Mercurial > emacs
annotate lispref/abbrevs.texi @ 53340:db645482d6bc
Trivial changes
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-18
author | Karoly Lorentey <lorentey@elte.hu> |
---|---|
date | Sun, 28 Dec 2003 22:28:52 +0000 |
parents | 8c622de0d2ed |
children | c3fa09d47632 |
rev | line source |
---|---|
6552 | 1 @c -*-texinfo-*- |
2 @c This is part of the GNU Emacs Lisp Reference Manual. | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42436
diff
changeset
|
3 @c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1999 |
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42436
diff
changeset
|
4 @c Free Software Foundation, Inc. |
6552 | 5 @c See the file elisp.texi for copying conditions. |
6 @setfilename ../info/abbrevs | |
7 @node Abbrevs, Processes, Syntax Tables, Top | |
25751
467b88fab665
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
8 @chapter Abbrevs and Abbrev Expansion |
6552 | 9 @cindex abbrev |
10 @cindex abbrev table | |
11 | |
12 An abbreviation or @dfn{abbrev} is a string of characters that may be | |
13 expanded to a longer string. The user can insert the abbrev string and | |
14 find it replaced automatically with the expansion of the abbrev. This | |
15 saves typing. | |
16 | |
17 The set of abbrevs currently in effect is recorded in an @dfn{abbrev | |
18 table}. Each buffer has a local abbrev table, but normally all buffers | |
19 in the same major mode share one abbrev table. There is also a global | |
20 abbrev table. Normally both are used. | |
21 | |
22 An abbrev table is represented as an obarray containing a symbol for | |
42435
36047fca69b3
Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents:
27385
diff
changeset
|
23 each abbreviation. The symbol's name is the abbreviation; its value |
36047fca69b3
Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents:
27385
diff
changeset
|
24 is the expansion; its function definition is the hook function to do |
36047fca69b3
Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents:
27385
diff
changeset
|
25 the expansion (@pxref{Defining Abbrevs}); its property list cell |
36047fca69b3
Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents:
27385
diff
changeset
|
26 typically contains the use count, the number of times the abbreviation |
36047fca69b3
Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents:
27385
diff
changeset
|
27 has been expanded. (Alternatively, the use count is on the |
36047fca69b3
Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents:
27385
diff
changeset
|
28 @code{count} property and the system-abbrev flag is on the |
36047fca69b3
Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents:
27385
diff
changeset
|
29 @code{system-type} property.) Because these symbols are not interned |
36047fca69b3
Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents:
27385
diff
changeset
|
30 in the usual obarray, they will never appear as the result of reading |
36047fca69b3
Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents:
27385
diff
changeset
|
31 a Lisp expression; in fact, normally they are never used except by the |
36047fca69b3
Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents:
27385
diff
changeset
|
32 code that handles abbrevs. Therefore, it is safe to use them in an |
36047fca69b3
Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents:
27385
diff
changeset
|
33 extremely nonstandard way. @xref{Creating Symbols}. |
6552 | 34 |
35 For the user-level commands for abbrevs, see @ref{Abbrevs,, Abbrev | |
36 Mode, emacs, The GNU Emacs Manual}. | |
37 | |
38 @menu | |
39 * Abbrev Mode:: Setting up Emacs for abbreviation. | |
40 * Tables: Abbrev Tables. Creating and working with abbrev tables. | |
41 * Defining Abbrevs:: Specifying abbreviations and their expansions. | |
42 * Files: Abbrev Files. Saving abbrevs in files. | |
43 * Expansion: Abbrev Expansion. Controlling expansion; expansion subroutines. | |
44 * Standard Abbrev Tables:: Abbrev tables used by various major modes. | |
45 @end menu | |
46 | |
47 @node Abbrev Mode, Abbrev Tables, Abbrevs, Abbrevs | |
48 @comment node-name, next, previous, up | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42436
diff
changeset
|
49 @section Setting Up Abbrev Mode |
6552 | 50 |
51 Abbrev mode is a minor mode controlled by the value of the variable | |
52 @code{abbrev-mode}. | |
53 | |
54 @defvar abbrev-mode | |
55 A non-@code{nil} value of this variable turns on the automatic expansion | |
56 of abbrevs when their abbreviations are inserted into a buffer. | |
57 If the value is @code{nil}, abbrevs may be defined, but they are not | |
58 expanded automatically. | |
59 | |
21682
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
60 This variable automatically becomes buffer-local when set in any fashion. |
6552 | 61 @end defvar |
62 | |
63 @defvar default-abbrev-mode | |
7688 | 64 This is the value of @code{abbrev-mode} for buffers that do not override it. |
6552 | 65 This is the same as @code{(default-value 'abbrev-mode)}. |
66 @end defvar | |
67 | |
68 @node Abbrev Tables, Defining Abbrevs, Abbrev Mode, Abbrevs | |
69 @section Abbrev Tables | |
70 | |
71 This section describes how to create and manipulate abbrev tables. | |
72 | |
73 @defun make-abbrev-table | |
74 This function creates and returns a new, empty abbrev table---an obarray | |
75 containing no symbols. It is a vector filled with zeros. | |
76 @end defun | |
77 | |
78 @defun clear-abbrev-table table | |
79 This function undefines all the abbrevs in abbrev table @var{table}, | |
27270
5a4e13447b47
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
27268
diff
changeset
|
80 leaving it empty. It always returns @code{nil}. |
6552 | 81 @end defun |
82 | |
52136
2df0dfd73718
(Abbrev Tables): Add copy-abbrev-table.
Richard M. Stallman <rms@gnu.org>
parents:
52037
diff
changeset
|
83 @defun copy-abbrev-table table |
2df0dfd73718
(Abbrev Tables): Add copy-abbrev-table.
Richard M. Stallman <rms@gnu.org>
parents:
52037
diff
changeset
|
84 This function returns a copy of abbrev table @var{table}---a new |
2df0dfd73718
(Abbrev Tables): Add copy-abbrev-table.
Richard M. Stallman <rms@gnu.org>
parents:
52037
diff
changeset
|
85 abbrev table that contains the same abbrev definitions. |
2df0dfd73718
(Abbrev Tables): Add copy-abbrev-table.
Richard M. Stallman <rms@gnu.org>
parents:
52037
diff
changeset
|
86 @end defun |
2df0dfd73718
(Abbrev Tables): Add copy-abbrev-table.
Richard M. Stallman <rms@gnu.org>
parents:
52037
diff
changeset
|
87 |
6552 | 88 @defun define-abbrev-table tabname definitions |
42435
36047fca69b3
Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents:
27385
diff
changeset
|
89 This function defines @var{tabname} (a symbol) as an abbrev table |
36047fca69b3
Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents:
27385
diff
changeset
|
90 name, i.e., as a variable whose value is an abbrev table. It defines |
36047fca69b3
Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents:
27385
diff
changeset
|
91 abbrevs in the table according to @var{definitions}, a list of |
36047fca69b3
Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents:
27385
diff
changeset
|
92 elements of the form @code{(@var{abbrevname} @var{expansion} |
36047fca69b3
Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents:
27385
diff
changeset
|
93 @var{hook} @var{usecount} @r{[}@var{system-flag}@r{]})}. The return |
36047fca69b3
Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents:
27385
diff
changeset
|
94 value is always @code{nil}. |
6552 | 95 @end defun |
96 | |
97 @defvar abbrev-table-name-list | |
98 This is a list of symbols whose values are abbrev tables. | |
99 @code{define-abbrev-table} adds the new abbrev table name to this list. | |
100 @end defvar | |
101 | |
102 @defun insert-abbrev-table-description name &optional human | |
103 This function inserts before point a description of the abbrev table | |
104 named @var{name}. The argument @var{name} is a symbol whose value is an | |
21007
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7688
diff
changeset
|
105 abbrev table. The return value is always @code{nil}. |
6552 | 106 |
107 If @var{human} is non-@code{nil}, the description is human-oriented. | |
108 Otherwise the description is a Lisp expression---a call to | |
7688 | 109 @code{define-abbrev-table} that would define @var{name} exactly as it |
6552 | 110 is currently defined. |
111 @end defun | |
112 | |
113 @node Defining Abbrevs, Abbrev Files, Abbrev Tables, Abbrevs | |
114 @comment node-name, next, previous, up | |
115 @section Defining Abbrevs | |
116 | |
117 These functions define an abbrev in a specified abbrev table. | |
118 @code{define-abbrev} is the low-level basic function, while | |
42436
99f8742109a3
Improve previous change.
Richard M. Stallman <rms@gnu.org>
parents:
42435
diff
changeset
|
119 @code{add-abbrev} is used by commands that ask for information from |
99f8742109a3
Improve previous change.
Richard M. Stallman <rms@gnu.org>
parents:
42435
diff
changeset
|
120 the user. When major modes predefine standard abbrevs, they should |
99f8742109a3
Improve previous change.
Richard M. Stallman <rms@gnu.org>
parents:
42435
diff
changeset
|
121 call @code{define-abbrev} and specify @code{t} for @var{system-flag}. |
6552 | 122 |
123 @defun add-abbrev table type arg | |
7688 | 124 This function adds an abbreviation to abbrev table @var{table} based on |
125 information from the user. The argument @var{type} is a string | |
126 describing in English the kind of abbrev this will be (typically, | |
127 @code{"global"} or @code{"mode-specific"}); this is used in prompting | |
128 the user. The argument @var{arg} is the number of words in the | |
129 expansion. | |
6552 | 130 |
7688 | 131 The return value is the symbol that internally represents the new |
6552 | 132 abbrev, or @code{nil} if the user declines to confirm redefining an |
133 existing abbrev. | |
134 @end defun | |
135 | |
42435
36047fca69b3
Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents:
27385
diff
changeset
|
136 @defun define-abbrev table name expansion &optional hook count system-flag |
21007
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7688
diff
changeset
|
137 This function defines an abbrev named @var{name}, in @var{table}, to |
42435
36047fca69b3
Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents:
27385
diff
changeset
|
138 expand to @var{expansion} and call @var{hook}. The return value is a |
36047fca69b3
Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents:
27385
diff
changeset
|
139 symbol that represents the abbrev inside Emacs; its name is |
36047fca69b3
Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents:
27385
diff
changeset
|
140 @var{name}. |
36047fca69b3
Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents:
27385
diff
changeset
|
141 |
36047fca69b3
Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents:
27385
diff
changeset
|
142 The value of @var{count}, if specified, initializes the abbrev's |
36047fca69b3
Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents:
27385
diff
changeset
|
143 usage-count. If @var{count} is not specified or @code{nil}, the use |
36047fca69b3
Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents:
27385
diff
changeset
|
144 count is initialized to zero. |
6552 | 145 |
146 The argument @var{name} should be a string. The argument | |
21007
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7688
diff
changeset
|
147 @var{expansion} is normally the desired expansion (a string), or |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7688
diff
changeset
|
148 @code{nil} to undefine the abbrev. If it is anything but a string or |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7688
diff
changeset
|
149 @code{nil}, then the abbreviation ``expands'' solely by running |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7688
diff
changeset
|
150 @var{hook}. |
6552 | 151 |
152 The argument @var{hook} is a function or @code{nil}. If @var{hook} is | |
153 non-@code{nil}, then it is called with no arguments after the abbrev is | |
154 replaced with @var{expansion}; point is located at the end of | |
7688 | 155 @var{expansion} when @var{hook} is called. |
27385
f7b7fdb0f3f4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
27270
diff
changeset
|
156 |
52540
8c622de0d2ed
(Defining Abbrevs): Index no-self-insert.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
157 @cindex @code{no-self-insert} property |
51681
0a1f20d3fa89
Fix minor Texinfo usage.
Richard M. Stallman <rms@gnu.org>
parents:
49600
diff
changeset
|
158 If @var{hook} is a non-@code{nil} symbol whose @code{no-self-insert} |
0a1f20d3fa89
Fix minor Texinfo usage.
Richard M. Stallman <rms@gnu.org>
parents:
49600
diff
changeset
|
159 property is non-@code{nil}, @var{hook} can explicitly control whether |
0a1f20d3fa89
Fix minor Texinfo usage.
Richard M. Stallman <rms@gnu.org>
parents:
49600
diff
changeset
|
160 to insert the self-inserting input character that triggered the |
0a1f20d3fa89
Fix minor Texinfo usage.
Richard M. Stallman <rms@gnu.org>
parents:
49600
diff
changeset
|
161 expansion. If @var{hook} returns non-@code{nil} in this case, that |
0a1f20d3fa89
Fix minor Texinfo usage.
Richard M. Stallman <rms@gnu.org>
parents:
49600
diff
changeset
|
162 inhibits insertion of the character. By contrast, if @var{hook} |
0a1f20d3fa89
Fix minor Texinfo usage.
Richard M. Stallman <rms@gnu.org>
parents:
49600
diff
changeset
|
163 returns @code{nil}, @code{expand-abbrev} also returns @code{nil}, as |
0a1f20d3fa89
Fix minor Texinfo usage.
Richard M. Stallman <rms@gnu.org>
parents:
49600
diff
changeset
|
164 if expansion had not really occurred. |
42435
36047fca69b3
Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents:
27385
diff
changeset
|
165 |
42436
99f8742109a3
Improve previous change.
Richard M. Stallman <rms@gnu.org>
parents:
42435
diff
changeset
|
166 If @var{system-flag} is non-@code{nil}, that marks the abbrev as a |
99f8742109a3
Improve previous change.
Richard M. Stallman <rms@gnu.org>
parents:
42435
diff
changeset
|
167 ``system'' abbrev with the @code{system-type} property. |
99f8742109a3
Improve previous change.
Richard M. Stallman <rms@gnu.org>
parents:
42435
diff
changeset
|
168 |
42435
36047fca69b3
Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents:
27385
diff
changeset
|
169 Normally the function @code{define-abbrev} sets the variable |
42436
99f8742109a3
Improve previous change.
Richard M. Stallman <rms@gnu.org>
parents:
42435
diff
changeset
|
170 @code{abbrevs-changed} to @code{t}, if it actually changes the abbrev. |
99f8742109a3
Improve previous change.
Richard M. Stallman <rms@gnu.org>
parents:
42435
diff
changeset
|
171 (This is so that some commands will offer to save the abbrevs.) It |
99f8742109a3
Improve previous change.
Richard M. Stallman <rms@gnu.org>
parents:
42435
diff
changeset
|
172 does not do this for a ``system'' abbrev, since those won't be saved |
99f8742109a3
Improve previous change.
Richard M. Stallman <rms@gnu.org>
parents:
42435
diff
changeset
|
173 anyway. |
6552 | 174 @end defun |
175 | |
176 @defopt only-global-abbrevs | |
177 If this variable is non-@code{nil}, it means that the user plans to use | |
178 global abbrevs only. This tells the commands that define mode-specific | |
179 abbrevs to define global ones instead. This variable does not alter the | |
7688 | 180 behavior of the functions in this section; it is examined by their |
6552 | 181 callers. |
182 @end defopt | |
183 | |
184 @node Abbrev Files, Abbrev Expansion, Defining Abbrevs, Abbrevs | |
185 @section Saving Abbrevs in Files | |
186 | |
187 A file of saved abbrev definitions is actually a file of Lisp code. | |
188 The abbrevs are saved in the form of a Lisp program to define the same | |
189 abbrev tables with the same contents. Therefore, you can load the file | |
190 with @code{load} (@pxref{How Programs Do Loading}). However, the | |
191 function @code{quietly-read-abbrev-file} is provided as a more | |
192 convenient interface. | |
193 | |
194 User-level facilities such as @code{save-some-buffers} can save | |
195 abbrevs in a file automatically, under the control of variables | |
196 described here. | |
197 | |
198 @defopt abbrev-file-name | |
199 This is the default file name for reading and saving abbrevs. | |
200 @end defopt | |
201 | |
26192 | 202 @defun quietly-read-abbrev-file &optional filename |
6552 | 203 This function reads abbrev definitions from a file named @var{filename}, |
204 previously written with @code{write-abbrev-file}. If @var{filename} is | |
26192 | 205 omitted or @code{nil}, the file specified in @code{abbrev-file-name} is |
206 used. @code{save-abbrevs} is set to @code{t} so that changes will be | |
207 saved. | |
6552 | 208 |
209 This function does not display any messages. It returns @code{nil}. | |
210 @end defun | |
211 | |
212 @defopt save-abbrevs | |
213 A non-@code{nil} value for @code{save-abbrev} means that Emacs should | |
214 save abbrevs when files are saved. @code{abbrev-file-name} specifies | |
215 the file to save the abbrevs in. | |
216 @end defopt | |
217 | |
218 @defvar abbrevs-changed | |
42435
36047fca69b3
Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents:
27385
diff
changeset
|
219 This variable is set non-@code{nil} by defining or altering any |
36047fca69b3
Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents:
27385
diff
changeset
|
220 abbrevs (except ``system'' abbrevs). This serves as a flag for |
36047fca69b3
Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents:
27385
diff
changeset
|
221 various Emacs commands to offer to save your abbrevs. |
6552 | 222 @end defvar |
223 | |
26192 | 224 @deffn Command write-abbrev-file &optional filename |
42435
36047fca69b3
Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents:
27385
diff
changeset
|
225 Save all abbrev definitions (except ``system'' abbrevs), in all abbrev |
36047fca69b3
Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents:
27385
diff
changeset
|
226 tables, in the file @var{filename}, in the form of a Lisp program that |
36047fca69b3
Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents:
27385
diff
changeset
|
227 when loaded will define the same abbrevs. If @var{filename} is |
36047fca69b3
Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents:
27385
diff
changeset
|
228 @code{nil} or omitted, @code{abbrev-file-name} is used. This function |
36047fca69b3
Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents:
27385
diff
changeset
|
229 returns @code{nil}. |
6552 | 230 @end deffn |
231 | |
232 @node Abbrev Expansion, Standard Abbrev Tables, Abbrev Files, Abbrevs | |
233 @comment node-name, next, previous, up | |
234 @section Looking Up and Expanding Abbreviations | |
235 | |
21007
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7688
diff
changeset
|
236 Abbrevs are usually expanded by certain interactive commands, |
6552 | 237 including @code{self-insert-command}. This section describes the |
21007
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7688
diff
changeset
|
238 subroutines used in writing such commands, as well as the variables they |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7688
diff
changeset
|
239 use for communication. |
6552 | 240 |
241 @defun abbrev-symbol abbrev &optional table | |
242 This function returns the symbol representing the abbrev named | |
243 @var{abbrev}. The value returned is @code{nil} if that abbrev is not | |
244 defined. The optional second argument @var{table} is the abbrev table | |
245 to look it up in. If @var{table} is @code{nil}, this function tries | |
246 first the current buffer's local abbrev table, and second the global | |
247 abbrev table. | |
248 @end defun | |
249 | |
7688 | 250 @defun abbrev-expansion abbrev &optional table |
251 This function returns the string that @var{abbrev} would expand into (as | |
252 defined by the abbrev tables used for the current buffer). The optional | |
253 argument @var{table} specifies the abbrev table to use, as in | |
254 @code{abbrev-symbol}. | |
255 @end defun | |
256 | |
257 @deffn Command expand-abbrev | |
26192 | 258 This command expands the abbrev before point, if any. If point does not |
259 follow an abbrev, this command does nothing. The command returns the | |
260 abbrev symbol if it did expansion, @code{nil} otherwise. | |
27385
f7b7fdb0f3f4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
27270
diff
changeset
|
261 |
f7b7fdb0f3f4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
27270
diff
changeset
|
262 If the abbrev symbol has a hook function which is a symbol whose |
f7b7fdb0f3f4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
27270
diff
changeset
|
263 @code{no-self-insert} property is non-@code{nil}, and if the hook |
f7b7fdb0f3f4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
27270
diff
changeset
|
264 function returns @code{nil} as its value, then @code{expand-abbrev} |
f7b7fdb0f3f4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
27270
diff
changeset
|
265 returns @code{nil} even though expansion did occur. |
7688 | 266 @end deffn |
267 | |
268 @deffn Command abbrev-prefix-mark &optional arg | |
269 Mark current point as the beginning of an abbrev. The next call to | |
270 @code{expand-abbrev} will use the text from here to point (where it is | |
271 then) as the abbrev to expand, rather than using the previous word as | |
272 usual. | |
273 @end deffn | |
274 | |
6552 | 275 @defopt abbrev-all-caps |
276 When this is set non-@code{nil}, an abbrev entered entirely in upper | |
277 case is expanded using all upper case. Otherwise, an abbrev entered | |
278 entirely in upper case is expanded by capitalizing each word of the | |
279 expansion. | |
280 @end defopt | |
281 | |
282 @defvar abbrev-start-location | |
283 This is the buffer position for @code{expand-abbrev} to use as the start | |
284 of the next abbrev to be expanded. (@code{nil} means use the word | |
285 before point instead.) @code{abbrev-start-location} is set to | |
286 @code{nil} each time @code{expand-abbrev} is called. This variable is | |
287 also set by @code{abbrev-prefix-mark}. | |
288 @end defvar | |
289 | |
290 @defvar abbrev-start-location-buffer | |
291 The value of this variable is the buffer for which | |
292 @code{abbrev-start-location} has been set. Trying to expand an abbrev | |
293 in any other buffer clears @code{abbrev-start-location}. This variable | |
294 is set by @code{abbrev-prefix-mark}. | |
295 @end defvar | |
296 | |
297 @defvar last-abbrev | |
21007
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7688
diff
changeset
|
298 This is the @code{abbrev-symbol} of the most recent abbrev expanded. This |
6552 | 299 information is left by @code{expand-abbrev} for the sake of the |
21007
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7688
diff
changeset
|
300 @code{unexpand-abbrev} command (@pxref{Expanding Abbrevs,, Expanding |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7688
diff
changeset
|
301 Abbrevs, emacs, The GNU Emacs Manual}). |
6552 | 302 @end defvar |
303 | |
304 @defvar last-abbrev-location | |
21007
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7688
diff
changeset
|
305 This is the location of the most recent abbrev expanded. This contains |
6552 | 306 information left by @code{expand-abbrev} for the sake of the |
307 @code{unexpand-abbrev} command. | |
308 @end defvar | |
309 | |
310 @defvar last-abbrev-text | |
21007
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7688
diff
changeset
|
311 This is the exact expansion text of the most recent abbrev expanded, |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7688
diff
changeset
|
312 after case conversion (if any). Its value is @code{nil} if the abbrev |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7688
diff
changeset
|
313 has already been unexpanded. This contains information left by |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7688
diff
changeset
|
314 @code{expand-abbrev} for the sake of the @code{unexpand-abbrev} command. |
6552 | 315 @end defvar |
316 | |
317 @c Emacs 19 feature | |
318 @defvar pre-abbrev-expand-hook | |
319 This is a normal hook whose functions are executed, in sequence, just | |
320 before any expansion of an abbrev. @xref{Hooks}. Since it is a normal | |
321 hook, the hook functions receive no arguments. However, they can find | |
322 the abbrev to be expanded by looking in the buffer before point. | |
26192 | 323 Running the hook is the first thing that @code{expand-abbrev} does, and |
324 so a hook function can be used to change the current abbrev table before | |
325 abbrev lookup happens. | |
6552 | 326 @end defvar |
327 | |
328 The following sample code shows a simple use of | |
329 @code{pre-abbrev-expand-hook}. If the user terminates an abbrev with a | |
330 punctuation character, the hook function asks for confirmation. Thus, | |
331 this hook allows the user to decide whether to expand the abbrev, and | |
332 aborts expansion if it is not confirmed. | |
333 | |
334 @smallexample | |
335 (add-hook 'pre-abbrev-expand-hook 'query-if-not-space) | |
336 | |
337 ;; @r{This is the function invoked by @code{pre-abbrev-expand-hook}.} | |
338 | |
339 ;; @r{If the user terminated the abbrev with a space, the function does} | |
340 ;; @r{nothing (that is, it returns so that the abbrev can expand). If the} | |
341 ;; @r{user entered some other character, this function asks whether} | |
342 ;; @r{expansion should continue.} | |
343 | |
7688 | 344 ;; @r{If the user answers the prompt with @kbd{y}, the function returns} |
6552 | 345 ;; @r{@code{nil} (because of the @code{not} function), but that is} |
346 ;; @r{acceptable; the return value has no effect on expansion.} | |
347 | |
348 (defun query-if-not-space () | |
52037
2232ca869e12
(Abbrev Expansion): Use \s syntax in example.
Markus Rost <rost@math.uni-bielefeld.de>
parents:
51681
diff
changeset
|
349 (if (/= ?\s (preceding-char)) |
6552 | 350 (if (not (y-or-n-p "Do you want to expand this abbrev? ")) |
351 (error "Not expanding this abbrev")))) | |
352 @end smallexample | |
353 | |
354 @node Standard Abbrev Tables, , Abbrev Expansion, Abbrevs | |
355 @comment node-name, next, previous, up | |
356 @section Standard Abbrev Tables | |
357 | |
358 Here we list the variables that hold the abbrev tables for the | |
359 preloaded major modes of Emacs. | |
360 | |
361 @defvar global-abbrev-table | |
362 This is the abbrev table for mode-independent abbrevs. The abbrevs | |
363 defined in it apply to all buffers. Each buffer may also have a local | |
364 abbrev table, whose abbrev definitions take precedence over those in the | |
365 global table. | |
366 @end defvar | |
367 | |
368 @defvar local-abbrev-table | |
369 The value of this buffer-local variable is the (mode-specific) | |
370 abbreviation table of the current buffer. | |
371 @end defvar | |
372 | |
373 @defvar fundamental-mode-abbrev-table | |
7688 | 374 This is the local abbrev table used in Fundamental mode; in other words, |
375 it is the local abbrev table in all buffers in Fundamental mode. | |
6552 | 376 @end defvar |
377 | |
378 @defvar text-mode-abbrev-table | |
379 This is the local abbrev table used in Text mode. | |
380 @end defvar | |
381 | |
382 @defvar lisp-mode-abbrev-table | |
383 This is the local abbrev table used in Lisp mode and Emacs Lisp mode. | |
384 @end defvar | |
26192 | 385 |
52401 | 386 @ignore |
387 arch-tag: 5ffdbe08-2cd4-48ec-a5a8-080f95756eec | |
388 @end ignore |