Next: Creating Keymaps, Previous: Keymap Terminology, Up: Keymaps
A keymap is a list whose car is the symbol keymap
. The
remaining elements of the list define the key bindings of the keymap.
Use the function keymapp
(see below) to test whether an object is
a keymap.
Several kinds of elements may appear in a keymap, after the symbol
keymap
that begins it:
(
type .
binding)
(t .
binding)
When a keymap contains a vector, it always defines a binding for each
ascii character, even if the vector contains nil
for that
character. Such a binding of nil
overrides any default key
binding in the keymap, for ascii characters. However, default
bindings are still meaningful for events other than ascii
characters. A binding of nil
does not override
lower-precedence keymaps; thus, if the local map gives a binding of
nil
, Emacs uses the binding from the global map.
Keymaps do not directly record bindings for the meta characters.
Instead, meta characters are regarded for purposes of key lookup as
sequences of two characters, the first of which is <ESC> (or
whatever is currently the value of meta-prefix-char
). Thus, the
key M-a is internally represented as <ESC> a, and its
global binding is found at the slot for a in esc-map
(see Prefix Keys).
This conversion applies only to characters, not to function keys or other input events; thus, M-<end> has nothing to do with <ESC> <end>.
Here as an example is the local keymap for Lisp mode, a sparse keymap. It defines bindings for <DEL> and <TAB>, plus C-c C-l, M-C-q, and M-C-x.
lisp-mode-map => (keymap ;; <TAB> (9 . lisp-indent-line) ;; <DEL> (127 . backward-delete-char-untabify) (3 keymap ;; C-c C-l (12 . run-lisp)) (27 keymap ;; M-C-q, treated as <ESC> C-q (17 . indent-sexp) ;; M-C-x, treated as <ESC> C-x (24 . lisp-send-defun)))