ErgoEmacsEmacsLispBlogEmacsLispBuy Tutorial
19dfoa3Q7oehm9MwCULQzBG8vqfCaeMazH
Web Hosting by 1&1

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:

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.

blog comments powered by Disqus