auf.suno
Connector, investor, futurist, geek, software developer, innovator, sportsman, libertarian, business enabler, cosmopolitan, autodidact, funny finch, tech evangelist,
purist, agnostic, Kärnten fan, foodie, artist, globetrotter, social liberal but fiscal conservative, Schöngeist... elegantiorum litterarum amans oder studiosus...

This is the website of Markus Gattol. It is composed, driven and secured/encrypted exclusively by Open Source Software. The speciality of this website
is that it is seamlessly integrating into my daily working environment (Python + MongoDB + Linux + SSH + GIT + ZeroMQ) which therefore means it
becomes a fully fledged and automatized publishing and communication platform. It will be under construction until 2014.

Open Source / Free Software, because freedom is in everyone's language...
Frihed Svoboda Libertà Vrijheid เสรีภาพ Liberté Freiheit Cê̤ṳ-iù Ελευθερία Свобода חרות Bebas Libertada 自由
auf.suno
Website Sections
Home
FAQs
About Me
Tweets by @markusgattol
Notes and Cheat Sheets Page for GNU Emacs
Status: Finished. New content might be added at any time.
Last changed: Saturday 2015-01-10 18:31 UTC
Abstract:

Whenever I work with GNU Emacs or read some documentation I make notes and add information to my various cheat sheets. Well, that was the past. Some time ago I decided to consolidate all that knowledge into a single page. This page is my collection for short notes and it also serves as a cheat sheet for information about GNU Emacs.
Table of Contents
GNU Emacs Hints and Notes
Special Emacs Subjects
Xft
mtty also known as multi-tty
Packages / Libraries
w3m
Dired
Image-Dired
How I process Static Images
TRAMP
artist-mode
pastie.el
python-mode
Notes, Functions, Variables and Settings
I want Emacs-like Behavior with GTK Applications
sort-numeric-fields
flush-lines
narrow-to-region
The grep Family
align-regexp
font-lock-mode
Collaboration with GNU Emacs
delete-duplicates respectively delete-dups
shell-quote-argument
file-newer-than-file-p
Info-goto-node
debug-on-error
file-attributes
call-process
C-M-h
C-x C-o
C-h p respectively M-x finder-by-keyword
M-x command-history
C-c C-l toggles font-lock-mode
list-colors-display
How to figure Faces and Text Properties of...
M-x list-faces-display
C-x respectively C-u C-x
count-lines-page
abbrev-mode
debug-on-signal
M-x locate-library RET <file_name> RET
M-x find-library RET <file_name> RET
Insert current date
C-u <an_integer> C-x f
What libraries are currently loaded
apropos.el
Transform text to lower/upper case
Development Versions of Emacs Packages
Automatize Updating to Development Code
Fetch up-to-date w3m Code
Fetch up-to-date BBDB Code
DebianGNU/* Notes
Leveraging debian-el
M-x apt-utils-show-package
M-x apt-utils-view-changelog
M-x apt-sources-mode
Dired
deb-view-dired-view

GNU Emacs Hints and Notes

Of course, since we are in GNU Emacs country, there is always another awesome thing beyond the horizon but sooner or later folks usually settle on a decent amount of additional Emacs packages, commands, functions and self constructed stuff within their .emacs, .gnus and a bunch of other libraries and files they came across during their past.

At least that is what happened to me and therefore I am going to not just put such useful stuff at this page from now on but also (and this will take at least a year or so) break down all the fine things I already use on a daily basis into fractions and put them here — this, however, is quite a work intensive task since my emacs stuff (as of now (February 2011) is spread all over my system.

Special Emacs Subjects

Xft

  • http://www.emacswiki.org/cgi-bin/wiki/XftGnuEmacs

mtty also known as multi-tty

Packages / Libraries

This subsection is about packages and libraries that I find worth mentioning explicitly. I am going to put information related to certain GNU Emacs packages/libraries I use in this section. I consider this packages useful or valuable to my daily work. However, I am not going to mention any piece of my .emacs here — just some things that I find worthy to additionally mention here.

w3m

w3m is not just yet another web browser. It is text-based web browser which smoothly integrates with GNU Emacs and thus blurs the borders between the Internet and the local machine. With w3m, what we get is a web browser that directly integrates into a platform (Emacs) and thus allows to use all the Emacs magic even when surfing the WWW (World Wide Web).

The left image above shows w3m in the lower right window (currently visiting http://plone.org/products/plone). The right image shows w3m this time with two sessions. Also what can be seen in the upper right window is ansi-term and how I create my screenshots. tsh is an alias in my .bashrc. So far so good... I am with up-to-the-minute w3m code from the upstream repository. Go here to see how I do it.

Dired

Well, how do I put it? Probably this one totally rocks describes it best. I am a CLI (Command Line Interface) addict for several reasons (speed and power mostly). So, is there any way to be even faster with daily tasks than using the CLI? Yes... there is... it definitely is Dired.

Dired, because over the years, I got used to traveling at hyperspace
speeds and whenever I drop out of hyperspace, back to sublight speed
(CLI) I get this fizzling noise in my left ear. It gets even worse if
I have to go on a planetary surface mission and move around on foot (GUI).
      — random space traveller, stardate 2988.4

Dired has some add-ons like Image-Dired for example or Dired-X (evaluate (i.e. point behind form and then C-x C-e) (Info-goto-node "(dired-x) Top") in order to directly jump into the info manual of Dired-X).

Then there is also Wdired (yes, you know the trick by now... evaluate (Info-goto-node "(emacs) Wdired")). Renaming files, changing permissions etc. has never been easier before... just hit C-x C-q in a dired buffer, rename/alter permissions/etc. and hit C-x C-c when done to make all changes permanent.

Image-Dired

Being with Emacs not just means one can chat, write emails, write source code, organize his schedule, manage his computer, etc. but it also means one has a powerful built-in image viewer and manipulator. Image-Dired is a facility for browsing image files. It provides viewing the images either as thumbnails or in full size, either inside Emacs or through an external viewer.

I pretty much live with the out of the box configuration for Image-Dired since all the keybindings and such is really good (at least from my point of view). I just made a few keybindings for some functions I found myself using on a regular which justified to gave them some shortcuts to invoke them. As usual, all my configuration for Image-Dired can be found in my .emacs.

My message for all the folks which still view/manage/mangle their images with some sort of heavy mousing approach — you guys might really stop wasting time and get to grips with Image-Dired, where rotating, moving around, resizing, building an XHTML gallery for some website etc. becomes as simple as, for example, pressing L in order to rotate original image 90 degrees to the left. One can also invoke (on the fly) any program/command on any image from within Image-Dired. For example, note the fading background in the full-size image which I accomplished by running a vertical Gauss filter on the image directly from within Image-Dired i.e. I simply triggered an Imagemagick command on the image.

Do that with common GUI (Graphical User Interface) image viewers and at the end of the day your mouse will have gone at least a few miles plus you wasted a lot of time because you simply dealt with a stupid UI (User Interface).

More information on Image-Dired can be found in the GNU Emacs manual (within Emacs just hit C-h r) chapter (Info-goto-node "(emacs) Image-Dired"). Also, the Emacswiki has a page about it (it was called Tumme in the past but then changed its name to the current name Image-Dired).

How I process Static Images

Of course, I also use the powers of Dired respectively Image-Dired to process my static images (photos). By processing, I refer to the whole

process chain from the point where I plug my all-in-one digicam via USB (Universal Serial Bus) to my computer until the photos (and other multimedia stuff I came home with) are tagged, sorted, reviewed and finally put into my multimedia archive.

This archive is nothing else than files on the file system — I dropped the super-but-folks-never-use-it-in-the-end-postgresql-for-private-multimedia approach in favor of the easy-to-use file system approach. I did that not because PostgreSQL is bad (in fact I think it rocks!) but simply because the fact that Dired is made in order to perform whatever actions on a file system. Using Dired boosts my productivity with regards to a UI (User Interface) more than any GUI (Graphical User Interface) or even CLI (Command Line Interface) could ever do.

Next to simply organizing my static images into categories implemented via simple directories, I also tag my static images. This happens during the input processing of images, while I review, mangle, reorder, etc. them and then put them into the archive.

The fact that I also tag my static images means that I get the possibility for another, horizontal view on my archive. This view can then be used (from within Image-Dired) to search, look up and reorganize things as needed. This horizontal view is more fine grained and flexible compared to the usual vertical tree view that comes with the file system tree. However, I got used to use those two approaches/views in a combined manner which really gets me great results from the beginning the whole way down to managing my archive.

The screenshot below shows a bunch of Dired buffers. This is at what I typically look at during the input processing of static images right after I plugged my digicam. I made two nice udev rules as can be seen below. Those rules basically guarantee that my digicam shows up at the same device nodes at any times and thus can be picked up by another script (buffer at the topmost window below) which mounts the digicam storage into my my computers local file system.

I got used to use

,----[ C-h k <f5> c e ]
| <f5> c e runs the command image-dired-copy-with-exif-file-name
|   which is an interactive compiled Lisp function in `image-dired.el'.
| It is bound to <f5> c e.
| (image-dired-copy-with-exif-file-name)
|
| Copy file with unique name to main image directory.
| Copy current or all marked files in dired to a new file in your
| main image directory, using a file name generated by
| `image-dired-get-exif-file-name'.  A typical usage for this if when
| copying images from a digital camera into the image directory.
|
|  Typically, you would open up the folder with the incoming
| digital images, mark the files to be copied, and execute this
| function.  The result is a couple of new files in
| `image-dired-main-image-directory' called
| 2005_05_08_12_52_00_dscn0319.jpg,
| 2005_05_08_14_27_45_dscn0320.jpg etc.
`----

in order to copy the static images from the digicam onto my computer which is great since it retrieves the EXIF (Exchangeable Image File Format) data from the static images and uses that information to generate the file name while it is copying the files.

TRAMP

After installing TRAMP (Transparent Remote Access Multiple Protocol) into our GNU Emacs, we will be able to access files on remote machines as though they were local. Access to the remote file system for editing files, version control, and dired are transparently enabled. Our access to the remote machine can be with the rsh, rlogin, telnet programs or with any similar connection method. This connection must pass ASCII successfully to be usable but need not be 8-bit clean.

The package provides support for SSH (Secure Shell) connections out of the box, one of the more common uses of the package. This allows relatively secure access to machines, especially if FTP (File Transfer Protocol) access is disabled. TRAMP can transfer files between machines in a variety of ways. The details are easy to select, depending on your needs and the machines in question.

TRAMP also provides the ability to edit files owned by another user than the current user on the fly e.g. we can edit files owned by root (/su::<path_to_file>) and just have to provide the root password once for each session. File permissions etc. do not change.

In fact, TRAMP can do a lot more than the afore mentioned. We can issue C-h i in order to start info (left window below) and read the TRAMP manual.

artist-mode

Artist mode, toggled by M-x artist-mode, lets us draw lines, squares, rectangles and poly-lines, ellipses, and circles with our mouse and/or keyboard. It is extremely useful when inserting text diagrams or figures into source comments (e.g. C++ source, Muse source, etc. For example, one might draw stuff like the below (took me under one minute ...) which can then be used to post into IRC/email/howtos etc. Into this, one might check pastie.el (see below).

                                    Mainframe
                                      -----
 +--------------+                    /.....\
 |              |        Data       /.......\
 |Linux Cluster | <-+-------------- |.......|
 |              |   |               \......./
 +--------------+   |                \...../
                    |                 -----
                    |
                    v
                +-------+
                |       |
                |  NAS  |
                |       |
                +-------+

There are some links and a nice screencast available.

pastie.el

Super useful to directly post from within Emacs into pastebin. More here and here.

python-mode

For python-mode and all other Python related information please visit the section about GNU Emacs on my Python page.

Notes, Functions, Variables and Settings

This is a random collection of various settings, functions and other nifty Emacs tricks that I find either worth mentioning or just wanted to make a note on them to not forget them since they already served me well in the past.

I want Emacs-like Behavior with GTK Applications

If we want Emacs-like behavior (keyboard shortcuts) with applications like for Firefox/Iceweasel, Pidgin, etc. then we can do

sa@wks:~$ touch .gtkrc-2.0
sa@wks:~$ echo 'gtk-key-theme-name = "Emacs"' > .gtkrc-2.0
sa@wks:~$ cat .gtkrc-2.0
gtk-key-theme-name = "Emacs"
sa@wks:~$

sort-numeric-fields

Comes in handy if you want to sort

0
2
3
4
5
18
6
9
10
7
22
11
12
8
13
14
1
16
17
19
20
21
15

into

0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

flush-lines

Sometimes after I copy-paste code snippets from web pages into some Emacs buffer I get text with superfluous blank lines delimiting code.

Marking region and running M-x flush-lines RET ^$ RET quickly makes it better by removing those pesky blank lines. This is, of course, makes sense only if pasted code does not contain blank lines you want to preserve.

narrow-to-region

You will love this! I use it for a lot of things e.g. narrow to region and then use occur on that region. This works anytime for any command i.e. there is no need for some command itself to feature <command>-on-region by itself. Just narrow to region and use any command you wish even when it has a built-in ...-on-region option.

,----[ C-h f narrow-to-region RET ]
| narrow-to-region is an interactive built-in function in `C source code'.
| It is bound to C-x n n.
| (narrow-to-region start end)
|
| Restrict editing in this buffer to the current region.
| The rest of the text becomes temporarily invisible and untouchable
| but is not deleted; if you save the buffer in a file, the invisible
| text is included in the file.  C-x n w makes all visible again.
| See also `save-restriction'.
|
| When calling from a program, pass two arguments; positions (integers
| or markers) bounding the text that should remain visible.
|
| [back]
`----

The grep Family

They can save you a lot of time. Namely they are find-grep, find-grep-dired, grep, grep-find (same as find-grep) and

,----[ C-h f rgrep RET ]
| rgrep is an interactive autoloaded Lisp function in `grep'.
| (rgrep regexp &optional files dir)
|
| Recursively grep for regexp in files in directory tree rooted at dir.
| The search is limited to file names matching shell pattern files.
| files may use abbreviations defined in `grep-files-aliases', e.g.
| entering `ch' is equivalent to `*.[ch]'.
|
| With C-u prefix, you can edit the constructed shell command line
| before it is executed.
| With two C-u prefixes, directly edit and run `grep-find-command'.
|
| Collect output in a buffer.  While find runs asynchronously, you
| can use C-x ` (M-x next-error), or
| Uses keymap "grep-mode-map", which is not currently defined.
| M-x compile-goto-error
| in the grep output buffer, to go to the lines where grep found matches.
|
| This command shares argument histories with M-x lgrep and M-x grep-find.
|
| [back]
`----

as well as

,----[ C-h f lgrep RET ]
| lgrep is an interactive autoloaded Lisp function in `grep'.
| (lgrep regexp &optional files dir)
|
| Run grep, searching for regexp in files in directory dir.
| The search is limited to file names matching shell pattern files.
| files may use abbreviations defined in `grep-files-aliases', e.g.
| entering `ch' is equivalent to `*.[ch]'.
|
| With C-u prefix, you can edit the constructed shell command line
| before it is executed.
| With two C-u prefixes, directly edit and run `grep-command'.
|
| Collect output in a buffer.  While grep runs asynchronously, you
| can use C-x ` (M-x next-error), or
| Uses keymap "grep-mode-map", which is not currently defined.
| M-x compile-goto-error
| in the grep output buffer, to go to the lines where grep found matches.
|
| This command shares argument histories with M-x rgrep and M-x grep.
|
| [back]
`----

align-regexp

This interactive Emacs Lisp function was very handy for me during some log files analysis. We mark the region, invoke align-regexp, provide a regexp and Et voilà!... our region is aligned.

Example data from align-regexp help:

Fred (123) 456-7890
Alice (123) 456-7890
Mary-Anne (123) 456-7890
Joe (123) 456-7890

Let us say, that we want to align a region on the ( character. For that, we mark the region that we want to align and invoke the function with: M-x align-regexp RET ( RET. The result of such invocation will be:

Fred      (123) 456-7890
Alice     (123) 456-7890
Mary-Anne (123) 456-7890
Joe       (123) 456-7890

font-lock-mode

Sometimes e.g. for cut/yank actions, toggling font-lock-mode is very helpful.

,----[ C-h f font-lock-mode RET ]
| font-lock-mode is an interactive compiled Lisp function in `font-core.el'.
| It is bound to C-c C-l.
| (font-lock-mode &optional arg)
|
| Toggle Font Lock mode.
| With arg, turn Font Lock mode off if and only if arg is a non-positive
| number; if arg is nil, toggle Font Lock mode; anything else turns Font
| Lock on.


[skipping a lot of lines...]


| The above is the default behavior of `font-lock-mode'; you may specify
| your own function which is called when `font-lock-mode' is toggled via
| `font-lock-function'.
|
| [back]
`----

Collaboration with GNU Emacs

It is possible to collaborate with GNU Emacs e.g. two persons editing one file.

delete-duplicates respectively delete-dups

Those two functions are used a lot here.

shell-quote-argument

,----[ C-h f shell-quote-argument RET ]
| shell-quote-argument is a compiled Lisp function in `subr.el'.
| (shell-quote-argument argument)
|
| Quote an argument for passing as argument to an inferior shell.
|
| [back]
`----

file-newer-than-file-p

,----[ C-h f file-newer-than-file-p RET ]
| file-newer-than-file-p is a built-in function in `C source code'.
| (file-newer-than-file-p file1 file2)
|
| Return t if file file1 is newer than file file2.
| If file1 does not exist, the answer is nil;
| otherwise, if file2 does not exist, the answer is t.
|
| [back]
`----

Info-goto-node

I make heavy use of the GNU Emacs built-in documentation system also known as info since

  • it allows for easy copy and paste
  • I do not have to switch back and forth between Emacs and another application all the time
  • I am so much faster using info than for example the html counterpart of the same manual
  • etc.

Often, I write documentation or just want to refer to some information within some manual or some page or so. Instead of doing it the cumbersome way most people do it

  • asking google
  • copy paste the URL over
  • probably touching the computer mouse (= annoying foreign substance)
  • etc.

all I have to do is to insert (Info-goto-node "(emacs)Abbrevs") for example. Then a person just has to position point after the closing parenthesis and hit C-x C-e and like magic, the info system gets started, the particularly manual (emacs) opens at the specific page (Abbrevs) — compare the time needed to do it the old-school way (searching, navigating, finding you are wrong, starting over again, ...).

Those who write some notes or documentation can visit particular info pages, hit w (runs the command Info-copy-current-node-name) and then paste it into either a template ((Info-goto-node "")) they create using some GNU Emacs magic like insert for example or they just type it every time it is needed.

debug-on-error

,----[ C-h v debug-on-error RET ]
| debug-on-error is a variable defined in `C source code'.
| Its value is nil
|
|
| Documentation:
| *Non-nil means enter debugger if an error is signaled.
| Does not apply to errors handled by `condition-case' or those
| matched by `debug-ignored-errors'.
| If the value is a list, an error only means to enter the debugger
| if one of its condition symbols appears in the list.
| When you evaluate an expression interactively, this variable
| is temporarily non-nil if `eval-expression-debug-on-error' is non-nil.
| See also variable `debug-on-quit'.
|
| You can customize this variable.
|
| [back]
`----

file-attributes

,----[ C-h f file-attributes RET ]
| file-attributes is a built-in function in `C source code'.
| (file-attributes filename &optional id-format)
|
| Return a list of attributes of file filename.
| Value is nil if specified file cannot be opened.
|
| id-format specifies the preferred format of attributes uid and gid (see
| below) - valid values are 'string and 'integer. The latter is the default,
| but we plan to change that, so you should specify a non-nil value for
| id-format if you use the returned uid or gid.
|
| Elements of the attribute list are:
|  0. t for directory, string (name linked to) for symbolic link, or nil.
|  1. Number of links to file.
|  2. File uid as a string or an integer.  If a string value cannot be
|   looked up, the integer value is returned.
|  3. File gid, likewise.
|  4. Last access time, as a list of two integers.
|   First integer has high-order 16 bits of time, second has low 16 bits.
|  5. Last modification time, likewise.
|  6. Last status change time, likewise.
|  7. Size in bytes.
|   This is a floating point number if the size is too large for an integer.
|  8. File modes, as a string of ten letters or dashes as in ls -l.
|  9. t if file's gid would change if file were deleted and recreated.
| 10. inode number.  If inode number is larger than the Emacs integer,
|   this is a cons cell containing two integers: first the high part,
|   then the low 16 bits.
| 11. Device number.  If it is larger than the Emacs integer, this is
|   a cons cell, similar to the inode number.
|
| [back]
`----

Use it like this

(nth 5 (file-attributes "~/.emacs")
to get the mtime (modification time).

call-process

,----[ C-h f call-process RET ]
| call-process is a built-in function in `C source code'.
| (call-process program &optional infile buffer display &rest args)
|
| Call program synchronously in separate process.
| The remaining arguments are optional.
| The program's input comes from file infile (nil means `/dev/null').
| Insert output in buffer before point; t means current buffer;
|  nil for buffer means discard it; 0 means discard and don't wait.
| buffer can also have the form (REAL-BUFFER STDERR-FILE); in that case,
| REAL-BUFFER says what to do with standard output, as above,
| while STDERR-FILE says what to do with standard error in the child.
| STDERR-FILE may be nil (discard standard error output),
| t (mix it with ordinary output), or a file name string.
|
| Fourth arg display non-nil means redisplay buffer as output is inserted.
| Remaining arguments are strings passed as command arguments to program.
|
| If executable program can't be found as an executable, `call-process'
| signals a Lisp error.  `call-process' reports errors in execution of
| the program only through its return and output.
|
| If buffer is 0, `call-process' returns immediately with value nil.
| Otherwise it waits for program to terminate
| and returns a numeric exit status or a signal description string.
| If you quit, the process is killed with SIGINT, or SIGKILL if you quit again.
|
| [back]
`----

C-M-h

,----[ C-h k C-M-h ]
| C-M-h runs the command mark-defun
|   which is an interactive compiled Lisp function in `lisp.el'.
| It is bound to C-M-h.
| (mark-defun &optional allow-extend)
|
| Put mark at end of this defun, point at beginning.
| The defun marked is the one that contains point or follows point.
|
| Interactively, if this command is repeated
| or (in Transient Mark mode) if the mark is active,
| it marks the next defun after the ones already marked.
|
| [back]
`----

C-x C-o

A lovely thing indeed...

,----[ C-h f delete-blank-lines RET ]
| delete-blank-lines is an interactive compiled Lisp function in `simple.el'.
| It is bound to C-x C-o.
| (delete-blank-lines)
|
| On blank line, delete all surrounding blank lines, leaving just one.
| On isolated blank line, delete that one.
| On nonblank line, delete any immediately following blank lines.
|
| [back]
`----

C-h p respectively M-x finder-by-keyword

Next to all those C-h f/v/k/m/b etc. there is another quite useful keybinding.

,----[ C-h f finder-by-keyword RET ]
| finder-by-keyword is an interactive autoloaded Lisp function in `finder'.
| It is bound to C-h p, <f1> p, <help> p, <menu-bar> <help-menu> <finder-by-keyword>.
| (finder-by-keyword)
|
| Find packages matching a given keyword.
|
| [back]
`----

M-x command-history

,----[ C-h f command-history RET ]
| command-history is an interactive compiled Lisp function in `chistory.el'.
| (command-history)
|
| Examine commands from `command-history' in a buffer.
| The number of commands listed is controlled by `list-command-history-max'.
| The command history is filtered by `list-command-history-filter' if non-nil.
| Use x to repeat the command on the current line.
|
| Otherwise much like Emacs-Lisp Mode except that there is no self-insertion
| and digits provide prefix arguments.  Tab does not indent.
| key             binding
| ---             -------
|
| TAB           lisp-indent-line
| C-j           next-line
| RET           next-line
| ESC           Prefix Command
| -             negative-argument
| 0 .. 9                digit-argument
| x             command-history-repeat
| DEL           previous-line
| <remap>               Prefix Command
|
| C-M-q         indent-sexp
|
|
|
| This command always recompiles the Command History listing
| and runs the normal hook `command-history-hook'.
|
| [back]
`----

C-c C-l toggles font-lock-mode

Toggle Font Lock mode. Font Lock is also known as syntax highlighting. For more info try C-h f font-lock-mode RET.

list-colors-display

If you would like to see what colors are available for GNU Emacs faces try M-x list-colors-display. What you get is something like that

How to figure Faces and Text Properties of...

M-x describe-face or M-x describe-text-properties will show you information about faces and text properties.

M-x list-faces-display

,----[ C-h f list-faces-display RET ]
| list-faces-display is an interactive compiled Lisp function in `faces.el'.
| It is bound to <C-down-mouse-2> <df>, <menu-bar> <edit> <props> <df>.
| (list-faces-display &optional regexp)
|
| List all faces, using the same sample text in each.
| The sample text is a string that comes from the variable
| `list-faces-sample-text'.
|
| If regexp is non-nil, list only those faces with names matching
| this regular expression.  When called interactively with a prefix
| arg, prompt for a regular expression.
`----

A picture says more than a thousand words

The left window above shows the current faces. The right window — on top a ansi terminal, the buffer list in the middle and the window at the right bottom shows the menu that can be used to edit a particular face that has been chosen from the left window — see the bottom of my .emacs (you find it on my main GNU Emacs page) how it looks like.

C-x respectively C-u C-x

A very useful command if you have problems with the display of some fonts and the like — use what-cursor-position to get information about the font etc.

,----[ C-h k C-x = ]
| C-x = runs the command what-cursor-position
|   which is an interactive compiled Lisp function in `simple.el'.
| It is bound to C-x =.
| (what-cursor-position &optional detail)
|
| Print info on cursor position (on screen and within buffer).
| Also describe the character after point, and give its character code
| in octal, decimal and hex.
|
| For a non-ASCII multibyte character, also give its encoding in the
| buffer's selected coding system if the coding system encodes the
| character safely.  If the character is encoded into one byte, that
| code is shown in hex.  If the character is encoded into more than one
| byte, just "..." is shown.
|
| In addition, with prefix argument, show details about that character
| in *Help* buffer.  See also the command `describe-char'.
|
| [back]
`----

count-lines-page

If you want to know how many lines the current page has plus how many lines are before (above) point and how many are after (below) point, then you might use

,----[ C-h k C-x l ]
| C-x l runs the command count-lines-page
|   which is an interactive compiled Lisp function in `page.el'.
| It is bound to C-x l.
| (count-lines-page)
|
| Report number of lines on current page, and how many are before or after point.
|
| [back]
`----

What you get is something like this in the minibuffer Page has 962 lines (52 + 910). As can be seen, the current page (buffer) has a total of 962 lines of which are 52 from current point position to the top of the page and 910 from point to the bottom of the page.

abbrev-mode

Whenever I write text, I commonly use things like CLI (Command Line Interface) — an abbreviation (CLI) and its explanation ((Command Line Interface)). In fact, people use abbreviations very often and thus it is an ideal thing to be automatized in order to save time.

With Emacs there is the so called abbrev-mode which can be used to, for example just type cli and then use a keybinding (e.g. C-x a e) in order to expand cli to CLI (Command Line Interface).

After using C-x a g to add new abbreviations one could either take a look at them (M-x list-abbrevs) or edit them (M-x edit-abbrevs) and when done, save them (C-c C-c). Take a look at the abbreviation mode info manual for more information.

debug-on-signal

,----[ C-h v debug-on-signal RET ]
| debug-on-signal is a variable defined in `C source code'.
| Its value is nil
|
|
| Documentation:
| *Non-nil means call the debugger regardless of condition handlers.
| Note that `debug-on-error', `debug-on-quit' and friends
| still determine whether to handle the particular condition.
`----

M-x locate-library RET &lt;file_name&gt; RET

,----[ C-h f locate-library RET ]
| locate-library is an interactive compiled Lisp function in `subr.el'.
| (locate-library library &optional nosuffix path interactive-call)
|
| Show the precise file name of Emacs library library.
| This command searches the directories in `load-path' like `M-x load-library'
| to find the file that `M-x load-library RET library RET' would load.
| Optional second arg nosuffix non-nil means don't add suffixes `load-suffixes'
| to the specified name library.
|
| If the optional third arg path is specified, that list of directories
| is used instead of `load-path'.
|
| When called from a program, the file name is normaly returned as a
| string.  When run interactively, the argument interactive-call is t,
| and the file name is displayed in the echo area.
|
| [back]
`----

M-x find-library RET &lt;file_name&gt; RET

,----[ C-h f find-library RET ]
| find-library is an interactive autoloaded Lisp function in `find-func'.
| (find-library library)
|
| Find the elisp source of library.
|
| [back]
`----

Insert current date

The sequence

C-u M-S-! date RET

inserts the current date

Sun Jun 24 04:35:59 BST 2007

at point. Instead of date, you can choose any CLI (Command Line Interface) command — see for yourself

,----[ C-h k M-! ]
| M-! runs the command shell-command
|   which is an interactive compiled Lisp function in `simple.el'.
| It is bound to M-!, <menu-bar> <tools> <shell>.
| (shell-command command &optional output-buffer error-buffer)
|
| Execute string command in inferior shell; display output, if any.


[skipping a lot of lines...]


| If it is nil, error output is mingled with regular output.
| In an interactive call, the variable `shell-command-default-error-buffer'
| specifies the value of error-buffer.
|
| [back]
`----

C-u &lt;an_integer&gt; C-x f

Normally the column width is set to 70 characters but sometimes you might want to change that. I for example use it to write the whole text in the Abstract area into a single line without a line break. So I do something like C-u 5000 C-x f for example.

,----[ C-h k C-x f ]
| C-x f runs the command set-fill-column
|   which is an interactive compiled Lisp function in `simple.el'.
| It is bound to C-x f.
| (set-fill-column arg)
|
| Set `fill-column' to specified argument.
| Use C-u followed by a number to specify a column.
| Just C-u as argument means to use the current column.
|
| [back]
`----

However, another way to accomplish the above would be to toggle auto-fill-mode like this

;;;_ , toggle-option

(require 'toggle-option)

(setq toggle-option-list
      '(
         (flyspell-mode function nil nil)
         (auto-fill-mode function nil nil)
       )
)

and use it like that

;;;_  . 'auto-fill-mode

(global-set-key (kbd "C-c t a")
                  (fset 'toggle-auto-fill-mode
                    (lambda () "Toggle auto-fill-mode"
                      (interactive)
                      (toggle-option 'auto-fill-mode)
                    )
                  )
)

So, all you need to do is using C-c t a to toggle auto-fill-mode between on and off. Whatever approach you choose probably depends on the current situation...

What libraries are currently loaded

If you want to find out which libraries are currently loaded try

,----[ C-h v features RET ]
| features is a variable defined in `C source code'.
| Its value is
| (repeat muse-http cgi httpd vc-arch [skipping a lot of libs]  gtk x-toolkit x emacs)
|
|
|
| Documentation:
| A list of symbols which are the features of the executing Emacs.
| Used by `featurep' and `require', and altered by `provide'.
|
| [back]
`----

or the variable load-history. It records lots of information about what libraries have been loaded in your session so far, what functions and variables they each define, and what other libraries they require. Try C-h v load-history - you'll get a very long list of very long entries. In this regards, also take a look at the function unload-feature, file-requires, file-provides and file-dependents.


For a list of loaded files you can take a look at

,----[ C-h f eval-after-load RET ]
| eval-after-load is a compiled Lisp function in `subr.el'.
| (eval-after-load file form)
|
| Arrange that, if file is ever loaded, form will be run at that time.
| If file is already loaded, evaluate form right now.


[skipping a lot of lines...]


| Usually file is just a library name like "font-lock" or a feature name
| like 'font-lock.
|
| This function makes or adds to an entry on `after-load-alist'.
|
| [back]
`----

apropos.el

I forget basic Emacs stuff all the time so I need something to help me out...


This one is, bound to C-h a by default as can be seen. Thing is it just looks for interactive commands. Use C-u C-h a to also search for non-interactive functions.

,----[ C-h f apropos-command RET ]
| apropos-command is an interactive compiled Lisp function in `apropos.el'.
| It is bound to C-h a, <f1> a, <help> a, <menu-bar> <help-menu> <apropos> <apropos-commands>.
| (apropos-command pattern &optional do-all var-predicate)
|
| Show commands (interactively callable functions) that match pattern.
| pattern can be a word, a list of words (separated by spaces),
| or a regexp (using some regexp special characters).  If it is a word,
| search for matches for that word as a substring.  If it is a list of words,
| search for matches for any two (or more) of those words.
|
| With C-u prefix, or if `apropos-do-all' is non-nil, also show
| noninteractive functions.
|
| If var-predicate is non-nil, show only variables, and only those that
| satisfy the predicate var-predicate.
|
| When called from a Lisp program, a string pattern is used as a regexp,
| while a list of strings is used as a word list.
|
| [back]
`----

If you want to search for variables use. Note the difference when using the C-u prefix.

,----[ C-h f apropos-variable RET ]
| apropos-variable is an interactive compiled Lisp function in `apropos.el'.
| It is bound to <menu-bar> <help-menu> <apropos> <apropos-variables>.
| (apropos-variable pattern &optional do-all)
|
| Show user variables that match pattern.
| pattern can be a word, a list of words (separated by spaces),
| or a regexp (using some regexp special characters).  If it is a word,
| search for matches for that word as a substring.  If it is a list of words,
| search for matches for any two (or more) of those words.
|
| With C-u prefix, or if `apropos-do-all' is non-nil, also show
| normal variables.
|
| [back]
`----

You are looking for some value. Again, C-u makes a difference.

,----[ C-h f apropos-value RET ]
| apropos-value is an interactive compiled Lisp function in `apropos.el'.
| It is bound to <menu-bar> <help-menu> <apropos> <apropos-value>.
| (apropos-value pattern &optional do-all)
|
| Show all symbols whose value's printed representation matches pattern.
| pattern can be a word, a list of words (separated by spaces),
| or a regexp (using some regexp special characters).  If it is a word,
| search for matches for that word as a substring.  If it is a list of words,
| search for matches for any two (or more) of those words.
|
| With C-u prefix, or if `apropos-do-all' is non-nil, also looks
| at the function and at the names and values of properties.
| Returns list of symbols and values found.
|
| [back]
`----

Now that is a neat thing indeed

,----[ C-h f apropos-documentation RET ]
| apropos-documentation is an interactive compiled Lisp function in `apropos.el'.
| It is bound to C-h d, <f1> d, <help> d, <menu-bar> <help-menu> <apropos> <apropos-documentation>.
| (apropos-documentation pattern &optional do-all)
|
| Show symbols whose documentation contains matches for pattern.
| pattern can be a word, a list of words (separated by spaces),
| or a regexp (using some regexp special characters).  If it is a word,
| search for matches for that word as a substring.  If it is a list of words,
| search for matches for any two (or more) of those words.
|
| With C-u prefix, or if `apropos-do-all' is non-nil, also use
| documentation that is not stored in the documentation file and show key
| bindings.
| Returns list of symbols and documentation found.
|
| [back]
`----

Finally you could set

,----[ C-h v apropos-do-all RET ]
| apropos-do-all is a variable defined in `apropos.el'.
| Its value is nil
|
|
| Documentation:
| *Whether the apropos commands should do more.
|
| Slows them down more or less.  Set this non-nil if you have a fast machine.
|
| You can customize this variable.
|
| [back]
`----

to non-nil anyway if you would like to.


For the more-confused ones a look at the source might provide some more nifty tricks to find orientation again

,----[ C-h f find-library RET ]
| find-library is an interactive compiled Lisp function in `find-func.el'.
| (find-library library)
|
| Find the elisp source of library.
|
| [back]
`----

a M-x find-library RET <.el that you are looking for> RET that is.


Transform text to lower/upper case

This is bound to C-x C-l (lower) respectively C-x C-u (upper). Also, you may put

(put 'downcase-region 'disabled nil)
(put 'upcase-region 'disabled nil)

into your .emacs.


,----[ C-h f downcase-region RET ]
| downcase-region is an interactive built-in function in `C source code'.
| It is bound to C-x C-l.
| (downcase-region beg end)
|
| Convert the region to lower case.  In programs, wants two arguments.
| These arguments specify the starting and ending character numbers of
| the region to operate on.  When used as a command, the text between
| point and the mark is operated on.
|
| [back]
`----

Development Versions of Emacs Packages

I have certain Emacs packages or just single files that even to old in DebianGNU/* sid (still in development). Because of that, I am using the up-to-date code of those packages which I directly pull from projects SCM (Software Configuration Management) systems on a regular.

Automatize Updating to Development Code

The fact that development code is not available via APT (Advanced Packaging Tool) requires one to take care one selves about acquiring the up-to-date code.

In order to ease such repetitive tasks I decided to introduce a little shell code magic. The idea is simple:

  1. First I am going to create some shell aliases in my .bashrc for each of the development packages which downloads the changes from a projects upstream repository and merges them into my local branch.
  2. When I have a working alias for each package I can chain them together and encapsulate all former aliases into a single one that executes one by one e.g. alias ua='pa_1 && pa_2... && pa_n'
  3. With a working ua (update all) alias I can then easily trigger things with a cronjob or manually as needed.
  4. Finally some sane checks might be added i.e. how to handle errors. For example how to handle an error while downloading changes from a remote repository when the URL changed or the host is unreachable and the like.

Now, if you just take a look at my .bashrc you can see that 1 and 2 from above are already done — 3 is not since I trigger e.g. mur manually every 3 days or so as I feel lucky about doing so — triggering via cronjob would of course be trivial. I did not care about 4 so far since after testing all worked fine — I will probably add code when I run into problems.

Fetch up-to-date w3m Code

Yesterday (Tue Sep 4 2007) I switched to the multi-tty branch. After that, Emacs did not start correctly (see how I start Emacs — I use an alias in my .bashrc) i.e. Emacs complained that no w3m was found. After a while it turned out, that Debians current w3m-el package did not contain up-to-date w3m code so I needed to fetch from CVS cvs -d :pserver:anonymous@cvs.namazu.org:/storage/cvsroot login && cvs -z9 -d:pserver:anonymous@cvs.namazu.org:/storage/cvsroot co -d w3m-el emacs-w3m. Hint: hit RET on the anonymous CVS login — no password needed.

Fetch up-to-date BBDB Code

The development and release versions are available via Anon-CVS to the CVS tree at bbdb.cvs.sourceforge.net. To access the tree, log in with the following command: cvs -d :pserver:anonymous@bbdb.cvs.sourceforge.net:/cvsroot/bbdb login. The password is blank; just hit return at the prompt.

To check out the development version of the BBDB, use the following command: cvs -d :pserver:anonymous@bbdb.cvs.sourceforge.net:/cvsroot/bbdb checkout bbdb

DebianGNU/* Notes

This section is about GNU Emacs providing and/or leveraging features for DebianGNU/*. The package

sa@pc1:~$ acsh debian-el | grep -A9 ^Description
Description: Emacs helpers specific to Debian users
 This package contains:
 .
  apt-sources - major mode for editing Debian sources.list files;
  apt-utils - interface to APT (Debian package management);
  debian-bug - an Emacs command to submit a bug report;
  deb-view - view contents of Debian package, similarly to tar-mode;
  gnus-BTS - provides buttons for bug numbers seen in Gnus messages;
  preseed - major mode for editing debian-installer preseed files.
 .
sa@pc1:~$

is such an example. It provides outstanding tools to GNU Emacs in order to retrieve information from Debian or to do work on/with Debian. However, note that I also provide information on this website which tells about common tools that help to develop and maintain software for Debian.

Leveraging debian-el

This section shows some examples that leverage the powers that are available when using debian-el (install it with apt-get install debian-el. This section can only scratch the surface of what is possible. Nonetheless I will try to provide some depicting examples in order to provide the first time reader with a notion of what can be done as well as the guru with a nice time to linger-and-skim-over already well-known things.

After installing debian-el, the first thing one might try is to fire up the info manual of debian-el — two choices...

  • first one: C-h i and then navigating dir to the entry for debian-el
  • second one: evaluate (Info-goto-node "(debian-el) Top"). Of course, the second one is way more like

M-x apt-utils-show-package

First, we show a packages information as most of you are probably used to when you use the CLI (Command Line Interface) e.g. apt-cache show <package_name> or aptitude show <package_name>. Of course some of you may use a GUI (Graphical User Interface) as well. I use GNU Emacs because I think it is the most comfortable, fastest and by far mightiest way to connect human brains to DebianGNU/*.

After issuing M-x apt-utils-show-package (or for the speed demons which we are — using the fancy-two-keys keybinding created) and entering a package name we get this (left image). The other two show just more Emacs magic once we are in apt-utils-mode.

M-x apt-utils-view-changelog

Above we issued a command to show a packages information. Pretty much every time I take a look at the change-log. I am used to this although I use

sa@pc1:/tmp$ acsn apt-list*
apt-listbugs - Lists critical bugs before each apt installation
apt-listchanges - Display change history from .deb archives
sa@pc1:/tmp$

To figure the change-log of the package debian-el which is still open in the right window (see above) all we have to do is to issue M-x apt-utils-view-change-log or even better since we are cool Emacsers, working at speeds others can only dream of, we might just hit v c and what we get is this (point must be in the buffer showing the package information; right window in the current situation — see above)

How long would it probably take to do all that via the mouse or by changing into the change-log directory of a particular package? Sure, most tools have either a switch or provide some other possibility to attain whatever information is needed but in the end my experience is, using an integrated environment like GNU Emacs has proven numerously superior because that logical chaining of moving from A to B and back and from there on to C etc. and doing something that semantically fits the current needs of a human is always just a few keystrokes far from being completed.

M-x apt-sources-mode

A GNU Emacs mode that eases editing /etc/apt/sources.list files a lot.

Dired

Dired has some neat features...

deb-view-dired-view

,----[ C-h f deb-view-dired-view RET ]
| deb-view-dired-view is an interactive compiled Lisp function in `deb-view.el'.
| (deb-view-dired-view)
|
| View Debian package control and data files.
| Press "q" in either window to kill both buffers
| and return to the dired buffer. See deb-view.
|
| [back]
`----

deb-view-dired-view in action i.e. first image is on the left side, second in the middle... Also, note the green rectangle, which is point in my case (customface).

Creative Commons License
The content of this site is licensed under Creative Commons Attribution-Share Alike 3.0 License.