Next: Key Sequences, Previous: Creating Keymaps, Up: Keymaps [Contents][Index]
A keymap can inherit the bindings of other keymaps. The other
keymaps are called the keymap’s parents, and are set with
set-keymap-parents
. When searching for a binding for a key
sequence in a particular keymap, that keymap itself will first be
searched; then, if no binding was found in the map and it has parents,
the first parent keymap will be searched; then that keymap’s parent will
be searched, and so on, until either a binding for the key sequence is
found, or a keymap without a parent is encountered. At this point,
the search will continue with the next parent of the most recently
encountered keymap that has another parent, etc. Essentially, a
depth-first search of all the ancestors of the keymap is conducted.
(current-global-map)
is the default parent of all keymaps.
This function sets the parent keymaps of keymap to the list parents.
If you change the bindings in one of the keymaps in parents using
define-key
or other key-binding functions, these changes are
visible in keymap unless shadowed by bindings in that map or in
earlier-searched ancestors. The converse is not true: if you use
define-key
to change keymap, that affects the bindings in
that map, but has no effect on any of the keymaps in parents.
This function returns the list of parent keymaps of keymap, or
nil
if keymap has no parents.
As an alternative to specifying a parent, you can also specify a default binding that is used whenever a key is not otherwise bound in the keymap. This is useful for terminal emulators, for example, which may want to trap all keystrokes and pass them on in some modified format. Note that if you specify a default binding for a keymap, neither the keymap’s parents nor the current global map are searched for key bindings.
This function sets the default binding of keymap to command,
or nil
if no default is desired.
This function returns the default binding of keymap, or nil
if it has none.
Next: Key Sequences, Previous: Creating Keymaps, Up: Keymaps [Contents][Index]