emacs: Keymaps
51.3.1 Keymaps
--------------
As described in Commands, each Emacs command is a Lisp function
whose definition provides for interactive use. Like every Lisp
function, a command has a function name, which usually consists of
lower-case letters and hyphens.
A “key sequence” (“key”, for short) is a sequence of “input events”
that have a meaning as a unit. Input events include characters,
function keys and mouse buttons—all the inputs that you can send to the
computer. A key sequence gets its meaning from its “binding”, which
says what command it runs.
The bindings between key sequences and command functions are recorded
in data structures called “keymaps”. Emacs has many of these, each used
on particular occasions.
The “global” keymap is the most important keymap because it is always
Major Modes::); most of these definitions are common to most or all
major modes. Each major or minor mode can have its own keymap which
overrides the global definitions of some keys.
For example, a self-inserting character such as ‘g’ is self-inserting
because the global keymap binds it to the command ‘self-insert-command’.
The standard Emacs editing characters such as ‘C-a’ also get their
standard meanings from the global keymap. Commands to rebind keys, such
as ‘M-x global-set-key’, work by storing the new binding in the proper
place in the global map (Rebinding).
Most modern keyboards have function keys as well as character keys.
Function keys send input events just as character keys do, and keymaps
can have bindings for them. Key sequences can mix function keys and
characters. For example, if your keyboard has a <Home> function key,
Emacs can recognize key sequences like ‘C-x <Home>’. You can even mix
mouse events with keyboard events, such as ‘S-down-mouse-1’.
On text terminals, typing a function key actually sends the computer
a sequence of characters; the precise details of the sequence depends on
the function key and on the terminal type. (Often the sequence starts
with ‘<ESC> [’.) If Emacs understands your terminal type properly, it
automatically handles such sequences as single input events.