Next: , Previous: , Up: Modes   [Index]


10.2 Minor Modes

A minor mode is an optional editing mode that alters the behavior of Emacs in some well-defined way. Unlike major modes, any number of minor modes can be in effect at any time.

Buffer Local

Some minor modes are buffer-local, and can be turned on (enabled) in certain buffers and off (disabled) in others.

Global

Other minor modes are global: while enabled, they affect everything you do in the Emacs session, in all buffers.

Enabling Minor Modes

Each minor mode is associated with a mode command, whose name consists of the mode name followed by ‘-mode’. For instance, the mode command for ‘Auto Fill’ mode is auto-fill-mode. But unlike a major mode command, which simply enables the mode, the mode command for a minor mode can either enable or disable it:

toggle minor mode

invoking the mode-command with no prefix argument toggles it on or off;

turn minor mode on or off
  • zero or negative prefix argument turns the mode unconditionally off
  • positive prefox argument turns the mode unconditionally on
  • when called from elisp,
    • nil’ or ommitted, mode is unconditinally turned on
    • non-‘nil’ is handled as above for zero, negative, or positive argument

Mode Variable

Most minor modes also have a mode variable, with the same name as the mode command. Its value is non-‘nil’ if the mode is enabled, and ‘nil’ if it is disabled. You should run the mode command instead of altering this variable. setting the mode variable through the Customize interface (see Easy Customization) will always properly enable or disable the mode, since Customize automatically runs the mode command for you.


Next: File Modes, Previous: Major Modes, Up: Modes   [Index]