aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2008-11-17 16:39:04 +0000
committerChong Yidong2008-11-17 16:39:04 +0000
commitd85f75e285f5e78174c618e705f682b0acf059c0 (patch)
treef2255e9454c81a7382c4046ec1ed87a614334f50
parent696f351d5adaf8dc62f0c6a9c23e8acd33688c74 (diff)
downloademacs-d85f75e285f5e78174c618e705f682b0acf059c0.tar.gz
emacs-d85f75e285f5e78174c618e705f682b0acf059c0.zip
(Minor Modes): Define mode commands and mode variables more precisely.
Recommend using mode commands instead of setting variables directly. Put minor modes in a list, and add more modes.
-rw-r--r--doc/emacs/custom.texi261
1 files changed, 132 insertions, 129 deletions
diff --git a/doc/emacs/custom.texi b/doc/emacs/custom.texi
index a78d66808cd..e01dbd1309b 100644
--- a/doc/emacs/custom.texi
+++ b/doc/emacs/custom.texi
@@ -6,33 +6,24 @@
6@chapter Customization 6@chapter Customization
7@cindex customization 7@cindex customization
8 8
9 This chapter talks about various topics relevant to adapting the 9 This chapter describes some simple methods to customize the behavior
10behavior of Emacs in ways we have anticipated. 10of Emacs.
11
12 Apart from the methods described here, see @ref{X Resources} for
13information about using X resources to customize Emacs, and see
14@ref{Keyboard Macros} for information about recording and replaying
15keyboard macros. Making more far-reaching and open-ended changes
16involves writing Emacs Lisp code; see
11@iftex 17@iftex
12See @cite{The Emacs Lisp Reference Manual} 18@cite{The Emacs Lisp Reference Manual}.
13@end iftex 19@end iftex
14@ifnottex 20@ifnottex
15@xref{Top, Emacs Lisp, Emacs Lisp, elisp, The Emacs Lisp 21@ref{Top, Emacs Lisp, Emacs Lisp, elisp, The Emacs Lisp
16Reference Manual}, 22Reference Manual}.
17@end ifnottex 23@end ifnottex
18for how to make more far-reaching and open-ended changes. @xref{X
19Resources}, for information on using X resources to customize Emacs.
20
21 Customization that you do within Emacs normally affects only the
22particular Emacs session that you do it in---it does not persist
23between sessions unless you save the customization in a file such as
24your init file (@file{.emacs}) that will affect future sessions.
25(@xref{Init File}.) When you tell the customization buffer to save
26customizations for future sessions, this actually works by editing
27@file{.emacs} for you.
28
29 Another means of customization is the keyboard macro, which is a
30sequence of keystrokes to be replayed with a single command.
31@xref{Keyboard Macros}, for full instruction how to record, manage, and
32replay sequences of keys.
33 24
34@menu 25@menu
35* Minor Modes:: Each minor mode is one feature you can turn on 26* Minor Modes:: Each minor mode is a feature you can turn on
36 independently of any others. 27 independently of any others.
37* Easy Customization:: Convenient way to browse and change settings. 28* Easy Customization:: Convenient way to browse and change settings.
38* Variables:: Many Emacs commands examine Emacs variables 29* Variables:: Many Emacs commands examine Emacs variables
@@ -52,136 +43,148 @@ replay sequences of keys.
52@cindex mode, minor 43@cindex mode, minor
53 44
54 Minor modes are optional features which you can turn on or off. For 45 Minor modes are optional features which you can turn on or off. For
55example, Auto Fill mode is a minor mode in which @key{SPC} breaks lines 46example, Auto Fill mode is a minor mode in which @key{SPC} breaks
56between words as you type. All the minor modes are independent of each 47lines between words as you type. Minor modes are independent of one
57other and of the selected major mode. Most minor modes say in the mode 48another and of the selected major mode. Most minor modes say in the
58line when they are enabled; for example, @samp{Fill} in the mode line means 49mode line when they are enabled; for example, @samp{Fill} in the mode
59that Auto Fill mode is enabled. 50line means that Auto Fill mode is enabled.
60 51
61 You should append @code{-mode} to the name of a minor mode to 52 Each minor mode is associated with a command, called the @dfn{mode
62produce the name of the command that turns the mode on or off. Thus, 53command}, which turns it on or off. The name of this command consists
63the command to enable or disable Auto Fill mode is called 54of the name of the minor mode, followed by @samp{-mode}; for instance,
64@code{auto-fill-mode}. These commands are usually invoked with 55the mode command for Auto Fill mode is @code{auto-fill-mode}. Calling
65@kbd{M-x}, but you can bind keys to them if you wish. 56the minor mode command with no prefix argument @dfn{toggles} the mode,
66 57turning it on if it was off, and off if it was on. A positive
67 With no argument, the minor mode function turns the mode on if it 58argument always turns the mode on, and a zero or negative argument
68was off, and off if it was on. This is known as @dfn{toggling}. A 59always turns it off. Mode commands are usually invoked with
69positive argument always turns the mode on, and an explicit zero 60@kbd{M-x}, but you can bind keys to them if you wish (@pxref{Key
70argument or a negative argument always turns it off. 61Bindings}).
71 62
72 Some minor modes are global: while enabled, they affect everything 63 Most minor modes also have a @dfn{mode variable}, with the same name
73you do in the Emacs session, in all buffers. Other minor modes are 64as the mode command. Its value is non-@code{nil} if the mode is
74buffer-local; they apply only to the current buffer, so you can enable 65enabled, and @code{nil} if it is disabled. In some minor modes---but
75the mode in certain buffers and not others. 66not all---the value of the variable alone determines whether the mode
76 67is active: the mode command works simply by setting the variable, and
77 For most minor modes, the command name is also the name of a 68changing the value of the variable has the same effect as calling the
78variable. The variable's value is non-@code{nil} if the mode is 69mode command. Because not all minor modes work this way, we recommend
79enabled and @code{nil} if it is disabled. Some minor-mode commands 70that you avoid changing the mode variables directly; use the mode
80work by just setting the variable. For example, the command 71commands instead.
81@code{abbrev-mode} works by setting the value of @code{abbrev-mode} as 72
82a variable; it is this variable that directly turns Abbrev mode on and 73 Some minor modes are buffer-local; they apply only to the current
83off. You can directly set the variable's value instead of calling the 74buffer, so you can enable the mode in certain buffers and not others.
84mode function. For other minor modes, you need to either set the 75Other minor modes are global: while enabled, they affect everything
85variable through the Customize interface or call the mode function to 76you do in the Emacs session, in all buffers. Some global minor modes
86correctly enable or disable the mode. To check which of these two 77are enabled by default.
87possibilities applies to a given minor mode, use @kbd{C-h v} to ask 78
88for documentation on the variable name. 79 The following is a list of some buffer-local minor modes:
89 80
90 For minor mode commands that work by just setting the minor mode 81@itemize @bullet
91variable, that variable provides a good way for Lisp programs to turn 82@item
92minor modes on and off; it is also useful in a file's local variables 83Abbrev mode automatically expands text based on pre-defined
93list (@pxref{File Variables}). But please think twice before setting 84abbreviation definitions. @xref{Abbrevs}.
94minor modes with a local variables list, because most minor modes are 85
95a matter of user preference---other users editing the same file might 86@item
96not want the same minor modes you prefer. 87Auto Fill mode inserts newlines as you type to prevent lines from
97
98 The most useful buffer-local minor modes include Abbrev mode, Auto
99Fill mode, Auto Save mode, Font-Lock mode, Glasses mode, Outline minor
100mode, Overwrite mode, and Binary Overwrite mode.
101
102 Abbrev mode allows you to define abbreviations that automatically expand
103as you type them. For example, @samp{amd} might expand to @samp{abbrev
104mode}. @xref{Abbrevs}, for full information.
105
106 Auto Fill mode allows you to enter filled text without breaking lines
107explicitly. Emacs inserts newlines as necessary to prevent lines from
108becoming too long. @xref{Filling}. 88becoming too long. @xref{Filling}.
109 89
110 Auto Save mode saves the buffer contents periodically to reduce the 90@item
91Auto Save mode saves the buffer contents periodically to reduce the
111amount of work you can lose in case of a crash. @xref{Auto Save}. 92amount of work you can lose in case of a crash. @xref{Auto Save}.
112 93
113 Enriched mode enables editing and saving of formatted text. 94@item
95Enriched mode enables editing and saving of formatted text.
114@xref{Formatted Text}. 96@xref{Formatted Text}.
115 97
116 Flyspell mode automatically highlights misspelled words. 98@item
99Flyspell mode automatically highlights misspelled words.
117@xref{Spelling}. 100@xref{Spelling}.
118 101
119 Font-Lock mode automatically highlights certain textual units found 102@item
120in programs, such as comments, strings, and function names being 103Font-Lock mode automatically highlights certain textual units found in
121defined. This requires a display that can show multiple fonts or 104programs. It is enabled globally by default, but you can disable it
122colors. @xref{Faces}. 105in individual buffers. @xref{Faces}.
123 106
124@ignore 107@findex linum-mode
125 ISO Accents mode makes the characters @samp{`}, @samp{'}, @samp{"}, 108@cindex Linum mode
126@samp{^}, @samp{/} and @samp{~} combine with the following letter, to 109@item
127produce an accented letter in the ISO Latin-1 character set. The 110Linum mode displays each line's line number in the window's left
128newer and more general feature of input methods more or less 111margin. Its mode command is @code{linum-mode}.
129supersedes ISO Accents mode. @xref{Unibyte Mode}.
130@end ignore
131 112
132 Outline minor mode provides the same facilities as the major mode 113@item
133called Outline mode; but since it is a minor mode instead, you can 114Outline minor mode provides similar facilities to the major mode
134combine it with any major mode. @xref{Outline Mode}. 115called Outline mode. @xref{Outline Mode}.
135 116
136@cindex Overwrite mode 117@cindex Overwrite mode
137@cindex mode, Overwrite 118@cindex mode, Overwrite
138 Overwrite mode causes ordinary printing characters to replace existing
139text instead of shoving it to the right. For example, if point is in
140front of the @samp{B} in @samp{FOOBAR}, then in Overwrite mode typing a
141@kbd{G} changes it to @samp{FOOGAR}, instead of producing @samp{FOOGBAR}
142as usual. In Overwrite mode, the command @kbd{C-q} inserts the next
143character whatever it may be, even if it is a digit---this gives you a
144way to insert a character instead of replacing an existing character.
145
146@findex overwrite-mode 119@findex overwrite-mode
147@kindex INSERT 120@kindex INSERT
148 The command @code{overwrite-mode} is an exception to the rule that 121@item
149commands which toggle minor modes are normally not bound to keys: it is 122Overwrite mode causes ordinary printing characters to replace existing
150bound to the @key{INSERT} function key. This is because many other 123text instead of shoving it to the right. For example, if point is in
151programs bind @key{INSERT} to similar functions. 124front of the @samp{B} in @samp{FOOBAR}, then in Overwrite mode typing
125a @kbd{G} changes it to @samp{FOOGAR}, instead of producing
126@samp{FOOGBAR} as usual. In Overwrite mode, the command @kbd{C-q}
127inserts the next character whatever it may be, even if it is a
128digit---this gives you a way to insert a character instead of
129replacing an existing character. The mode command,
130@code{overwrite-mode}, is bound to the @key{Insert} key.
152 131
153@findex binary-overwrite-mode 132@findex binary-overwrite-mode
154 Binary Overwrite mode is a variant of Overwrite mode for editing 133@item
155binary files; it treats newlines and tabs like other characters, so that 134Binary Overwrite mode is a variant of Overwrite mode for editing
156they overwrite other characters and can be overwritten by them. 135binary files; it treats newlines and tabs like other characters, so
157In Binary Overwrite mode, digits after @kbd{C-q} specify an 136that they overwrite other characters and can be overwritten by them.
158octal character code, as usual. 137In Binary Overwrite mode, digits after @kbd{C-q} specify an octal
159 138character code, as usual.
160 Here are some useful minor modes that normally apply to all buffers 139
161at once. Since Line Number mode and Transient Mark mode can be 140@item
162enabled or disabled just by setting the value of the minor mode 141Visual Line mode performs ``word wrapping'', causing long lines to be
163variable, you @emph{can} set them differently for particular buffers, 142wrapped at word boundaries. @xref{Visual Line Mode}.
164by explicitly making the corresponding variable local in those 143@end itemize
165buffers. @xref{Locals}. 144
166 145 Here are some useful global minor modes. Since Line Number mode and
167 Icomplete mode displays an indication of available completions when 146Transient Mark mode can be enabled or disabled just by setting the
147value of the minor mode variable, you @emph{can} set them differently
148for particular buffers, by explicitly making the corresponding
149variable local in those buffers. @xref{Locals}.
150
151@itemize @bullet
152@item
153Column Number mode enables display of the current column number in the
154mode line. @xref{Mode Line}.
155
156@item
157Delete Selection mode causes text insertion to first delete the text
158in the region, if the region is active. @xref{Using Region}.
159
160@item
161Icomplete mode displays an indication of available completions when
168you are in the minibuffer and completion is active. @xref{Completion 162you are in the minibuffer and completion is active. @xref{Completion
169Options}. 163Options}.
170 164
171 Line Number mode enables continuous display in the mode line of the 165@item
172line number of point, and Column Number mode enables display of the 166Line Number mode enables display of the current line number in the
173column number. @xref{Mode Line}. 167mode line. It is enabled by default. @xref{Mode Line}.
174 168
175 Scroll Bar mode gives each window a scroll bar (@pxref{Scroll Bars}). 169@item
176Menu Bar mode gives each frame a menu bar (@pxref{Menu Bars}). Both of 170Menu Bar mode gives each frame a menu bar. It is enabled by default.
177these modes are enabled by default when you use the X Window System. 171@xref{Menu Bars}.
172
173@item
174Scroll Bar mode gives each window a scroll bar. It is enabled by
175default, but the scroll bar is only displayed on graphical terminals.
176@xref{Scroll Bars}.
178 177
179 In Transient Mark mode, every change in the buffer contents 178@item
180``deactivates'' the mark, so that commands that operate on the region 179Tool Bar mode gives each frame a tool bar. It is enabled by default,
181will get an error. This means you must either set the mark, or 180but the tool bar is only displayed on graphical terminals. @xref{Tool
182explicitly ``reactivate'' it, before each command that uses the region. 181Bars}.
183The advantage of Transient Mark mode is that Emacs can display the 182
184region highlighted. @xref{Mark}. 183@item
184Transient Mark mode highlights the region, and makes many Emacs
185commands operate on the region when the mark is active. It is enabled
186by default. @xref{Mark}.
187@end itemize
185 188
186@node Easy Customization 189@node Easy Customization
187@section Easy Customization Interface 190@section Easy Customization Interface