Next: , Previous: , Up: Keymaps   [Contents][Index]


26.3 Creating Keymaps

Here we describe the functions for creating keymaps.

Function: make-keymap &optional name

This function constructs and returns a new keymap object. All entries in it are nil, meaning “command undefined”.

Optional argument name specifies a name to assign to the keymap, as in set-keymap-name. This name is only a debugging convenience; it is not used except when printing the keymap.

Function: make-sparse-keymap &optional name

This function constructs and returns a new keymap object. All entries in it are nil, meaning “command undefined”. The only difference between this function and make-keymap is that this function returns a “smaller” keymap (one that is expected to contain fewer entries). As keymaps dynamically resize, this distinction is not great.

Optional argument name specifies a name to assign to the keymap, as in set-keymap-name. This name is only a debugging convenience; it is not used except when printing the keymap.

Function: set-keymap-name keymap new-name

This function assigns a “name” to a keymap. The name is only a debugging convenience; it is not used except when printing the keymap.

Function: keymap-name keymap

This function returns the “name” of a keymap, as assigned using set-keymap-name.

Function: copy-keymap keymap

This function returns a copy of keymap. Any keymaps that appear directly as bindings in keymap are also copied recursively, and so on to any number of levels. However, recursive copying does not take place when the definition of a character is a symbol whose function definition is a keymap; the same symbol appears in the new copy.

(setq map (copy-keymap (current-local-map)))
⇒ #<keymap 3 entries 0x21f80>
(eq map (current-local-map))
    ⇒ nil

Next: , Previous: , Up: Keymaps   [Contents][Index]