57.1 Minor Modes
Minor modes are optional features which you can turn on or off. For
example, Auto Fill mode is a minor mode in which <SPC> breaks
lines between words as you type. Minor modes are independent of one
another and of the selected major mode. Most minor modes say in the
mode line when they are enabled; for example, ‘Fill’ in the mode
line means that Auto Fill mode is enabled.
Each minor mode is associated with a command, called the mode
command, which turns it on or off. The name of this command consists
of the name of the minor mode, followed by ‘-mode’; for instance,
the mode command for Auto Fill mode is auto-fill-mode. Calling
the minor mode command with no prefix argument toggles the mode,
turning it on if it was off, and off if it was on. A positive
argument always turns the mode on, and a zero or negative argument
always turns it off. Mode commands are usually invoked with
M-x, but you can bind keys to them if you wish (see Key Bindings).
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. In some minor modes—but
not all—the value of the variable alone determines whether the mode
is active: the mode command works simply by setting the variable, and
changing the value of the variable has the same effect as calling the
mode command. Because not all minor modes work this way, we recommend
that you avoid changing the mode variables directly; use the mode
commands instead.
Some minor modes are buffer-local: they apply only to the
current buffer, so you can enable the mode in certain buffers and not
others. Other minor modes are global: while enabled, they
affect everything you do in the Emacs session, in all buffers. Some
global minor modes are enabled by default.
The following is a list of some buffer-local minor modes:
- Abbrev mode automatically expands text based on pre-defined
abbreviation definitions. See Abbrevs.
- Auto Fill mode inserts newlines as you type to prevent lines from
becoming too long. See Filling.
- Auto Save mode saves the buffer contents periodically to reduce the
amount of work you can lose in case of a crash. See Auto Save.
- Enriched mode enables editing and saving of formatted text.
See Formatted Text.
- Flyspell mode automatically highlights misspelled words.
See Spelling.
- Font-Lock mode automatically highlights certain textual units found in
programs. It is enabled globally by default, but you can disable it
in individual buffers. See Faces.
- Linum mode displays each line's line number in the window's left
margin. Its mode command is
linum-mode.
- Outline minor mode provides similar facilities to the major mode
called Outline mode. See Outline Mode.
- Overwrite mode causes ordinary printing characters to replace existing
text instead of shoving it to the right. For example, if point is in
front of the ‘B’ in ‘FOOBAR’, then in Overwrite mode typing
a G changes it to ‘FOOGAR’, instead of producing
‘FOOGBAR’ as usual. In Overwrite mode, the command C-q
inserts the next character whatever it may be, even if it is a
digit—this gives you a way to insert a character instead of
replacing an existing character. The mode command,
overwrite-mode, is bound to the <Insert> key.
- Binary Overwrite mode is a variant of Overwrite mode for editing
binary files; it treats newlines and tabs like other characters, so
that they overwrite other characters and can be overwritten by them.
In Binary Overwrite mode, digits after C-q specify an octal
character code, as usual.
- Visual Line mode performs “word wrapping”, causing long lines to be
wrapped at word boundaries. See Visual Line Mode.
Here are some useful global minor modes. Since Line Number mode and
Transient Mark mode can be enabled or disabled just by setting the
value of the minor mode variable, you can set them differently
for particular buffers, by explicitly making the corresponding
variable local in those buffers. See Locals.
- Column Number mode enables display of the current column number in the
mode line. See Mode Line.
- Delete Selection mode causes text insertion to first delete the text
in the region, if the region is active. See Using Region.
- Icomplete mode displays an indication of available completions when
you are in the minibuffer and completion is active. See Completion Options.
- Line Number mode enables display of the current line number in the
mode line. It is enabled by default. See Mode Line.
- Menu Bar mode gives each frame a menu bar. It is enabled by default.
See Menu Bars.
- Scroll Bar mode gives each window a scroll bar. It is enabled by
default, but the scroll bar is only displayed on graphical terminals.
See Scroll Bars.
- Tool Bar mode gives each frame a tool bar. It is enabled by default,
but the tool bar is only displayed on graphical terminals. See Tool Bars.
- Transient Mark mode highlights the region, and makes many Emacs
commands operate on the region when the mark is active. It is enabled
by default. See Mark.