1.11. Customizing Emacs
1.11.1. Keyboard Customization
You customize key bindings using one of three functions: define-key, global-set-key, or local-set-key. Their forms are:
(define-key keymap "keystroke" 'command-name) (global-set-key "keystroke" 'command-name) (local-set-key "keystroke" 'command-name)
Notice the double quotes around keystroke and the single quote preceding command-name. This is LISP syntax. The "keystroke" is one or more characters, either printable or special characters. Special characters, such as ESC, should be represented as shown in the table below.
1.11.1.1. Special character conventions
Special Character | Definition |
---|---|
\C-n | C-n (where n is any letter) |
\C-[ or \e | ESC |
\C-j or \n | LINEFEED |
\C-m or \r | RETURN |
\C-i or \T | TAB |
1.11.2. Emacs Variables
To set the value of a variable, use the setq function in your .emacs file, as in:
(setq auto-save-interval 800)
Although auto-save-interval takes an integer value, many Emacs variables take "true" or "false" values. In Emacs LISP, t is true and nil is false. Emacs variables can also take other types of values; here is how to specify them:
Strings of characters are surrounded by double quotes.
Characters are specified like strings but with a ? preceding them, and they are not surrounded by double quotes. Thus, ?x and ?\C-c are character values x and C-c, respectively.
Symbols are specified by a single quote followed by a symbol name—for example, 'never.
A list of some useful Emacs variables with descriptions ...
Get GNU Emacs Pocket Reference now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.