[ < ] [ > ]   [ << ] [Plus haut] [ >> ]         [Top] [Table des matières] [Index] [ ? ]

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. All the minor modes are independent of each other 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.

You should append -mode to the name of a minor mode to produce the name of the command that turns the mode on or off. Thus, the command to enable or disable Auto Fill mode is called auto-fill-mode. These commands are usually invoked with M-x, but you can bind keys to them if you wish.

With no argument, the minor mode function turns the mode on if it was off, and off if it was on. This is known as toggling. A positive argument always turns the mode on, and an explicit zero argument or a negative argument always turns it off.

Some minor modes are global: while enabled, they affect everything you do in the Emacs session, in all buffers. Other minor modes are buffer-local; they apply only to the current buffer, so you can enable the mode in certain buffers and not others.

For most minor modes, the command name is also the name of a variable. The variable's value is non-nil if the mode is enabled and nil if it is disabled. Some minor-mode commands work by just setting the variable. For example, the command abbrev-mode works by setting the value of abbrev-mode as a variable; it is this variable that directly turns Abbrev mode on and off. You can directly set the variable's value instead of calling the mode function. For other minor modes, you need to either set the variable through the Customize interface or call the mode function to correctly enable or disable the mode. To check which of these two possibilities applies to a given minor mode, use C-h v to ask for documentation on the variable name.

For minor mode commands that work by just setting the minor mode variable, that variable provides a good way for Lisp programs to turn minor modes on and off; it is also useful in a file's local variables list (voir la section Local Variables in Files). But please think twice before setting minor modes with a local variables list, because most minor modes are a matter of user preference—other users editing the same file might not want the same minor modes you prefer.

The most useful buffer-local minor modes include Abbrev mode, Auto Fill mode, Auto Save mode, Font-Lock mode, Glasses mode, Outline minor mode, Overwrite mode, and Binary Overwrite mode.

Abbrev mode allows you to define abbreviations that automatically expand as you type them. For example, ‘amd’ might expand to ‘abbrev mode’. Voir la section Abbrevs, for full information.

Auto Fill mode allows you to enter filled text without breaking lines explicitly. Emacs inserts newlines as necessary to prevent lines from becoming too long. Voir la section Filling Text.

Auto Save mode saves the buffer contents periodically to reduce the amount of work you can lose in case of a crash. Voir la section Auto-Saving: Protection Against Disasters.

Enriched mode enables editing and saving of formatted text. Voir la section Editing Formatted Text.

Flyspell mode automatically highlights misspelled words. Voir la section Checking and Correcting Spelling.

Font-Lock mode automatically highlights certain textual units found in programs, such as comments, strings, and function names being defined. This requires a display that can show multiple fonts or colors. Voir la section Using Multiple Typefaces.

Outline minor mode provides the same facilities as the major mode called Outline mode; but since it is a minor mode instead, you can combine it with any major mode. Voir la section 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 command overwrite-mode is an exception to the rule that commands which toggle minor modes are normally not bound to keys: it is bound to the <INSERT> function key. This is because many other programs bind <INSERT> to similar functions.

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.

Here are some useful minor modes that normally apply to all buffers at once. 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. Voir la section Local Variables.

Icomplete mode displays an indication of available completions when you are in the minibuffer and completion is active. Voir la section Completion Options.

Line Number mode enables continuous display in the mode line of the line number of point, and Column Number mode enables display of the column number. Voir la section The Mode Line.

Scroll Bar mode gives each window a scroll bar (voir la section Scroll Bars). Menu Bar mode gives each frame a menu bar (voir la section Menu Bars). Both of these modes are enabled by default when you use the X Window System.

In Transient Mark mode, every change in the buffer contents “deactivates” the mark, so that commands that operate on the region will get an error. This means you must either set the mark, or explicitly “reactivate” it, before each command that uses the region. The advantage of Transient Mark mode is that Emacs can display the region highlighted. @xref{Mark}.


[ < ] [ > ]   [ << ] [Plus haut] [ >> ]         [Top] [Table des matières] [Index] [ ? ]

Ce document a été généré par Eric Reinbold le 23 Février 2009 en utilisant texi2html 1.78.