annotate man/abbrevs.texi @ 31020:2f1815d3e9ae

Mark inhibit-iso-escape-detection as updated in the manual.
author Eli Zaretskii <eliz@gnu.org>
date Tue, 22 Aug 2000 08:03:22 +0000
parents 4f58e2bbcb08
children 8cbeffd70393
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1 @c This is part of the Emacs manual.
Dave Love <fx@gnu.org>
parents:
diff changeset
2 @c Copyright (C) 1985, 86, 87, 93, 94, 95, 1997 Free Software Foundation, Inc.
Dave Love <fx@gnu.org>
parents:
diff changeset
3 @c See file emacs.texi for copying conditions.
Dave Love <fx@gnu.org>
parents:
diff changeset
4 @node Abbrevs, Picture, Building, Top
Dave Love <fx@gnu.org>
parents:
diff changeset
5 @chapter Abbrevs
Dave Love <fx@gnu.org>
parents:
diff changeset
6 @cindex abbrevs
Dave Love <fx@gnu.org>
parents:
diff changeset
7 @cindex expansion (of abbrevs)
Dave Love <fx@gnu.org>
parents:
diff changeset
8
Dave Love <fx@gnu.org>
parents:
diff changeset
9 A defined @dfn{abbrev} is a word which @dfn{expands}, if you insert
Dave Love <fx@gnu.org>
parents:
diff changeset
10 it, into some different text. Abbrevs are defined by the user to expand
Dave Love <fx@gnu.org>
parents:
diff changeset
11 in specific ways. For example, you might define @samp{foo} as an abbrev
Dave Love <fx@gnu.org>
parents:
diff changeset
12 expanding to @samp{find outer otter}. Then you would be able to insert
Dave Love <fx@gnu.org>
parents:
diff changeset
13 @samp{find outer otter } into the buffer by typing @kbd{f o o
Dave Love <fx@gnu.org>
parents:
diff changeset
14 @key{SPC}}.
Dave Love <fx@gnu.org>
parents:
diff changeset
15
Dave Love <fx@gnu.org>
parents:
diff changeset
16 A second kind of abbreviation facility is called @dfn{dynamic abbrev
Dave Love <fx@gnu.org>
parents:
diff changeset
17 expansion}. You use dynamic abbrev expansion with an explicit command
Dave Love <fx@gnu.org>
parents:
diff changeset
18 to expand the letters in the buffer before point by looking for other
Dave Love <fx@gnu.org>
parents:
diff changeset
19 words in the buffer that start with those letters. @xref{Dynamic
Dave Love <fx@gnu.org>
parents:
diff changeset
20 Abbrevs}.
Dave Love <fx@gnu.org>
parents:
diff changeset
21
30870
4f58e2bbcb08 *** empty log message ***
Dave Love <fx@gnu.org>
parents: 27208
diff changeset
22 `Hippie' expansion generalizes abbreviation expansion.
27208
85ee0699746e Mention Hippie Expand.
Dave Love <fx@gnu.org>
parents: 25829
diff changeset
23 @xref{Hippie Expand, `Hippie' Expansion, autotype, Features for
85ee0699746e Mention Hippie Expand.
Dave Love <fx@gnu.org>
parents: 25829
diff changeset
24 Automatic Typing}.
85ee0699746e Mention Hippie Expand.
Dave Love <fx@gnu.org>
parents: 25829
diff changeset
25
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
26 @menu
Dave Love <fx@gnu.org>
parents:
diff changeset
27 * Abbrev Concepts:: Fundamentals of defined abbrevs.
Dave Love <fx@gnu.org>
parents:
diff changeset
28 * Defining Abbrevs:: Defining an abbrev, so it will expand when typed.
Dave Love <fx@gnu.org>
parents:
diff changeset
29 * Expanding Abbrevs:: Controlling expansion: prefixes, canceling expansion.
Dave Love <fx@gnu.org>
parents:
diff changeset
30 * Editing Abbrevs:: Viewing or editing the entire list of defined abbrevs.
Dave Love <fx@gnu.org>
parents:
diff changeset
31 * Saving Abbrevs:: Saving the entire list of abbrevs for another session.
Dave Love <fx@gnu.org>
parents:
diff changeset
32 * Dynamic Abbrevs:: Abbreviations for words already in the buffer.
Dave Love <fx@gnu.org>
parents:
diff changeset
33 * Dabbrev Customization:: What is a word, for dynamic abbrevs. Case handling.
Dave Love <fx@gnu.org>
parents:
diff changeset
34 @end menu
Dave Love <fx@gnu.org>
parents:
diff changeset
35
Dave Love <fx@gnu.org>
parents:
diff changeset
36 @node Abbrev Concepts
Dave Love <fx@gnu.org>
parents:
diff changeset
37 @section Abbrev Concepts
Dave Love <fx@gnu.org>
parents:
diff changeset
38
Dave Love <fx@gnu.org>
parents:
diff changeset
39 An @dfn{abbrev} is a word which has been defined to @dfn{expand} into
Dave Love <fx@gnu.org>
parents:
diff changeset
40 a specified @dfn{expansion}. When you insert a word-separator character
Dave Love <fx@gnu.org>
parents:
diff changeset
41 following the abbrev, that expands the abbrev---replacing the abbrev
Dave Love <fx@gnu.org>
parents:
diff changeset
42 with its expansion. For example, if @samp{foo} is defined as an abbrev
Dave Love <fx@gnu.org>
parents:
diff changeset
43 expanding to @samp{find outer otter}, then you can insert @samp{find
Dave Love <fx@gnu.org>
parents:
diff changeset
44 outer otter.} into the buffer by typing @kbd{f o o .}.
Dave Love <fx@gnu.org>
parents:
diff changeset
45
Dave Love <fx@gnu.org>
parents:
diff changeset
46 @findex abbrev-mode
Dave Love <fx@gnu.org>
parents:
diff changeset
47 @vindex abbrev-mode
Dave Love <fx@gnu.org>
parents:
diff changeset
48 @cindex Abbrev mode
Dave Love <fx@gnu.org>
parents:
diff changeset
49 @cindex mode, Abbrev
Dave Love <fx@gnu.org>
parents:
diff changeset
50 Abbrevs expand only when Abbrev mode (a minor mode) is enabled.
Dave Love <fx@gnu.org>
parents:
diff changeset
51 Disabling Abbrev mode does not cause abbrev definitions to be forgotten,
Dave Love <fx@gnu.org>
parents:
diff changeset
52 but they do not expand until Abbrev mode is enabled again. The command
Dave Love <fx@gnu.org>
parents:
diff changeset
53 @kbd{M-x abbrev-mode} toggles Abbrev mode; with a numeric argument, it
Dave Love <fx@gnu.org>
parents:
diff changeset
54 turns Abbrev mode on if the argument is positive, off otherwise.
Dave Love <fx@gnu.org>
parents:
diff changeset
55 @xref{Minor Modes}. @code{abbrev-mode} is also a variable; Abbrev mode is
Dave Love <fx@gnu.org>
parents:
diff changeset
56 on when the variable is non-@code{nil}. The variable @code{abbrev-mode}
Dave Love <fx@gnu.org>
parents:
diff changeset
57 automatically becomes local to the current buffer when it is set.
Dave Love <fx@gnu.org>
parents:
diff changeset
58
Dave Love <fx@gnu.org>
parents:
diff changeset
59 Abbrev definitions can be @dfn{mode-specific}---active only in one major
Dave Love <fx@gnu.org>
parents:
diff changeset
60 mode. Abbrevs can also have @dfn{global} definitions that are active in
Dave Love <fx@gnu.org>
parents:
diff changeset
61 all major modes. The same abbrev can have a global definition and various
Dave Love <fx@gnu.org>
parents:
diff changeset
62 mode-specific definitions for different major modes. A mode-specific
Dave Love <fx@gnu.org>
parents:
diff changeset
63 definition for the current major mode overrides a global definition.
Dave Love <fx@gnu.org>
parents:
diff changeset
64
Dave Love <fx@gnu.org>
parents:
diff changeset
65 Abbrevs can be defined interactively during the editing session. Lists
Dave Love <fx@gnu.org>
parents:
diff changeset
66 of abbrev definitions can also be saved in files and reloaded in later
Dave Love <fx@gnu.org>
parents:
diff changeset
67 sessions. Some users keep extensive lists of abbrevs that they load in
Dave Love <fx@gnu.org>
parents:
diff changeset
68 every session.
Dave Love <fx@gnu.org>
parents:
diff changeset
69
Dave Love <fx@gnu.org>
parents:
diff changeset
70 @node Defining Abbrevs
Dave Love <fx@gnu.org>
parents:
diff changeset
71 @section Defining Abbrevs
Dave Love <fx@gnu.org>
parents:
diff changeset
72
Dave Love <fx@gnu.org>
parents:
diff changeset
73 @table @kbd
Dave Love <fx@gnu.org>
parents:
diff changeset
74 @item C-x a g
Dave Love <fx@gnu.org>
parents:
diff changeset
75 Define an abbrev, using one or more words before point as its expansion
Dave Love <fx@gnu.org>
parents:
diff changeset
76 (@code{add-global-abbrev}).
Dave Love <fx@gnu.org>
parents:
diff changeset
77 @item C-x a l
Dave Love <fx@gnu.org>
parents:
diff changeset
78 Similar, but define an abbrev specific to the current major mode
Dave Love <fx@gnu.org>
parents:
diff changeset
79 (@code{add-mode-abbrev}).
Dave Love <fx@gnu.org>
parents:
diff changeset
80 @item C-x a i g
Dave Love <fx@gnu.org>
parents:
diff changeset
81 Define a word in the buffer as an abbrev (@code{inverse-add-global-abbrev}).
Dave Love <fx@gnu.org>
parents:
diff changeset
82 @item C-x a i l
Dave Love <fx@gnu.org>
parents:
diff changeset
83 Define a word in the buffer as a mode-specific abbrev
Dave Love <fx@gnu.org>
parents:
diff changeset
84 (@code{inverse-add-mode-abbrev}).
Dave Love <fx@gnu.org>
parents:
diff changeset
85 @item M-x kill-all-abbrevs
Dave Love <fx@gnu.org>
parents:
diff changeset
86 This command discards all abbrev definitions currently in effect,
Dave Love <fx@gnu.org>
parents:
diff changeset
87 leaving a blank slate.
Dave Love <fx@gnu.org>
parents:
diff changeset
88 @end table
Dave Love <fx@gnu.org>
parents:
diff changeset
89
Dave Love <fx@gnu.org>
parents:
diff changeset
90 @kindex C-x a g
Dave Love <fx@gnu.org>
parents:
diff changeset
91 @findex add-global-abbrev
Dave Love <fx@gnu.org>
parents:
diff changeset
92 The usual way to define an abbrev is to enter the text you want the
Dave Love <fx@gnu.org>
parents:
diff changeset
93 abbrev to expand to, position point after it, and type @kbd{C-x a g}
Dave Love <fx@gnu.org>
parents:
diff changeset
94 (@code{add-global-abbrev}). This reads the abbrev itself using the
Dave Love <fx@gnu.org>
parents:
diff changeset
95 minibuffer, and then defines it as an abbrev for one or more words before
Dave Love <fx@gnu.org>
parents:
diff changeset
96 point. Use a numeric argument to say how many words before point should be
Dave Love <fx@gnu.org>
parents:
diff changeset
97 taken as the expansion. For example, to define the abbrev @samp{foo} as
Dave Love <fx@gnu.org>
parents:
diff changeset
98 mentioned above, insert the text @samp{find outer otter} and then type
Dave Love <fx@gnu.org>
parents:
diff changeset
99 @kbd{C-u 3 C-x a g f o o @key{RET}}.
Dave Love <fx@gnu.org>
parents:
diff changeset
100
Dave Love <fx@gnu.org>
parents:
diff changeset
101 An argument of zero to @kbd{C-x a g} means to use the contents of the
Dave Love <fx@gnu.org>
parents:
diff changeset
102 region as the expansion of the abbrev being defined.
Dave Love <fx@gnu.org>
parents:
diff changeset
103
Dave Love <fx@gnu.org>
parents:
diff changeset
104 @kindex C-x a l
Dave Love <fx@gnu.org>
parents:
diff changeset
105 @findex add-mode-abbrev
Dave Love <fx@gnu.org>
parents:
diff changeset
106 The command @kbd{C-x a l} (@code{add-mode-abbrev}) is similar, but
Dave Love <fx@gnu.org>
parents:
diff changeset
107 defines a mode-specific abbrev. Mode-specific abbrevs are active only in a
Dave Love <fx@gnu.org>
parents:
diff changeset
108 particular major mode. @kbd{C-x a l} defines an abbrev for the major mode
Dave Love <fx@gnu.org>
parents:
diff changeset
109 in effect at the time @kbd{C-x a l} is typed. The arguments work the same
Dave Love <fx@gnu.org>
parents:
diff changeset
110 as for @kbd{C-x a g}.
Dave Love <fx@gnu.org>
parents:
diff changeset
111
Dave Love <fx@gnu.org>
parents:
diff changeset
112 @kindex C-x a i g
Dave Love <fx@gnu.org>
parents:
diff changeset
113 @findex inverse-add-global-abbrev
Dave Love <fx@gnu.org>
parents:
diff changeset
114 @kindex C-x a i l
Dave Love <fx@gnu.org>
parents:
diff changeset
115 @findex inverse-add-mode-abbrev
Dave Love <fx@gnu.org>
parents:
diff changeset
116 If the text already in the buffer is the abbrev, rather than its
Dave Love <fx@gnu.org>
parents:
diff changeset
117 expansion, use command @kbd{C-x a i g}
Dave Love <fx@gnu.org>
parents:
diff changeset
118 (@code{inverse-add-global-abbrev}) instead of @kbd{C-x a g}, or use
Dave Love <fx@gnu.org>
parents:
diff changeset
119 @kbd{C-x a i l} (@code{inverse-add-mode-abbrev}) instead of @kbd{C-x a
Dave Love <fx@gnu.org>
parents:
diff changeset
120 l}. These commands are called ``inverse'' because they invert the
Dave Love <fx@gnu.org>
parents:
diff changeset
121 meaning of the two text strings they use (one from the buffer and one
Dave Love <fx@gnu.org>
parents:
diff changeset
122 read with the minibuffer).
Dave Love <fx@gnu.org>
parents:
diff changeset
123
Dave Love <fx@gnu.org>
parents:
diff changeset
124 To change the definition of an abbrev, just define a new definition.
Dave Love <fx@gnu.org>
parents:
diff changeset
125 When the abbrev has a prior definition, the abbrev definition commands
Dave Love <fx@gnu.org>
parents:
diff changeset
126 ask for confirmation for replacing it.
Dave Love <fx@gnu.org>
parents:
diff changeset
127
Dave Love <fx@gnu.org>
parents:
diff changeset
128 To remove an abbrev definition, give a negative argument to the abbrev
Dave Love <fx@gnu.org>
parents:
diff changeset
129 definition command: @kbd{C-u - C-x a g} or @kbd{C-u - C-x a l}. The
Dave Love <fx@gnu.org>
parents:
diff changeset
130 former removes a global definition, while the latter removes a
Dave Love <fx@gnu.org>
parents:
diff changeset
131 mode-specific definition.
Dave Love <fx@gnu.org>
parents:
diff changeset
132
Dave Love <fx@gnu.org>
parents:
diff changeset
133 @findex kill-all-abbrevs
Dave Love <fx@gnu.org>
parents:
diff changeset
134 @kbd{M-x kill-all-abbrevs} removes all the abbrev definitions there
Dave Love <fx@gnu.org>
parents:
diff changeset
135 are, both global and local.
Dave Love <fx@gnu.org>
parents:
diff changeset
136
Dave Love <fx@gnu.org>
parents:
diff changeset
137 @node Expanding Abbrevs
Dave Love <fx@gnu.org>
parents:
diff changeset
138 @section Controlling Abbrev Expansion
Dave Love <fx@gnu.org>
parents:
diff changeset
139
Dave Love <fx@gnu.org>
parents:
diff changeset
140 An abbrev expands whenever it is present in the buffer just before
Dave Love <fx@gnu.org>
parents:
diff changeset
141 point and you type a self-inserting whitespace or punctuation character
Dave Love <fx@gnu.org>
parents:
diff changeset
142 (@key{SPC}, comma, etc.@:). More precisely, any character that is not a
Dave Love <fx@gnu.org>
parents:
diff changeset
143 word constituent expands an abbrev, and any word-constituent character
Dave Love <fx@gnu.org>
parents:
diff changeset
144 can be part of an abbrev. The most common way to use an abbrev is to
Dave Love <fx@gnu.org>
parents:
diff changeset
145 insert it and then insert a punctuation character to expand it.
Dave Love <fx@gnu.org>
parents:
diff changeset
146
Dave Love <fx@gnu.org>
parents:
diff changeset
147 @vindex abbrev-all-caps
Dave Love <fx@gnu.org>
parents:
diff changeset
148 Abbrev expansion preserves case; thus, @samp{foo} expands into @samp{find
Dave Love <fx@gnu.org>
parents:
diff changeset
149 outer otter}; @samp{Foo} into @samp{Find outer otter}, and @samp{FOO} into
Dave Love <fx@gnu.org>
parents:
diff changeset
150 @samp{FIND OUTER OTTER} or @samp{Find Outer Otter} according to the
Dave Love <fx@gnu.org>
parents:
diff changeset
151 variable @code{abbrev-all-caps} (a non-@code{nil} value chooses the first
Dave Love <fx@gnu.org>
parents:
diff changeset
152 of the two expansions).
Dave Love <fx@gnu.org>
parents:
diff changeset
153
Dave Love <fx@gnu.org>
parents:
diff changeset
154 These commands are used to control abbrev expansion:
Dave Love <fx@gnu.org>
parents:
diff changeset
155
Dave Love <fx@gnu.org>
parents:
diff changeset
156 @table @kbd
Dave Love <fx@gnu.org>
parents:
diff changeset
157 @item M-'
Dave Love <fx@gnu.org>
parents:
diff changeset
158 Separate a prefix from a following abbrev to be expanded
Dave Love <fx@gnu.org>
parents:
diff changeset
159 (@code{abbrev-prefix-mark}).
Dave Love <fx@gnu.org>
parents:
diff changeset
160 @item C-x a e
Dave Love <fx@gnu.org>
parents:
diff changeset
161 @findex expand-abbrev
Dave Love <fx@gnu.org>
parents:
diff changeset
162 Expand the abbrev before point (@code{expand-abbrev}).
Dave Love <fx@gnu.org>
parents:
diff changeset
163 This is effective even when Abbrev mode is not enabled.
Dave Love <fx@gnu.org>
parents:
diff changeset
164 @item M-x expand-region-abbrevs
Dave Love <fx@gnu.org>
parents:
diff changeset
165 Expand some or all abbrevs found in the region.
Dave Love <fx@gnu.org>
parents:
diff changeset
166 @end table
Dave Love <fx@gnu.org>
parents:
diff changeset
167
Dave Love <fx@gnu.org>
parents:
diff changeset
168 @kindex M-'
Dave Love <fx@gnu.org>
parents:
diff changeset
169 @findex abbrev-prefix-mark
Dave Love <fx@gnu.org>
parents:
diff changeset
170 You may wish to expand an abbrev with a prefix attached; for example,
Dave Love <fx@gnu.org>
parents:
diff changeset
171 if @samp{cnst} expands into @samp{construction}, you might want to use
Dave Love <fx@gnu.org>
parents:
diff changeset
172 it to enter @samp{reconstruction}. It does not work to type
Dave Love <fx@gnu.org>
parents:
diff changeset
173 @kbd{recnst}, because that is not necessarily a defined abbrev. What
Dave Love <fx@gnu.org>
parents:
diff changeset
174 you can do is use the command @kbd{M-'} (@code{abbrev-prefix-mark}) in
Dave Love <fx@gnu.org>
parents:
diff changeset
175 between the prefix @samp{re} and the abbrev @samp{cnst}. First, insert
Dave Love <fx@gnu.org>
parents:
diff changeset
176 @samp{re}. Then type @kbd{M-'}; this inserts a hyphen in the buffer to
Dave Love <fx@gnu.org>
parents:
diff changeset
177 indicate that it has done its work. Then insert the abbrev @samp{cnst};
Dave Love <fx@gnu.org>
parents:
diff changeset
178 the buffer now contains @samp{re-cnst}. Now insert a non-word character
Dave Love <fx@gnu.org>
parents:
diff changeset
179 to expand the abbrev @samp{cnst} into @samp{construction}. This
Dave Love <fx@gnu.org>
parents:
diff changeset
180 expansion step also deletes the hyphen that indicated @kbd{M-'} had been
Dave Love <fx@gnu.org>
parents:
diff changeset
181 used. The result is the desired @samp{reconstruction}.
Dave Love <fx@gnu.org>
parents:
diff changeset
182
Dave Love <fx@gnu.org>
parents:
diff changeset
183 If you actually want the text of the abbrev in the buffer, rather than
Dave Love <fx@gnu.org>
parents:
diff changeset
184 its expansion, you can accomplish this by inserting the following
Dave Love <fx@gnu.org>
parents:
diff changeset
185 punctuation with @kbd{C-q}. Thus, @kbd{foo C-q ,} leaves @samp{foo,} in
Dave Love <fx@gnu.org>
parents:
diff changeset
186 the buffer.
Dave Love <fx@gnu.org>
parents:
diff changeset
187
Dave Love <fx@gnu.org>
parents:
diff changeset
188 @findex unexpand-abbrev
Dave Love <fx@gnu.org>
parents:
diff changeset
189 If you expand an abbrev by mistake, you can undo the expansion and
Dave Love <fx@gnu.org>
parents:
diff changeset
190 bring back the abbrev itself by typing @kbd{C-_} to undo (@pxref{Undo}).
Dave Love <fx@gnu.org>
parents:
diff changeset
191 This also undoes the insertion of the non-word character that expanded
Dave Love <fx@gnu.org>
parents:
diff changeset
192 the abbrev. If the result you want is the terminating non-word
Dave Love <fx@gnu.org>
parents:
diff changeset
193 character plus the unexpanded abbrev, you must reinsert the terminating
Dave Love <fx@gnu.org>
parents:
diff changeset
194 character, quoting it with @kbd{C-q}. You can also use the command
Dave Love <fx@gnu.org>
parents:
diff changeset
195 @kbd{M-x unexpand-abbrev} to cancel the last expansion without
Dave Love <fx@gnu.org>
parents:
diff changeset
196 deleting the terminating character.
Dave Love <fx@gnu.org>
parents:
diff changeset
197
Dave Love <fx@gnu.org>
parents:
diff changeset
198 @findex expand-region-abbrevs
Dave Love <fx@gnu.org>
parents:
diff changeset
199 @kbd{M-x expand-region-abbrevs} searches through the region for defined
Dave Love <fx@gnu.org>
parents:
diff changeset
200 abbrevs, and for each one found offers to replace it with its expansion.
Dave Love <fx@gnu.org>
parents:
diff changeset
201 This command is useful if you have typed in text using abbrevs but forgot
Dave Love <fx@gnu.org>
parents:
diff changeset
202 to turn on Abbrev mode first. It may also be useful together with a
Dave Love <fx@gnu.org>
parents:
diff changeset
203 special set of abbrev definitions for making several global replacements at
Dave Love <fx@gnu.org>
parents:
diff changeset
204 once. This command is effective even if Abbrev mode is not enabled.
Dave Love <fx@gnu.org>
parents:
diff changeset
205
Dave Love <fx@gnu.org>
parents:
diff changeset
206 Expanding an abbrev runs the hook @code{pre-abbrev-expand-hook}
Dave Love <fx@gnu.org>
parents:
diff changeset
207 (@pxref{Hooks}).
Dave Love <fx@gnu.org>
parents:
diff changeset
208
Dave Love <fx@gnu.org>
parents:
diff changeset
209 @need 1500
Dave Love <fx@gnu.org>
parents:
diff changeset
210 @node Editing Abbrevs
Dave Love <fx@gnu.org>
parents:
diff changeset
211 @section Examining and Editing Abbrevs
Dave Love <fx@gnu.org>
parents:
diff changeset
212
Dave Love <fx@gnu.org>
parents:
diff changeset
213 @table @kbd
Dave Love <fx@gnu.org>
parents:
diff changeset
214 @item M-x list-abbrevs
Dave Love <fx@gnu.org>
parents:
diff changeset
215 Display a list of all abbrev definitions.
Dave Love <fx@gnu.org>
parents:
diff changeset
216 @item M-x edit-abbrevs
Dave Love <fx@gnu.org>
parents:
diff changeset
217 Edit a list of abbrevs; you can add, alter or remove definitions.
Dave Love <fx@gnu.org>
parents:
diff changeset
218 @end table
Dave Love <fx@gnu.org>
parents:
diff changeset
219
Dave Love <fx@gnu.org>
parents:
diff changeset
220 @findex list-abbrevs
Dave Love <fx@gnu.org>
parents:
diff changeset
221 The output from @kbd{M-x list-abbrevs} looks like this:
Dave Love <fx@gnu.org>
parents:
diff changeset
222
Dave Love <fx@gnu.org>
parents:
diff changeset
223 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
224 (lisp-mode-abbrev-table)
Dave Love <fx@gnu.org>
parents:
diff changeset
225 "dk" 0 "define-key"
Dave Love <fx@gnu.org>
parents:
diff changeset
226 (global-abbrev-table)
Dave Love <fx@gnu.org>
parents:
diff changeset
227 "dfn" 0 "definition"
Dave Love <fx@gnu.org>
parents:
diff changeset
228 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
229
Dave Love <fx@gnu.org>
parents:
diff changeset
230 @noindent
Dave Love <fx@gnu.org>
parents:
diff changeset
231 (Some blank lines of no semantic significance, and some other abbrev
Dave Love <fx@gnu.org>
parents:
diff changeset
232 tables, have been omitted.)
Dave Love <fx@gnu.org>
parents:
diff changeset
233
Dave Love <fx@gnu.org>
parents:
diff changeset
234 A line containing a name in parentheses is the header for abbrevs in a
Dave Love <fx@gnu.org>
parents:
diff changeset
235 particular abbrev table; @code{global-abbrev-table} contains all the global
Dave Love <fx@gnu.org>
parents:
diff changeset
236 abbrevs, and the other abbrev tables that are named after major modes
Dave Love <fx@gnu.org>
parents:
diff changeset
237 contain the mode-specific abbrevs.
Dave Love <fx@gnu.org>
parents:
diff changeset
238
Dave Love <fx@gnu.org>
parents:
diff changeset
239 Within each abbrev table, each nonblank line defines one abbrev. The
Dave Love <fx@gnu.org>
parents:
diff changeset
240 word at the beginning of the line is the abbrev. The number that
Dave Love <fx@gnu.org>
parents:
diff changeset
241 follows is the number of times the abbrev has been expanded. Emacs
Dave Love <fx@gnu.org>
parents:
diff changeset
242 keeps track of this to help you see which abbrevs you actually use, so
Dave Love <fx@gnu.org>
parents:
diff changeset
243 that you can eliminate those that you don't use often. The string at
Dave Love <fx@gnu.org>
parents:
diff changeset
244 the end of the line is the expansion.
Dave Love <fx@gnu.org>
parents:
diff changeset
245
Dave Love <fx@gnu.org>
parents:
diff changeset
246 @findex edit-abbrevs
Dave Love <fx@gnu.org>
parents:
diff changeset
247 @kindex C-c C-c @r{(Edit Abbrevs)}
Dave Love <fx@gnu.org>
parents:
diff changeset
248 @kbd{M-x edit-abbrevs} allows you to add, change or kill abbrev
Dave Love <fx@gnu.org>
parents:
diff changeset
249 definitions by editing a list of them in an Emacs buffer. The list has
Dave Love <fx@gnu.org>
parents:
diff changeset
250 the same format described above. The buffer of abbrevs is called
Dave Love <fx@gnu.org>
parents:
diff changeset
251 @samp{*Abbrevs*}, and is in Edit-Abbrevs mode. Type @kbd{C-c C-c} in
Dave Love <fx@gnu.org>
parents:
diff changeset
252 this buffer to install the abbrev definitions as specified in the
Dave Love <fx@gnu.org>
parents:
diff changeset
253 buffer---and delete any abbrev definitions not listed.
Dave Love <fx@gnu.org>
parents:
diff changeset
254
Dave Love <fx@gnu.org>
parents:
diff changeset
255 The command @code{edit-abbrevs} is actually the same as
Dave Love <fx@gnu.org>
parents:
diff changeset
256 @code{list-abbrevs} except that it selects the buffer @samp{*Abbrevs*}
Dave Love <fx@gnu.org>
parents:
diff changeset
257 whereas @code{list-abbrevs} merely displays it in another window.
Dave Love <fx@gnu.org>
parents:
diff changeset
258
Dave Love <fx@gnu.org>
parents:
diff changeset
259 @node Saving Abbrevs
Dave Love <fx@gnu.org>
parents:
diff changeset
260 @section Saving Abbrevs
Dave Love <fx@gnu.org>
parents:
diff changeset
261
Dave Love <fx@gnu.org>
parents:
diff changeset
262 These commands allow you to keep abbrev definitions between editing
Dave Love <fx@gnu.org>
parents:
diff changeset
263 sessions.
Dave Love <fx@gnu.org>
parents:
diff changeset
264
Dave Love <fx@gnu.org>
parents:
diff changeset
265 @table @kbd
Dave Love <fx@gnu.org>
parents:
diff changeset
266 @item M-x write-abbrev-file @key{RET} @var{file} @key{RET}
Dave Love <fx@gnu.org>
parents:
diff changeset
267 Write a file @var{file} describing all defined abbrevs.
Dave Love <fx@gnu.org>
parents:
diff changeset
268 @item M-x read-abbrev-file @key{RET} @var{file} @key{RET}
Dave Love <fx@gnu.org>
parents:
diff changeset
269 Read the file @var{file} and define abbrevs as specified therein.
Dave Love <fx@gnu.org>
parents:
diff changeset
270 @item M-x quietly-read-abbrev-file @key{RET} @var{file} @key{RET}
Dave Love <fx@gnu.org>
parents:
diff changeset
271 Similar but do not display a message about what is going on.
Dave Love <fx@gnu.org>
parents:
diff changeset
272 @item M-x define-abbrevs
Dave Love <fx@gnu.org>
parents:
diff changeset
273 Define abbrevs from definitions in current buffer.
Dave Love <fx@gnu.org>
parents:
diff changeset
274 @item M-x insert-abbrevs
Dave Love <fx@gnu.org>
parents:
diff changeset
275 Insert all abbrevs and their expansions into current buffer.
Dave Love <fx@gnu.org>
parents:
diff changeset
276 @end table
Dave Love <fx@gnu.org>
parents:
diff changeset
277
Dave Love <fx@gnu.org>
parents:
diff changeset
278 @findex write-abbrev-file
Dave Love <fx@gnu.org>
parents:
diff changeset
279 @kbd{M-x write-abbrev-file} reads a file name using the minibuffer and
Dave Love <fx@gnu.org>
parents:
diff changeset
280 then writes a description of all current abbrev definitions into that
Dave Love <fx@gnu.org>
parents:
diff changeset
281 file. This is used to save abbrev definitions for use in a later
Dave Love <fx@gnu.org>
parents:
diff changeset
282 session. The text stored in the file is a series of Lisp expressions
Dave Love <fx@gnu.org>
parents:
diff changeset
283 that, when executed, define the same abbrevs that you currently have.
Dave Love <fx@gnu.org>
parents:
diff changeset
284
Dave Love <fx@gnu.org>
parents:
diff changeset
285 @findex read-abbrev-file
Dave Love <fx@gnu.org>
parents:
diff changeset
286 @findex quietly-read-abbrev-file
Dave Love <fx@gnu.org>
parents:
diff changeset
287 @vindex abbrev-file-name
Dave Love <fx@gnu.org>
parents:
diff changeset
288 @kbd{M-x read-abbrev-file} reads a file name using the minibuffer and
Dave Love <fx@gnu.org>
parents:
diff changeset
289 then reads the file, defining abbrevs according to the contents of the
Dave Love <fx@gnu.org>
parents:
diff changeset
290 file. @kbd{M-x quietly-read-abbrev-file} is the same except that it
Dave Love <fx@gnu.org>
parents:
diff changeset
291 does not display a message in the echo area saying that it is doing its
Dave Love <fx@gnu.org>
parents:
diff changeset
292 work; it is actually useful primarily in the @file{.emacs} file. If an
Dave Love <fx@gnu.org>
parents:
diff changeset
293 empty argument is given to either of these functions, they use the file
Dave Love <fx@gnu.org>
parents:
diff changeset
294 name specified in the variable @code{abbrev-file-name}, which is by
Dave Love <fx@gnu.org>
parents:
diff changeset
295 default @code{"~/.abbrev_defs"}.
Dave Love <fx@gnu.org>
parents:
diff changeset
296
Dave Love <fx@gnu.org>
parents:
diff changeset
297 @vindex save-abbrevs
Dave Love <fx@gnu.org>
parents:
diff changeset
298 Emacs will offer to save abbrevs automatically if you have changed any of
Dave Love <fx@gnu.org>
parents:
diff changeset
299 them, whenever it offers to save all files (for @kbd{C-x s} or @kbd{C-x
Dave Love <fx@gnu.org>
parents:
diff changeset
300 C-c}). This feature can be inhibited by setting the variable
Dave Love <fx@gnu.org>
parents:
diff changeset
301 @code{save-abbrevs} to @code{nil}.
Dave Love <fx@gnu.org>
parents:
diff changeset
302
Dave Love <fx@gnu.org>
parents:
diff changeset
303 @findex insert-abbrevs
Dave Love <fx@gnu.org>
parents:
diff changeset
304 @findex define-abbrevs
Dave Love <fx@gnu.org>
parents:
diff changeset
305 The commands @kbd{M-x insert-abbrevs} and @kbd{M-x define-abbrevs} are
Dave Love <fx@gnu.org>
parents:
diff changeset
306 similar to the previous commands but work on text in an Emacs buffer.
Dave Love <fx@gnu.org>
parents:
diff changeset
307 @kbd{M-x insert-abbrevs} inserts text into the current buffer before point,
Dave Love <fx@gnu.org>
parents:
diff changeset
308 describing all current abbrev definitions; @kbd{M-x define-abbrevs} parses
Dave Love <fx@gnu.org>
parents:
diff changeset
309 the entire current buffer and defines abbrevs accordingly.@refill
Dave Love <fx@gnu.org>
parents:
diff changeset
310
Dave Love <fx@gnu.org>
parents:
diff changeset
311 @node Dynamic Abbrevs
Dave Love <fx@gnu.org>
parents:
diff changeset
312 @section Dynamic Abbrev Expansion
Dave Love <fx@gnu.org>
parents:
diff changeset
313
Dave Love <fx@gnu.org>
parents:
diff changeset
314 The abbrev facility described above operates automatically as you insert
Dave Love <fx@gnu.org>
parents:
diff changeset
315 text, but all abbrevs must be defined explicitly. By contrast,
Dave Love <fx@gnu.org>
parents:
diff changeset
316 @dfn{dynamic abbrevs} allow the meanings of abbrevs to be determined
Dave Love <fx@gnu.org>
parents:
diff changeset
317 automatically from the contents of the buffer, but dynamic abbrev expansion
Dave Love <fx@gnu.org>
parents:
diff changeset
318 happens only when you request it explicitly.
Dave Love <fx@gnu.org>
parents:
diff changeset
319
Dave Love <fx@gnu.org>
parents:
diff changeset
320 @kindex M-/
Dave Love <fx@gnu.org>
parents:
diff changeset
321 @kindex C-M-/
Dave Love <fx@gnu.org>
parents:
diff changeset
322 @findex dabbrev-expand
Dave Love <fx@gnu.org>
parents:
diff changeset
323 @findex dabbrev-completion
Dave Love <fx@gnu.org>
parents:
diff changeset
324 @table @kbd
Dave Love <fx@gnu.org>
parents:
diff changeset
325 @item M-/
Dave Love <fx@gnu.org>
parents:
diff changeset
326 Expand the word in the buffer before point as a @dfn{dynamic abbrev},
Dave Love <fx@gnu.org>
parents:
diff changeset
327 by searching in the buffer for words starting with that abbreviation
Dave Love <fx@gnu.org>
parents:
diff changeset
328 (@code{dabbrev-expand}).
Dave Love <fx@gnu.org>
parents:
diff changeset
329
Dave Love <fx@gnu.org>
parents:
diff changeset
330 @item C-M-/
Dave Love <fx@gnu.org>
parents:
diff changeset
331 Complete the word before point as a dynamic abbrev
Dave Love <fx@gnu.org>
parents:
diff changeset
332 (@code{dabbrev-completion}).
Dave Love <fx@gnu.org>
parents:
diff changeset
333 @end table
Dave Love <fx@gnu.org>
parents:
diff changeset
334
Dave Love <fx@gnu.org>
parents:
diff changeset
335 @vindex dabbrev-limit
Dave Love <fx@gnu.org>
parents:
diff changeset
336 For example, if the buffer contains @samp{does this follow } and you
Dave Love <fx@gnu.org>
parents:
diff changeset
337 type @kbd{f o M-/}, the effect is to insert @samp{follow} because that
Dave Love <fx@gnu.org>
parents:
diff changeset
338 is the last word in the buffer that starts with @samp{fo}. A numeric
Dave Love <fx@gnu.org>
parents:
diff changeset
339 argument to @kbd{M-/} says to take the second, third, etc.@: distinct
Dave Love <fx@gnu.org>
parents:
diff changeset
340 expansion found looking backward from point. Repeating @kbd{M-/}
Dave Love <fx@gnu.org>
parents:
diff changeset
341 searches for an alternative expansion by looking farther back. After
Dave Love <fx@gnu.org>
parents:
diff changeset
342 scanning all the text before point, it searches the text after point.
Dave Love <fx@gnu.org>
parents:
diff changeset
343 The variable @code{dabbrev-limit}, if non-@code{nil}, specifies how far
Dave Love <fx@gnu.org>
parents:
diff changeset
344 in the buffer to search for an expansion.
Dave Love <fx@gnu.org>
parents:
diff changeset
345
Dave Love <fx@gnu.org>
parents:
diff changeset
346 @vindex dabbrev-check-all-buffers
Dave Love <fx@gnu.org>
parents:
diff changeset
347 After scanning the current buffer, @kbd{M-/} normally searches other
Dave Love <fx@gnu.org>
parents:
diff changeset
348 buffers, unless you have set @code{dabbrev-check-all-buffers} to
Dave Love <fx@gnu.org>
parents:
diff changeset
349 @code{nil}.
Dave Love <fx@gnu.org>
parents:
diff changeset
350
Dave Love <fx@gnu.org>
parents:
diff changeset
351 A negative argument to @kbd{M-/}, as in @kbd{C-u - M-/}, says to
Dave Love <fx@gnu.org>
parents:
diff changeset
352 search first for expansions after point, and second for expansions
Dave Love <fx@gnu.org>
parents:
diff changeset
353 before point. If you repeat the @kbd{M-/} to look for another
Dave Love <fx@gnu.org>
parents:
diff changeset
354 expansion, do not specify an argument. This tries all the expansions
Dave Love <fx@gnu.org>
parents:
diff changeset
355 after point and then the expansions before point.
Dave Love <fx@gnu.org>
parents:
diff changeset
356
Dave Love <fx@gnu.org>
parents:
diff changeset
357 After you have expanded a dynamic abbrev, you can copy additional
Dave Love <fx@gnu.org>
parents:
diff changeset
358 words that follow the expansion in its original context. Simply type
Dave Love <fx@gnu.org>
parents:
diff changeset
359 @kbd{@key{SPC} M-/} for each word you want to copy. The spacing and
Dave Love <fx@gnu.org>
parents:
diff changeset
360 punctuation between words is copied along with the words.
Dave Love <fx@gnu.org>
parents:
diff changeset
361
Dave Love <fx@gnu.org>
parents:
diff changeset
362 The command @kbd{C-M-/} (@code{dabbrev-completion}) performs
Dave Love <fx@gnu.org>
parents:
diff changeset
363 completion of a dynamic abbreviation. Instead of trying the possible
Dave Love <fx@gnu.org>
parents:
diff changeset
364 expansions one by one, it finds all of them, then inserts the text that
Dave Love <fx@gnu.org>
parents:
diff changeset
365 they have in common. If they have nothing in common, @kbd{C-M-/}
Dave Love <fx@gnu.org>
parents:
diff changeset
366 displays a list of completions, from which you can select a choice in
Dave Love <fx@gnu.org>
parents:
diff changeset
367 the usual manner. @xref{Completion}.
Dave Love <fx@gnu.org>
parents:
diff changeset
368
Dave Love <fx@gnu.org>
parents:
diff changeset
369 Dynamic abbrev expansion is completely independent of Abbrev mode; the
Dave Love <fx@gnu.org>
parents:
diff changeset
370 expansion of a word with @kbd{M-/} is completely independent of whether
Dave Love <fx@gnu.org>
parents:
diff changeset
371 it has a definition as an ordinary abbrev.
Dave Love <fx@gnu.org>
parents:
diff changeset
372
Dave Love <fx@gnu.org>
parents:
diff changeset
373 @node Dabbrev Customization
Dave Love <fx@gnu.org>
parents:
diff changeset
374 @section Customizing Dynamic Abbreviation
Dave Love <fx@gnu.org>
parents:
diff changeset
375
Dave Love <fx@gnu.org>
parents:
diff changeset
376 Normally, dynamic abbrev expansion ignores case when searching for
Dave Love <fx@gnu.org>
parents:
diff changeset
377 expansions. That is, the expansion need not agree in case with the word
Dave Love <fx@gnu.org>
parents:
diff changeset
378 you are expanding.
Dave Love <fx@gnu.org>
parents:
diff changeset
379
Dave Love <fx@gnu.org>
parents:
diff changeset
380 @vindex dabbrev-case-fold-search
Dave Love <fx@gnu.org>
parents:
diff changeset
381 This feature is controlled by the variable
Dave Love <fx@gnu.org>
parents:
diff changeset
382 @code{dabbrev-case-fold-search}. If it is @code{t}, case is ignored in
Dave Love <fx@gnu.org>
parents:
diff changeset
383 this search; if @code{nil}, the word and the expansion must match in
Dave Love <fx@gnu.org>
parents:
diff changeset
384 case. If the value of @code{dabbrev-case-fold-search} is
Dave Love <fx@gnu.org>
parents:
diff changeset
385 @code{case-fold-search}, which is true by default, then the variable
Dave Love <fx@gnu.org>
parents:
diff changeset
386 @code{case-fold-search} controls whether to ignore case while searching
Dave Love <fx@gnu.org>
parents:
diff changeset
387 for expansions.
Dave Love <fx@gnu.org>
parents:
diff changeset
388
Dave Love <fx@gnu.org>
parents:
diff changeset
389 @vindex dabbrev-case-replace
Dave Love <fx@gnu.org>
parents:
diff changeset
390 Normally, dynamic abbrev expansion preserves the case pattern @emph{of
Dave Love <fx@gnu.org>
parents:
diff changeset
391 the abbrev you have typed}, by converting the expansion to that case
Dave Love <fx@gnu.org>
parents:
diff changeset
392 pattern.
Dave Love <fx@gnu.org>
parents:
diff changeset
393
Dave Love <fx@gnu.org>
parents:
diff changeset
394 @vindex dabbrev-case-fold-search
Dave Love <fx@gnu.org>
parents:
diff changeset
395 The variable @code{dabbrev-case-replace} controls whether to preserve
Dave Love <fx@gnu.org>
parents:
diff changeset
396 the case pattern of the abbrev. If it is @code{t}, the abbrev's case
Dave Love <fx@gnu.org>
parents:
diff changeset
397 pattern is preserved in most cases; if @code{nil}, the expansion is
Dave Love <fx@gnu.org>
parents:
diff changeset
398 always copied verbatim. If the value of @code{dabbrev-case-replace} is
Dave Love <fx@gnu.org>
parents:
diff changeset
399 @code{case-replace}, which is true by default, then the variable
Dave Love <fx@gnu.org>
parents:
diff changeset
400 @code{case-replace} controls whether to copy the expansion verbatim.
Dave Love <fx@gnu.org>
parents:
diff changeset
401
Dave Love <fx@gnu.org>
parents:
diff changeset
402 However, if the expansion contains a complex mixed case pattern, and
Dave Love <fx@gnu.org>
parents:
diff changeset
403 the abbrev matches this pattern as far as it goes, then the expansion is
Dave Love <fx@gnu.org>
parents:
diff changeset
404 always copied verbatim, regardless of those variables. Thus, for
Dave Love <fx@gnu.org>
parents:
diff changeset
405 example, if the buffer contains @code{variableWithSillyCasePattern}, and
Dave Love <fx@gnu.org>
parents:
diff changeset
406 you type @kbd{v a M-/}, it copies the expansion verbatim including its
Dave Love <fx@gnu.org>
parents:
diff changeset
407 case pattern.
Dave Love <fx@gnu.org>
parents:
diff changeset
408
Dave Love <fx@gnu.org>
parents:
diff changeset
409 @vindex dabbrev-abbrev-char-regexp
Dave Love <fx@gnu.org>
parents:
diff changeset
410 The variable @code{dabbrev-abbrev-char-regexp}, if non-@code{nil},
Dave Love <fx@gnu.org>
parents:
diff changeset
411 controls which characters are considered part of a word, for dynamic expansion
Dave Love <fx@gnu.org>
parents:
diff changeset
412 purposes. The regular expression must match just one character, never
Dave Love <fx@gnu.org>
parents:
diff changeset
413 two or more. The same regular expression also determines which
Dave Love <fx@gnu.org>
parents:
diff changeset
414 characters are part of an expansion. The value @code{nil} has a special
Dave Love <fx@gnu.org>
parents:
diff changeset
415 meaning: abbreviations are made of word characters, but expansions are
Dave Love <fx@gnu.org>
parents:
diff changeset
416 made of word and symbol characters.
Dave Love <fx@gnu.org>
parents:
diff changeset
417
Dave Love <fx@gnu.org>
parents:
diff changeset
418 @vindex dabbrev-abbrev-skip-leading-regexp
Dave Love <fx@gnu.org>
parents:
diff changeset
419 In shell scripts and makefiles, a variable name is sometimes prefixed
Dave Love <fx@gnu.org>
parents:
diff changeset
420 with @samp{$} and sometimes not. Major modes for this kind of text can
Dave Love <fx@gnu.org>
parents:
diff changeset
421 customize dynamic abbreviation to handle optional prefixes by setting
Dave Love <fx@gnu.org>
parents:
diff changeset
422 the variable @code{dabbrev-abbrev-skip-leading-regexp}. Its value
Dave Love <fx@gnu.org>
parents:
diff changeset
423 should be a regular expression that matches the optional prefix that
Dave Love <fx@gnu.org>
parents:
diff changeset
424 dynamic abbreviation should ignore.