Next: , Previous: Active Keymaps, Up: Keymaps


22.8 Searching the Active Keymaps

After translation of event subsequences (see Translation Keymaps) Emacs looks for them in the active keymaps. Here is a pseudo-Lisp description of the order in which the active keymaps are searched:

     (or (if overriding-terminal-local-map
             (find-in overriding-terminal-local-map)
           (if overriding-local-map
               (find-in overriding-local-map)
             (or (find-in (get-text-property (point) 'keymap))
                 (find-in-any emulation-mode-map-alists)
                 (find-in-any minor-mode-overriding-map-alist)
                 (find-in-any minor-mode-map-alist)
                 (if (get-text-property (point) 'local-map)
                     (find-in (get-text-property (point) 'local-map))
                   (find-in (current-local-map))))))
         (find-in (current-global-map)))

The find-in and find-in-any are pseudo functions that search in one keymap and in an alist of keymaps, respectively.

  1. The function finally found may be remapped (see Remapping Commands).
  2. Characters that are bound to self-insert-command are translated according to translation-table-for-input before insertion.
  3. current-active-maps returns a list of the currently active keymaps at point.
  4. When a match is found (see Key Lookup), if the binding in the keymap is a function, the search is over. However if the keymap entry is a symbol with a value or a string, Emacs replaces the input key sequences with the variable's value or the string, and restarts the search of the active keymaps.

Xah Signet