(lispref.info)Scanning Keymaps

Prev: Key Binding Commands Up: Keymaps

Scanning Keymaps

   This section describes functions used to scan all the current keymaps
for the sake of printing help information.

 - Function: accessible-keymaps KEYMAP &optional PREFIX
     This function returns a list of all the keymaps that can be
     accessed (via prefix keys) from KEYMAP.  The value is an
     association list with elements of the form `(KEY . MAP)', where
     KEY is a prefix key whose definition in KEYMAP is MAP.

     The elements of the alist are ordered so that the KEY increases in
     length.  The first element is always `("" . KEYMAP)', because the
     specified keymap is accessible from itself with a prefix of no

     If PREFIX is given, it should be a prefix key sequence; then
     `accessible-keymaps' includes only the submaps whose prefixes start
     with PREFIX.  These elements look just as they do in the value of
     `(accessible-keymaps)'; the only difference is that some elements
     are omitted.

     In the example below, the returned alist indicates that the key
     ESC, which is displayed as `^[', is a prefix key whose definition
     is the sparse keymap `(keymap (83 . center-paragraph) (115 .

          (accessible-keymaps (current-local-map))
          =>(("" keymap
                (27 keymap   ; Note this keymap for ESC is repeated below.
                    (83 . center-paragraph)
                    (115 . center-line))
                (9 . tab-to-tab-stop))

          ("^[" keymap
              (83 . center-paragraph)
              (115 . foo)))

     In the following example, `C-h' is a prefix key that uses a sparse
     keymap starting with `(keymap (118 . describe-variable)...)'.
     Another prefix, `C-x 4', uses a keymap which happens to be
     `ctl-x-4-map'.  The event `mode-line' is one of several dummy
     events used as prefixes for mouse actions in special parts of a

          (accessible-keymaps (current-global-map))
          => (("" keymap [set-mark-command beginning-of-line ...

          ("^H" keymap (118 . describe-variable) ...
               (8 . help-for-help))

          ("^X" keymap [x-flush-mouse-queue ...

          ("^[" keymap [mark-sexp backward-sexp ...
              ("^X4" keymap (15 . display-buffer) ...)
          ([mode-line] keymap
               (S-mouse-2 . mouse-split-window-horizontally) ...))

     These are not all the keymaps you would see in an actual case.

 - Function: where-is-internal COMMAND &optional KEYMAP FIRSTONLY
     This function returns a list of key sequences (of any length) that
     are bound to COMMAND in KEYMAP and the global keymap.  The
     argument COMMAND can be any object; it is compared with all keymap
     entries using `eq'.  If KEYMAP is not supplied, then the global
     map alone is used.

     If FIRSTONLY is non-`nil', then the value is a single string
     representing the first key sequence found, rather than a list of
     all possible key sequences.

     This function is used by `where-is' (Note: Help.).

          (where-is-internal 'describe-function)
              => ("\^hf" "\^hd")

 - Command: describe-bindings PREFIX
     This function creates a listing of all defined keys, and their
     definitions.  The listing is put in a buffer named `*Help*', which
     is then displayed in a window.

     A meta character is shown as ESC followed by the corresponding
     non-meta character.  Control characters are indicated with `C-'.

     When several characters with consecutive ASCII codes have the same
     definition, they are shown together, as `FIRSTCHAR..LASTCHAR'.  In
     this instance, you need to know the ASCII codes to understand
     which characters this means.  For example, in the default global
     map, the characters `SPC .. ~' are described by a single line.
     SPC is ASCII 32, `~' is ASCII 126, and the characters between them
     include all the normal printing characters, (e.g., letters,
     digits, punctuation, etc.); all these characters are bound to

     If PREFIX is non-`nil', it should be a prefix key; then only keys
     that start with PREFIX are described.

automatically generated by info2www