Commit | Line | Data |
---|---|---|
b8d4c8d0 GM |
1 | @c -*-texinfo-*- |
2 | @c This is part of the GNU Emacs Lisp Reference Manual. | |
ab422c4d PE |
3 | @c Copyright (C) 1990-1994, 1999, 2001-2013 Free Software Foundation, |
4 | @c Inc. | |
b8d4c8d0 | 5 | @c See the file elisp.texi for copying conditions. |
ecc6530d | 6 | @node Abbrevs |
b8d4c8d0 GM |
7 | @chapter Abbrevs and Abbrev Expansion |
8 | @cindex abbrev | |
9 | @c @cindex abbrev table Redundant with "abbrev". | |
10 | ||
11 | An abbreviation or @dfn{abbrev} is a string of characters that may be | |
12 | expanded to a longer string. The user can insert the abbrev string and | |
13 | find it replaced automatically with the expansion of the abbrev. This | |
14 | saves typing. | |
15 | ||
16 | The set of abbrevs currently in effect is recorded in an @dfn{abbrev | |
17 | table}. Each buffer has a local abbrev table, but normally all buffers | |
18 | in the same major mode share one abbrev table. There is also a global | |
19 | abbrev table. Normally both are used. | |
20 | ||
925672cd CY |
21 | An abbrev table is represented as an obarray. @xref{Creating |
22 | Symbols}, for information about obarrays. Each abbreviation is | |
23 | represented by a symbol in the obarray. The symbol's name is the | |
24 | abbreviation; its value is the expansion; its function definition is | |
25 | the hook function for performing the expansion (@pxref{Defining | |
26 | Abbrevs}); and its property list cell contains various additional | |
27 | properties, including the use count and the number of times the | |
28 | abbreviation has been expanded (@pxref{Abbrev Properties}). | |
29 | ||
30 | @cindex system abbrev | |
31 | Certain abbrevs, called @dfn{system abbrevs}, are defined by a major | |
32 | mode instead of the user. A system abbrev is identified by its | |
33 | non-@code{nil} @code{:system} property (@pxref{Abbrev Properties}). | |
34 | When abbrevs are saved to an abbrev file, system abbrevs are omitted. | |
35 | @xref{Abbrev Files}. | |
36 | ||
37 | Because the symbols used for abbrevs are not interned in the usual | |
b8d4c8d0 GM |
38 | obarray, they will never appear as the result of reading a Lisp |
39 | expression; in fact, normally they are never used except by the code | |
ea16568d GM |
40 | that handles abbrevs. Therefore, it is safe to use them in a |
41 | nonstandard way. | |
b8d4c8d0 | 42 | |
ea16568d GM |
43 | If the minor mode Abbrev mode is enabled, the buffer-local variable |
44 | @code{abbrev-mode} is non-@code{nil}, and abbrevs are automatically | |
45 | expanded in the buffer. For the user-level commands for abbrevs, see | |
46 | @ref{Abbrevs,, Abbrev Mode, emacs, The GNU Emacs Manual}. | |
b8d4c8d0 GM |
47 | |
48 | @menu | |
b8d4c8d0 GM |
49 | * Tables: Abbrev Tables. Creating and working with abbrev tables. |
50 | * Defining Abbrevs:: Specifying abbreviations and their expansions. | |
51 | * Files: Abbrev Files. Saving abbrevs in files. | |
52 | * Expansion: Abbrev Expansion. Controlling expansion; expansion subroutines. | |
53 | * Standard Abbrev Tables:: Abbrev tables used by various major modes. | |
e047f448 SM |
54 | * Abbrev Properties:: How to read and set abbrev properties. |
55 | Which properties have which effect. | |
56 | * Abbrev Table Properties:: How to read and set abbrev table properties. | |
57 | Which properties have which effect. | |
b8d4c8d0 GM |
58 | @end menu |
59 | ||
ecc6530d | 60 | @node Abbrev Tables |
b8d4c8d0 GM |
61 | @section Abbrev Tables |
62 | ||
63 | This section describes how to create and manipulate abbrev tables. | |
64 | ||
106e6894 | 65 | @defun make-abbrev-table &optional props |
925672cd CY |
66 | This function creates and returns a new, empty abbrev table---an |
67 | obarray containing no symbols. It is a vector filled with zeros. | |
68 | @var{props} is a property list that is applied to the new table | |
79415279 | 69 | (@pxref{Abbrev Table Properties}). |
e047f448 SM |
70 | @end defun |
71 | ||
925672cd CY |
72 | @defun abbrev-table-p object |
73 | This function returns a non-@code{nil} value if @var{object} is an | |
74 | abbrev table. | |
b8d4c8d0 GM |
75 | @end defun |
76 | ||
925672cd CY |
77 | @defun clear-abbrev-table abbrev-table |
78 | This function undefines all the abbrevs in @var{abbrev-table}, leaving | |
ea16568d GM |
79 | it empty. |
80 | @c Don't see why this needs saying. | |
81 | @c It always returns @code{nil}. | |
b8d4c8d0 GM |
82 | @end defun |
83 | ||
925672cd CY |
84 | @defun copy-abbrev-table abbrev-table |
85 | This function returns a copy of @var{abbrev-table}---a new abbrev | |
ea16568d GM |
86 | table containing the same abbrev definitions. It does @emph{not} copy |
87 | any property lists; only the names, values, and functions. | |
b8d4c8d0 GM |
88 | @end defun |
89 | ||
e047f448 | 90 | @defun define-abbrev-table tabname definitions &optional docstring &rest props |
b8d4c8d0 GM |
91 | This function defines @var{tabname} (a symbol) as an abbrev table |
92 | name, i.e., as a variable whose value is an abbrev table. It defines | |
93 | abbrevs in the table according to @var{definitions}, a list of | |
94 | elements of the form @code{(@var{abbrevname} @var{expansion} | |
e047f448 | 95 | [@var{hook}] [@var{props}...])}. These elements are passed as |
ea16568d | 96 | arguments to @code{define-abbrev}. @c The return value is always @code{nil}. |
e047f448 SM |
97 | |
98 | The optional string @var{docstring} is the documentation string of the | |
99 | variable @var{tabname}. The property list @var{props} is applied to | |
100 | the abbrev table (@pxref{Abbrev Table Properties}). | |
b8d4c8d0 GM |
101 | |
102 | If this function is called more than once for the same @var{tabname}, | |
103 | subsequent calls add the definitions in @var{definitions} to | |
ea16568d | 104 | @var{tabname}, rather than overwriting the entire original contents. |
b8d4c8d0 GM |
105 | (A subsequent call only overrides abbrevs explicitly redefined or |
106 | undefined in @var{definitions}.) | |
107 | @end defun | |
108 | ||
109 | @defvar abbrev-table-name-list | |
110 | This is a list of symbols whose values are abbrev tables. | |
111 | @code{define-abbrev-table} adds the new abbrev table name to this list. | |
112 | @end defvar | |
113 | ||
114 | @defun insert-abbrev-table-description name &optional human | |
115 | This function inserts before point a description of the abbrev table | |
116 | named @var{name}. The argument @var{name} is a symbol whose value is an | |
ea16568d | 117 | abbrev table. @c The return value is always @code{nil}. |
b8d4c8d0 GM |
118 | |
119 | If @var{human} is non-@code{nil}, the description is human-oriented. | |
120 | System abbrevs are listed and identified as such. Otherwise the | |
121 | description is a Lisp expression---a call to @code{define-abbrev-table} | |
122 | that would define @var{name} as it is currently defined, but without | |
123 | the system abbrevs. (The mode or package using @var{name} is supposed | |
124 | to add these to @var{name} separately.) | |
125 | @end defun | |
126 | ||
ecc6530d | 127 | @node Defining Abbrevs |
b8d4c8d0 | 128 | @section Defining Abbrevs |
925672cd | 129 | |
b8d4c8d0 | 130 | @code{define-abbrev} is the low-level basic function for defining an |
925672cd CY |
131 | abbrev in an abbrev table. |
132 | ||
133 | When a major mode defines a system abbrev, it should call | |
ea16568d | 134 | @code{define-abbrev} and specify @code{t} for the @code{:system} |
925672cd | 135 | property. Be aware that any saved non-``system'' abbrevs are restored |
1df7defd | 136 | at startup, i.e., before some major modes are loaded. Therefore, major |
925672cd CY |
137 | modes should not assume that their abbrev tables are empty when they |
138 | are first loaded. | |
139 | ||
140 | @defun define-abbrev abbrev-table name expansion &optional hook &rest props | |
141 | This function defines an abbrev named @var{name}, in | |
142 | @var{abbrev-table}, to expand to @var{expansion} and call @var{hook}, | |
143 | with properties @var{props} (@pxref{Abbrev Properties}). The return | |
144 | value is @var{name}. The @code{:system} property in @var{props} is | |
145 | treated specially here: if it has the value @code{force}, then it will | |
146 | overwrite an existing definition even for a non-``system'' abbrev of | |
147 | the same name. | |
148 | ||
149 | @var{name} should be a string. The argument @var{expansion} is | |
150 | normally the desired expansion (a string), or @code{nil} to undefine | |
151 | the abbrev. If it is anything but a string or @code{nil}, then the | |
152 | abbreviation ``expands'' solely by running @var{hook}. | |
b8d4c8d0 GM |
153 | |
154 | The argument @var{hook} is a function or @code{nil}. If @var{hook} is | |
155 | non-@code{nil}, then it is called with no arguments after the abbrev is | |
156 | replaced with @var{expansion}; point is located at the end of | |
157 | @var{expansion} when @var{hook} is called. | |
158 | ||
159 | @cindex @code{no-self-insert} property | |
160 | If @var{hook} is a non-@code{nil} symbol whose @code{no-self-insert} | |
161 | property is non-@code{nil}, @var{hook} can explicitly control whether | |
162 | to insert the self-inserting input character that triggered the | |
163 | expansion. If @var{hook} returns non-@code{nil} in this case, that | |
164 | inhibits insertion of the character. By contrast, if @var{hook} | |
ea16568d GM |
165 | returns @code{nil}, @code{expand-abbrev} (or @code{abbrev-insert}) |
166 | also returns @code{nil}, as if expansion had not really occurred. | |
b8d4c8d0 | 167 | |
925672cd | 168 | Normally, @code{define-abbrev} sets the variable |
b8d4c8d0 | 169 | @code{abbrevs-changed} to @code{t}, if it actually changes the abbrev. |
ea16568d | 170 | This is so that some commands will offer to save the abbrevs. It |
925672cd | 171 | does not do this for a system abbrev, since those aren't saved anyway. |
b8d4c8d0 GM |
172 | @end defun |
173 | ||
174 | @defopt only-global-abbrevs | |
175 | If this variable is non-@code{nil}, it means that the user plans to use | |
176 | global abbrevs only. This tells the commands that define mode-specific | |
177 | abbrevs to define global ones instead. This variable does not alter the | |
178 | behavior of the functions in this section; it is examined by their | |
179 | callers. | |
180 | @end defopt | |
181 | ||
ecc6530d | 182 | @node Abbrev Files |
b8d4c8d0 GM |
183 | @section Saving Abbrevs in Files |
184 | ||
185 | A file of saved abbrev definitions is actually a file of Lisp code. | |
186 | The abbrevs are saved in the form of a Lisp program to define the same | |
187 | abbrev tables with the same contents. Therefore, you can load the file | |
188 | with @code{load} (@pxref{How Programs Do Loading}). However, the | |
189 | function @code{quietly-read-abbrev-file} is provided as a more | |
ea16568d GM |
190 | convenient interface. Emacs automatically calls this function at |
191 | startup. | |
b8d4c8d0 GM |
192 | |
193 | User-level facilities such as @code{save-some-buffers} can save | |
194 | abbrevs in a file automatically, under the control of variables | |
195 | described here. | |
196 | ||
197 | @defopt abbrev-file-name | |
198 | This is the default file name for reading and saving abbrevs. | |
199 | @end defopt | |
200 | ||
201 | @defun quietly-read-abbrev-file &optional filename | |
202 | This function reads abbrev definitions from a file named @var{filename}, | |
203 | previously written with @code{write-abbrev-file}. If @var{filename} is | |
204 | omitted or @code{nil}, the file specified in @code{abbrev-file-name} is | |
ea16568d | 205 | used. |
b8d4c8d0 | 206 | |
ea16568d GM |
207 | As the name implies, this function does not display any messages. |
208 | @c It returns @code{nil}. | |
b8d4c8d0 GM |
209 | @end defun |
210 | ||
211 | @defopt save-abbrevs | |
212 | A non-@code{nil} value for @code{save-abbrevs} means that Emacs should | |
ea16568d GM |
213 | offer to save abbrevs (if any have changed) when files are saved. If |
214 | the value is @code{silently}, Emacs saves the abbrevs without asking | |
215 | the user. @code{abbrev-file-name} specifies the file to save the | |
216 | abbrevs in. | |
b8d4c8d0 GM |
217 | @end defopt |
218 | ||
219 | @defvar abbrevs-changed | |
220 | This variable is set non-@code{nil} by defining or altering any | |
925672cd CY |
221 | abbrevs (except system abbrevs). This serves as a flag for various |
222 | Emacs commands to offer to save your abbrevs. | |
b8d4c8d0 GM |
223 | @end defvar |
224 | ||
225 | @deffn Command write-abbrev-file &optional filename | |
925672cd | 226 | Save all abbrev definitions (except system abbrevs), for all abbrev |
b8d4c8d0 GM |
227 | tables listed in @code{abbrev-table-name-list}, in the file |
228 | @var{filename}, in the form of a Lisp program that when loaded will | |
229 | define the same abbrevs. If @var{filename} is @code{nil} or omitted, | |
230 | @code{abbrev-file-name} is used. This function returns @code{nil}. | |
231 | @end deffn | |
232 | ||
ecc6530d | 233 | @node Abbrev Expansion |
b8d4c8d0 GM |
234 | @section Looking Up and Expanding Abbreviations |
235 | ||
236 | Abbrevs are usually expanded by certain interactive commands, | |
237 | including @code{self-insert-command}. This section describes the | |
238 | subroutines used in writing such commands, as well as the variables they | |
239 | use for communication. | |
240 | ||
241 | @defun abbrev-symbol abbrev &optional table | |
242 | This function returns the symbol representing the abbrev named | |
ea16568d | 243 | @var{abbrev}. It returns @code{nil} if that abbrev is not |
b8d4c8d0 | 244 | defined. The optional second argument @var{table} is the abbrev table |
925672cd CY |
245 | in which to look it up. If @var{table} is @code{nil}, this function |
246 | tries first the current buffer's local abbrev table, and second the | |
247 | global abbrev table. | |
b8d4c8d0 GM |
248 | @end defun |
249 | ||
250 | @defun abbrev-expansion abbrev &optional table | |
251 | This function returns the string that @var{abbrev} would expand into (as | |
ea16568d GM |
252 | defined by the abbrev tables used for the current buffer). It returns |
253 | @code{nil} if @var{abbrev} is not a valid abbrev. | |
b8d4c8d0 GM |
254 | The optional argument @var{table} specifies the abbrev table to use, |
255 | as in @code{abbrev-symbol}. | |
256 | @end defun | |
257 | ||
258 | @deffn Command expand-abbrev | |
259 | This command expands the abbrev before point, if any. If point does not | |
260 | follow an abbrev, this command does nothing. The command returns the | |
261 | abbrev symbol if it did expansion, @code{nil} otherwise. | |
262 | ||
ea16568d | 263 | If the abbrev symbol has a hook function that is a symbol whose |
b8d4c8d0 GM |
264 | @code{no-self-insert} property is non-@code{nil}, and if the hook |
265 | function returns @code{nil} as its value, then @code{expand-abbrev} | |
266 | returns @code{nil} even though expansion did occur. | |
267 | @end deffn | |
268 | ||
5854c267 | 269 | @defun abbrev-insert abbrev &optional name start end |
925672cd CY |
270 | This function inserts the abbrev expansion of @code{abbrev}, replacing |
271 | the text between @code{start} and @code{end}. If @code{start} is | |
272 | omitted, it defaults to point. @code{name}, if non-@code{nil}, should | |
273 | be the name by which this abbrev was found (a string); it is used to | |
274 | figure out whether to adjust the capitalization of the expansion. The | |
275 | function returns @code{abbrev} if the abbrev was successfully | |
276 | inserted. | |
5854c267 | 277 | @end defun |
925672cd | 278 | |
b8d4c8d0 GM |
279 | @deffn Command abbrev-prefix-mark &optional arg |
280 | This command marks the current location of point as the beginning of | |
281 | an abbrev. The next call to @code{expand-abbrev} will use the text | |
282 | from here to point (where it is then) as the abbrev to expand, rather | |
283 | than using the previous word as usual. | |
284 | ||
285 | First, this command expands any abbrev before point, unless @var{arg} | |
286 | is non-@code{nil}. (Interactively, @var{arg} is the prefix argument.) | |
287 | Then it inserts a hyphen before point, to indicate the start of the | |
288 | next abbrev to be expanded. The actual expansion removes the hyphen. | |
289 | @end deffn | |
290 | ||
291 | @defopt abbrev-all-caps | |
292 | When this is set non-@code{nil}, an abbrev entered entirely in upper | |
293 | case is expanded using all upper case. Otherwise, an abbrev entered | |
294 | entirely in upper case is expanded by capitalizing each word of the | |
295 | expansion. | |
296 | @end defopt | |
297 | ||
298 | @defvar abbrev-start-location | |
299 | The value of this variable is a buffer position (an integer or a marker) | |
300 | for @code{expand-abbrev} to use as the start of the next abbrev to be | |
301 | expanded. The value can also be @code{nil}, which means to use the | |
302 | word before point instead. @code{abbrev-start-location} is set to | |
303 | @code{nil} each time @code{expand-abbrev} is called. This variable is | |
304 | also set by @code{abbrev-prefix-mark}. | |
305 | @end defvar | |
306 | ||
307 | @defvar abbrev-start-location-buffer | |
308 | The value of this variable is the buffer for which | |
309 | @code{abbrev-start-location} has been set. Trying to expand an abbrev | |
310 | in any other buffer clears @code{abbrev-start-location}. This variable | |
311 | is set by @code{abbrev-prefix-mark}. | |
312 | @end defvar | |
313 | ||
314 | @defvar last-abbrev | |
315 | This is the @code{abbrev-symbol} of the most recent abbrev expanded. This | |
316 | information is left by @code{expand-abbrev} for the sake of the | |
317 | @code{unexpand-abbrev} command (@pxref{Expanding Abbrevs,, Expanding | |
318 | Abbrevs, emacs, The GNU Emacs Manual}). | |
319 | @end defvar | |
320 | ||
321 | @defvar last-abbrev-location | |
322 | This is the location of the most recent abbrev expanded. This contains | |
323 | information left by @code{expand-abbrev} for the sake of the | |
324 | @code{unexpand-abbrev} command. | |
325 | @end defvar | |
326 | ||
327 | @defvar last-abbrev-text | |
328 | This is the exact expansion text of the most recent abbrev expanded, | |
329 | after case conversion (if any). Its value is @code{nil} if the abbrev | |
330 | has already been unexpanded. This contains information left by | |
331 | @code{expand-abbrev} for the sake of the @code{unexpand-abbrev} command. | |
332 | @end defvar | |
333 | ||
e047f448 | 334 | @defvar abbrev-expand-functions |
ea16568d GM |
335 | This is a wrapper hook (@pxref{Running Hooks}) run around the |
336 | @code{expand-abbrev} function. Each function on this hook is called | |
337 | with a single argument: a function that performs the normal abbrev | |
338 | expansion. The hook function can hence do anything it wants before | |
339 | and after performing the expansion. It can also choose not to call | |
340 | its argument, thus overriding the default behavior; or it may even | |
341 | call it several times. The function should return the abbrev symbol | |
342 | if expansion took place. | |
b8d4c8d0 GM |
343 | @end defvar |
344 | ||
345 | The following sample code shows a simple use of | |
e047f448 | 346 | @code{abbrev-expand-functions}. It assumes that @code{foo-mode} is a |
b8d4c8d0 GM |
347 | mode for editing certain files in which lines that start with @samp{#} |
348 | are comments. You want to use Text mode abbrevs for those lines. The | |
349 | regular local abbrev table, @code{foo-mode-abbrev-table} is | |
ea16568d | 350 | appropriate for all other lines. @xref{Standard Abbrev Tables}, for the |
b8d4c8d0 GM |
351 | definitions of @code{local-abbrev-table} and @code{text-mode-abbrev-table}. |
352 | ||
353 | @smallexample | |
e047f448 SM |
354 | (defun foo-mode-abbrev-expand-function (expand) |
355 | (if (not (save-excursion (forward-line 0) (eq (char-after) ?#))) | |
356 | ;; Performs normal expansion. | |
357 | (funcall expand) | |
358 | ;; We're inside a comment: use the text-mode abbrevs. | |
359 | (let ((local-abbrev-table text-mode-abbrev-table)) | |
360 | (funcall expand)))) | |
b8d4c8d0 GM |
361 | |
362 | (add-hook 'foo-mode-hook | |
d24880de GM |
363 | #'(lambda () |
364 | (add-hook 'abbrev-expand-functions | |
365 | 'foo-mode-abbrev-expand-function | |
366 | nil t))) | |
b8d4c8d0 GM |
367 | @end smallexample |
368 | ||
ecc6530d | 369 | @node Standard Abbrev Tables |
b8d4c8d0 GM |
370 | @section Standard Abbrev Tables |
371 | ||
372 | Here we list the variables that hold the abbrev tables for the | |
373 | preloaded major modes of Emacs. | |
374 | ||
375 | @defvar global-abbrev-table | |
376 | This is the abbrev table for mode-independent abbrevs. The abbrevs | |
377 | defined in it apply to all buffers. Each buffer may also have a local | |
378 | abbrev table, whose abbrev definitions take precedence over those in the | |
379 | global table. | |
380 | @end defvar | |
381 | ||
382 | @defvar local-abbrev-table | |
383 | The value of this buffer-local variable is the (mode-specific) | |
e047f448 SM |
384 | abbreviation table of the current buffer. It can also be a list of |
385 | such tables. | |
386 | @end defvar | |
387 | ||
388 | @defvar abbrev-minor-mode-table-alist | |
389 | The value of this variable is a list of elements of the form | |
390 | @code{(@var{mode} . @var{abbrev-table})} where @var{mode} is the name | |
391 | of a variable: if the variable is bound to a non-@code{nil} value, | |
392 | then the @var{abbrev-table} is active, otherwise it is ignored. | |
393 | @var{abbrev-table} can also be a list of abbrev tables. | |
b8d4c8d0 GM |
394 | @end defvar |
395 | ||
396 | @defvar fundamental-mode-abbrev-table | |
397 | This is the local abbrev table used in Fundamental mode; in other words, | |
398 | it is the local abbrev table in all buffers in Fundamental mode. | |
399 | @end defvar | |
400 | ||
401 | @defvar text-mode-abbrev-table | |
402 | This is the local abbrev table used in Text mode. | |
403 | @end defvar | |
404 | ||
405 | @defvar lisp-mode-abbrev-table | |
ea16568d GM |
406 | This is the local abbrev table used in Lisp mode. It is the parent |
407 | of the local abbrev table used in Emacs Lisp mode. @xref{Abbrev Table | |
408 | Properties}. | |
b8d4c8d0 GM |
409 | @end defvar |
410 | ||
ecc6530d | 411 | @node Abbrev Properties |
e047f448 SM |
412 | @section Abbrev Properties |
413 | ||
414 | Abbrevs have properties, some of which influence the way they work. | |
ea16568d | 415 | You can provide them as arguments to @code{define-abbrev}, and |
925672cd | 416 | manipulate them with the following functions: |
e047f448 SM |
417 | |
418 | @defun abbrev-put abbrev prop val | |
925672cd | 419 | Set the property @var{prop} of @var{abbrev} to value @var{val}. |
e047f448 SM |
420 | @end defun |
421 | ||
422 | @defun abbrev-get abbrev prop | |
925672cd CY |
423 | Return the property @var{prop} of @var{abbrev}, or @code{nil} if the |
424 | abbrev has no such property. | |
e047f448 SM |
425 | @end defun |
426 | ||
925672cd | 427 | The following properties have special meanings: |
e047f448 SM |
428 | |
429 | @table @code | |
79415279 | 430 | @item :count |
e047f448 SM |
431 | This property counts the number of times the abbrev has |
432 | been expanded. If not explicitly set, it is initialized to 0 by | |
433 | @code{define-abbrev}. | |
434 | ||
79415279 | 435 | @item :system |
925672cd CY |
436 | If non-@code{nil}, this property marks the abbrev as a system abbrev. |
437 | Such abbrevs are not saved (@pxref{Abbrev Files}). | |
e047f448 SM |
438 | |
439 | @item :enable-function | |
79415279 | 440 | If non-@code{nil}, this property should be a function of no |
e047f448 SM |
441 | arguments which returns @code{nil} if the abbrev should not be used |
442 | and @code{t} otherwise. | |
443 | ||
444 | @item :case-fixed | |
445 | If non-@code{nil}, this property indicates that the case of the | |
446 | abbrev's name is significant and should only match a text with the | |
79415279 SM |
447 | same pattern of capitalization. It also disables the code that |
448 | modifies the capitalization of the expansion. | |
e047f448 SM |
449 | @end table |
450 | ||
ecc6530d | 451 | @node Abbrev Table Properties |
e047f448 SM |
452 | @section Abbrev Table Properties |
453 | ||
bc5cde4b | 454 | Like abbrevs, abbrev tables have properties, some of which influence |
79415279 | 455 | the way they work. You can provide them as arguments to |
ea16568d | 456 | @code{define-abbrev-table}, and manipulate them with the functions: |
e047f448 SM |
457 | |
458 | @defun abbrev-table-put table prop val | |
459 | Set the property @var{prop} of abbrev table @var{table} to value @var{val}. | |
460 | @end defun | |
461 | ||
462 | @defun abbrev-table-get table prop | |
463 | Return the property @var{prop} of abbrev table @var{table}, or @code{nil} | |
464 | if the abbrev has no such property. | |
465 | @end defun | |
466 | ||
467 | The following properties have special meaning: | |
468 | ||
469 | @table @code | |
470 | @item :enable-function | |
79415279 | 471 | This is like the @code{:enable-function} abbrev property except that |
ea16568d GM |
472 | it applies to all abbrevs in the table. It is used before even trying |
473 | to find the abbrev before point, so it can dynamically modify the | |
79415279 | 474 | abbrev table. |
e047f448 SM |
475 | |
476 | @item :case-fixed | |
79415279 SM |
477 | This is like the @code{:case-fixed} abbrev property except that it |
478 | applies to all abbrevs in the table. | |
e047f448 SM |
479 | |
480 | @item :regexp | |
481 | If non-@code{nil}, this property is a regular expression that | |
ea16568d | 482 | indicates how to extract the name of the abbrev before point, before |
e047f448 SM |
483 | looking it up in the table. When the regular expression matches |
484 | before point, the abbrev name is expected to be in submatch 1. | |
ea16568d GM |
485 | If this property is @code{nil}, the default is to use |
486 | @code{backward-word} and @code{forward-word} to find the name. This | |
487 | property allows the use of abbrevs whose name contains characters of | |
488 | non-word syntax. | |
e047f448 SM |
489 | |
490 | @item :parents | |
ea16568d | 491 | This property holds a list of tables from which to inherit |
e047f448 SM |
492 | other abbrevs. |
493 | ||
494 | @item :abbrev-table-modiff | |
495 | This property holds a counter incremented each time a new abbrev is | |
496 | added to the table. | |
497 | ||
498 | @end table |