[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

22.3 Creating Keymaps

Here we describe the functions for creating keymaps.

Function: make-keymap &optional prompt
This function creates and returns a new full keymap. That keymap contains a char-table (see section 6.6 Char-Tables) with 384 slots: the first 128 slots are for defining all the ASCII characters, the next 128 slots are for 8-bit European characters, and each one of the final 128 slots is for one character set of non-ASCII characters supported by Emacs. The new keymap initially binds all these characters to nil, and does not bind any other kind of event.

 
(make-keymap)
    => (keymap [nil nil nil ... nil nil])

If you specify prompt, that becomes the overall prompt string for the keymap. The prompt string should be provided for menu keymaps (see section 22.12.1 Defining Menus).

Function: make-sparse-keymap &optional prompt
This function creates and returns a new sparse keymap with no entries. The new keymap does not contain a char-table, unlike make-keymap, and does not bind any events. The argument prompt specifies a prompt string, as in make-keymap.

 
(make-sparse-keymap)
    => (keymap)

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
     ;; (This implements meta characters.)
     (27 keymap         
         (83 . center-paragraph)
         (115 . center-line))
     (9 . tab-to-tab-stop))

(eq map (current-local-map))
    => nil
(equal map (current-local-map))
    => t


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on May 2, 2002 using texi2html