annotate man/abbrevs.texi @ 78440:4fa26746dfc9

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