(lispref.info)Keymaps and Minor Modes

Prev: Minor Mode Conventions Up: Minor Modes

Keymaps and Minor Modes

   As of Emacs version 19, each minor mode can have its own keymap
which is active when the mode is enabled.  Note: Active Keymaps.  To
set up a keymap for a minor mode, add an element to the alist

   One use of minor mode keymaps is to modify the behavior of certain
self-inserting characters so that they do something else as well as
self-insert.  This is the only way to accomplish this in general, since
there is no way to customize what `self-insert-command' does except in
certain special cases (designed for abbrevs and Auto Fill mode).  (Do
not try substituting your own definition of `self-insert-command' for
the standard one.  The editor command loop handles this function

 - Variable: minor-mode-map-alist
     This variable is an alist of elements element that look like this:

          (VARIABLE . KEYMAP)

     where VARIABLE is the variable which indicates whether the minor
     mode is enabled, and KEYMAP is the keymap.  The keymap KEYMAP is
     active whenever VARIABLE has a non-`nil' value.

     Note that elements of `minor-mode-map-alist' do not have the same
     structure as elements of `minor-mode-alist'.  The map must be the
     CDR of the element; a list with the map as the second element will
     not do.

     What's more, the keymap itself must appear in the CDR.  It does not
     work to store a variable in the CDR and make the map the value of
     that variable.

     When more than one minor mode keymap is active, their order of
     priority is the order of `minor-mode-map-alist'.  But you should
     design minor modes so that they don't interfere with each other.
     If you do this properly, the order will not matter.

automatically generated by info2www