annotate lispref/abbrevs.texi @ 75051:04cb4f06cca2

(Variable Aliases): Clarify that aliases vars always have the same value.
author Richard M. Stallman <rms@gnu.org>
date Tue, 02 Jan 2007 20:58:29 +0000
parents f43c6119c6c4
children 6d19c76d81c5 6588c6259dfb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6552
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1 @c -*-texinfo-*-
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2 @c This is part of the GNU Emacs Lisp Reference Manual.
64889
e836425ee789 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 60260
diff changeset
3 @c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1999, 2002, 2003, 2004,
68648
067115a6e738 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 64889
diff changeset
4 @c 2005, 2006 Free Software Foundation, Inc.
6552
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5 @c See the file elisp.texi for copying conditions.
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6 @setfilename ../info/abbrevs
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9 @cindex abbrev
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10 @cindex abbrev table
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12 An abbreviation or @dfn{abbrev} is a string of characters that may be
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 expanded to a longer string. The user can insert the abbrev string and
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14 find it replaced automatically with the expansion of the abbrev. This
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15 saves typing.
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 The set of abbrevs currently in effect is recorded in an @dfn{abbrev
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 table}. Each buffer has a local abbrev table, but normally all buffers
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19 in the same major mode share one abbrev table. There is also a global
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 abbrev table. Normally both are used.
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
54133
c3fa09d47632 Various corrections and clarifications in addition to the following:
Luc Teirlinck <teirllm@auburn.edu>
parents: 52540
diff changeset
27 has been expanded. Alternatively, the use count is on the
42435
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
54133
c3fa09d47632 Various corrections and clarifications in addition to the following:
Luc Teirlinck <teirllm@auburn.edu>
parents: 52540
diff changeset
29 @code{system-type} property. Abbrevs with a non-@code{nil}
c3fa09d47632 Various corrections and clarifications in addition to the following:
Luc Teirlinck <teirllm@auburn.edu>
parents: 52540
diff changeset
30 @code{system-type} property are called ``system'' abbrevs. They are
c3fa09d47632 Various corrections and clarifications in addition to the following:
Luc Teirlinck <teirllm@auburn.edu>
parents: 52540
diff changeset
31 usually defined by modes or packages, instead of by the user, and are
c3fa09d47632 Various corrections and clarifications in addition to the following:
Luc Teirlinck <teirllm@auburn.edu>
parents: 52540
diff changeset
32 treated specially in certain respects.
c3fa09d47632 Various corrections and clarifications in addition to the following:
Luc Teirlinck <teirllm@auburn.edu>
parents: 52540
diff changeset
33
c3fa09d47632 Various corrections and clarifications in addition to the following:
Luc Teirlinck <teirllm@auburn.edu>
parents: 52540
diff changeset
34 Because the symbols used for abbrevs are not interned in the usual
c3fa09d47632 Various corrections and clarifications in addition to the following:
Luc Teirlinck <teirllm@auburn.edu>
parents: 52540
diff changeset
35 obarray, they will never appear as the result of reading a Lisp
c3fa09d47632 Various corrections and clarifications in addition to the following:
Luc Teirlinck <teirllm@auburn.edu>
parents: 52540
diff changeset
36 expression; in fact, normally they are never used except by the code
c3fa09d47632 Various corrections and clarifications in addition to the following:
Luc Teirlinck <teirllm@auburn.edu>
parents: 52540
diff changeset
37 that handles abbrevs. Therefore, it is safe to use them in an
42435
36047fca69b3 Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents: 27385
diff changeset
38 extremely nonstandard way. @xref{Creating Symbols}.
6552
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40 For the user-level commands for abbrevs, see @ref{Abbrevs,, Abbrev
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41 Mode, emacs, The GNU Emacs Manual}.
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43 @menu
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44 * Abbrev Mode:: Setting up Emacs for abbreviation.
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45 * Tables: Abbrev Tables. Creating and working with abbrev tables.
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46 * Defining Abbrevs:: Specifying abbreviations and their expansions.
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47 * Files: Abbrev Files. Saving abbrevs in files.
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48 * Expansion: Abbrev Expansion. Controlling expansion; expansion subroutines.
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
49 * Standard Abbrev Tables:: Abbrev tables used by various major modes.
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50 @end menu
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52 @node Abbrev Mode, Abbrev Tables, Abbrevs, Abbrevs
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53 @comment node-name, next, previous, up
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42436
diff changeset
54 @section Setting Up Abbrev Mode
6552
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56 Abbrev mode is a minor mode controlled by the value of the variable
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 @code{abbrev-mode}.
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59 @defvar abbrev-mode
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60 A non-@code{nil} value of this variable turns on the automatic expansion
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61 of abbrevs when their abbreviations are inserted into a buffer.
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62 If the value is @code{nil}, abbrevs may be defined, but they are not
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63 expanded automatically.
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64
21682
90da2489c498 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 21007
diff changeset
65 This variable automatically becomes buffer-local when set in any fashion.
6552
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 @end defvar
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 @defvar default-abbrev-mode
7688
ab6b8aa5002e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 6552
diff changeset
69 This is the value of @code{abbrev-mode} for buffers that do not override it.
6552
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70 This is the same as @code{(default-value 'abbrev-mode)}.
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71 @end defvar
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73 @node Abbrev Tables, Defining Abbrevs, Abbrev Mode, Abbrevs
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74 @section Abbrev Tables
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 This section describes how to create and manipulate abbrev tables.
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78 @defun make-abbrev-table
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79 This function creates and returns a new, empty abbrev table---an obarray
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80 containing no symbols. It is a vector filled with zeros.
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81 @end defun
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83 @defun clear-abbrev-table table
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84 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
85 leaving it empty. It always returns @code{nil}.
6552
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86 @end defun
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87
52136
2df0dfd73718 (Abbrev Tables): Add copy-abbrev-table.
Richard M. Stallman <rms@gnu.org>
parents: 52037
diff changeset
88 @defun copy-abbrev-table table
2df0dfd73718 (Abbrev Tables): Add copy-abbrev-table.
Richard M. Stallman <rms@gnu.org>
parents: 52037
diff changeset
89 This function returns a copy of abbrev table @var{table}---a new
54133
c3fa09d47632 Various corrections and clarifications in addition to the following:
Luc Teirlinck <teirllm@auburn.edu>
parents: 52540
diff changeset
90 abbrev table that contains the same abbrev definitions. The only
c3fa09d47632 Various corrections and clarifications in addition to the following:
Luc Teirlinck <teirllm@auburn.edu>
parents: 52540
diff changeset
91 difference between @var{table} and the returned copy is that this
c3fa09d47632 Various corrections and clarifications in addition to the following:
Luc Teirlinck <teirllm@auburn.edu>
parents: 52540
diff changeset
92 function sets the property lists of all copied abbrevs to 0.
52136
2df0dfd73718 (Abbrev Tables): Add copy-abbrev-table.
Richard M. Stallman <rms@gnu.org>
parents: 52037
diff changeset
93 @end defun
2df0dfd73718 (Abbrev Tables): Add copy-abbrev-table.
Richard M. Stallman <rms@gnu.org>
parents: 52037
diff changeset
94
6552
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95 @defun define-abbrev-table tabname definitions
42435
36047fca69b3 Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents: 27385
diff changeset
96 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
97 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
98 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
99 elements of the form @code{(@var{abbrevname} @var{expansion}
54133
c3fa09d47632 Various corrections and clarifications in addition to the following:
Luc Teirlinck <teirllm@auburn.edu>
parents: 52540
diff changeset
100 @var{hook} @var{usecount} @var{system-flag})}. If an element of
c3fa09d47632 Various corrections and clarifications in addition to the following:
Luc Teirlinck <teirllm@auburn.edu>
parents: 52540
diff changeset
101 @var{definitions} has length less than five, omitted elements default
c3fa09d47632 Various corrections and clarifications in addition to the following:
Luc Teirlinck <teirllm@auburn.edu>
parents: 52540
diff changeset
102 to @code{nil}. A value of @code{nil} for @var{usecount} is equivalent
c3fa09d47632 Various corrections and clarifications in addition to the following:
Luc Teirlinck <teirllm@auburn.edu>
parents: 52540
diff changeset
103 to zero. The return value is always @code{nil}.
c3fa09d47632 Various corrections and clarifications in addition to the following:
Luc Teirlinck <teirllm@auburn.edu>
parents: 52540
diff changeset
104
c3fa09d47632 Various corrections and clarifications in addition to the following:
Luc Teirlinck <teirllm@auburn.edu>
parents: 52540
diff changeset
105 If this function is called more than once for the same @var{tabname},
c3fa09d47632 Various corrections and clarifications in addition to the following:
Luc Teirlinck <teirllm@auburn.edu>
parents: 52540
diff changeset
106 subsequent calls add the definitions in @var{definitions} to
c3fa09d47632 Various corrections and clarifications in addition to the following:
Luc Teirlinck <teirllm@auburn.edu>
parents: 52540
diff changeset
107 @var{tabname}, rather than overriding the entire original contents.
c3fa09d47632 Various corrections and clarifications in addition to the following:
Luc Teirlinck <teirllm@auburn.edu>
parents: 52540
diff changeset
108 (A subsequent call only overrides abbrevs explicitly redefined or
c3fa09d47632 Various corrections and clarifications in addition to the following:
Luc Teirlinck <teirllm@auburn.edu>
parents: 52540
diff changeset
109 undefined in @var{definitions}.)
6552
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110 @end defun
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112 @defvar abbrev-table-name-list
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113 This is a list of symbols whose values are abbrev tables.
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114 @code{define-abbrev-table} adds the new abbrev table name to this list.
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115 @end defvar
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117 @defun insert-abbrev-table-description name &optional human
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 This function inserts before point a description of the abbrev table
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119 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
120 abbrev table. The return value is always @code{nil}.
6552
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122 If @var{human} is non-@code{nil}, the description is human-oriented.
54133
c3fa09d47632 Various corrections and clarifications in addition to the following:
Luc Teirlinck <teirllm@auburn.edu>
parents: 52540
diff changeset
123 System abbrevs are listed and identified as such. Otherwise the
c3fa09d47632 Various corrections and clarifications in addition to the following:
Luc Teirlinck <teirllm@auburn.edu>
parents: 52540
diff changeset
124 description is a Lisp expression---a call to @code{define-abbrev-table}
c3fa09d47632 Various corrections and clarifications in addition to the following:
Luc Teirlinck <teirllm@auburn.edu>
parents: 52540
diff changeset
125 that would define @var{name} as it is currently defined, but without
c3fa09d47632 Various corrections and clarifications in addition to the following:
Luc Teirlinck <teirllm@auburn.edu>
parents: 52540
diff changeset
126 the system abbrevs. (The mode or package using @var{name} is supposed
c3fa09d47632 Various corrections and clarifications in addition to the following:
Luc Teirlinck <teirllm@auburn.edu>
parents: 52540
diff changeset
127 to add these to @var{name} separately.)
6552
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128 @end defun
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
130 @node Defining Abbrevs, Abbrev Files, Abbrev Tables, Abbrevs
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131 @comment node-name, next, previous, up
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132 @section Defining Abbrevs
54133
c3fa09d47632 Various corrections and clarifications in addition to the following:
Luc Teirlinck <teirllm@auburn.edu>
parents: 52540
diff changeset
133 @code{define-abbrev} is the low-level basic function for defining an
74552
f43c6119c6c4 (Defining Abbrevs): Abbrev tables may not be empty when major modes
Glenn Morris <rgm@gnu.org>
parents: 74550
diff changeset
134 abbrev in a specified abbrev table. When major modes predefine standard
f43c6119c6c4 (Defining Abbrevs): Abbrev tables may not be empty when major modes
Glenn Morris <rgm@gnu.org>
parents: 74550
diff changeset
135 abbrevs, they should call @code{define-abbrev} and specify @code{t} for
f43c6119c6c4 (Defining Abbrevs): Abbrev tables may not be empty when major modes
Glenn Morris <rgm@gnu.org>
parents: 74550
diff changeset
136 @var{system-flag}. Be aware that any saved non-``system'' abbrevs are
f43c6119c6c4 (Defining Abbrevs): Abbrev tables may not be empty when major modes
Glenn Morris <rgm@gnu.org>
parents: 74550
diff changeset
137 restored at startup, i.e. before some major modes are loaded. Major modes
f43c6119c6c4 (Defining Abbrevs): Abbrev tables may not be empty when major modes
Glenn Morris <rgm@gnu.org>
parents: 74550
diff changeset
138 should therefore not assume that when they are first loaded their abbrev
f43c6119c6c4 (Defining Abbrevs): Abbrev tables may not be empty when major modes
Glenn Morris <rgm@gnu.org>
parents: 74550
diff changeset
139 tables are empty.
6552
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140
42435
36047fca69b3 Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents: 27385
diff changeset
141 @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
142 This function defines an abbrev named @var{name}, in @var{table}, to
54133
c3fa09d47632 Various corrections and clarifications in addition to the following:
Luc Teirlinck <teirllm@auburn.edu>
parents: 52540
diff changeset
143 expand to @var{expansion} and call @var{hook}. The return value is
42435
36047fca69b3 Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents: 27385
diff changeset
144 @var{name}.
36047fca69b3 Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents: 27385
diff changeset
145
36047fca69b3 Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents: 27385
diff changeset
146 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
147 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
148 count is initialized to zero.
6552
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
150 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
151 @var{expansion} is normally the desired expansion (a string), or
66d807bdc5b4 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 7688
diff changeset
152 @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
153 @code{nil}, then the abbreviation ``expands'' solely by running
66d807bdc5b4 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 7688
diff changeset
154 @var{hook}.
6552
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
156 The argument @var{hook} is a function or @code{nil}. If @var{hook} is
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157 non-@code{nil}, then it is called with no arguments after the abbrev is
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
158 replaced with @var{expansion}; point is located at the end of
7688
ab6b8aa5002e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 6552
diff changeset
159 @var{expansion} when @var{hook} is called.
27385
f7b7fdb0f3f4 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 27270
diff changeset
160
52540
8c622de0d2ed (Defining Abbrevs): Index no-self-insert.
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
161 @cindex @code{no-self-insert} property
51681
0a1f20d3fa89 Fix minor Texinfo usage.
Richard M. Stallman <rms@gnu.org>
parents: 49600
diff changeset
162 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
163 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
164 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
165 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
166 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
167 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
168 if expansion had not really occurred.
42435
36047fca69b3 Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents: 27385
diff changeset
169
42436
99f8742109a3 Improve previous change.
Richard M. Stallman <rms@gnu.org>
parents: 42435
diff changeset
170 If @var{system-flag} is non-@code{nil}, that marks the abbrev as a
74550
296e4310eeb6 (Defining Abbrevs): Mention `define-abbrev' 'force
Glenn Morris <rgm@gnu.org>
parents: 68648
diff changeset
171 ``system'' abbrev with the @code{system-type} property. Unless
296e4310eeb6 (Defining Abbrevs): Mention `define-abbrev' 'force
Glenn Morris <rgm@gnu.org>
parents: 68648
diff changeset
172 @var{system-flag} has the value @code{force}, a ``system'' abbrev will
296e4310eeb6 (Defining Abbrevs): Mention `define-abbrev' 'force
Glenn Morris <rgm@gnu.org>
parents: 68648
diff changeset
173 not overwrite an existing definition for a non-``system'' abbrev of the
296e4310eeb6 (Defining Abbrevs): Mention `define-abbrev' 'force
Glenn Morris <rgm@gnu.org>
parents: 68648
diff changeset
174 same name.
42436
99f8742109a3 Improve previous change.
Richard M. Stallman <rms@gnu.org>
parents: 42435
diff changeset
175
42435
36047fca69b3 Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents: 27385
diff changeset
176 Normally the function @code{define-abbrev} sets the variable
42436
99f8742109a3 Improve previous change.
Richard M. Stallman <rms@gnu.org>
parents: 42435
diff changeset
177 @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
178 (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
179 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
180 anyway.
6552
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
181 @end defun
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
182
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
183 @defopt only-global-abbrevs
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
184 If this variable is non-@code{nil}, it means that the user plans to use
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
185 global abbrevs only. This tells the commands that define mode-specific
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
186 abbrevs to define global ones instead. This variable does not alter the
7688
ab6b8aa5002e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 6552
diff changeset
187 behavior of the functions in this section; it is examined by their
6552
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
188 callers.
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
189 @end defopt
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
190
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
191 @node Abbrev Files, Abbrev Expansion, Defining Abbrevs, Abbrevs
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
192 @section Saving Abbrevs in Files
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
193
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
194 A file of saved abbrev definitions is actually a file of Lisp code.
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
195 The abbrevs are saved in the form of a Lisp program to define the same
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
196 abbrev tables with the same contents. Therefore, you can load the file
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
197 with @code{load} (@pxref{How Programs Do Loading}). However, the
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
198 function @code{quietly-read-abbrev-file} is provided as a more
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
199 convenient interface.
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
200
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
201 User-level facilities such as @code{save-some-buffers} can save
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
202 abbrevs in a file automatically, under the control of variables
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
203 described here.
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
204
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
205 @defopt abbrev-file-name
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
206 This is the default file name for reading and saving abbrevs.
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
207 @end defopt
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
208
26192
01d4feb7e1e4 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents: 25751
diff changeset
209 @defun quietly-read-abbrev-file &optional filename
6552
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
210 This function reads abbrev definitions from a file named @var{filename},
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
211 previously written with @code{write-abbrev-file}. If @var{filename} is
26192
01d4feb7e1e4 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents: 25751
diff changeset
212 omitted or @code{nil}, the file specified in @code{abbrev-file-name} is
01d4feb7e1e4 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents: 25751
diff changeset
213 used. @code{save-abbrevs} is set to @code{t} so that changes will be
01d4feb7e1e4 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents: 25751
diff changeset
214 saved.
6552
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
215
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
216 This function does not display any messages. It returns @code{nil}.
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
217 @end defun
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
218
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
219 @defopt save-abbrevs
54133
c3fa09d47632 Various corrections and clarifications in addition to the following:
Luc Teirlinck <teirllm@auburn.edu>
parents: 52540
diff changeset
220 A non-@code{nil} value for @code{save-abbrevs} means that Emacs should
c3fa09d47632 Various corrections and clarifications in addition to the following:
Luc Teirlinck <teirllm@auburn.edu>
parents: 52540
diff changeset
221 offer the user to save abbrevs when files are saved. If the value is
c3fa09d47632 Various corrections and clarifications in addition to the following:
Luc Teirlinck <teirllm@auburn.edu>
parents: 52540
diff changeset
222 @code{silently}, Emacs saves the abbrevs without asking the user.
c3fa09d47632 Various corrections and clarifications in addition to the following:
Luc Teirlinck <teirllm@auburn.edu>
parents: 52540
diff changeset
223 @code{abbrev-file-name} specifies the file to save the abbrevs in.
6552
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
224 @end defopt
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
225
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
226 @defvar abbrevs-changed
42435
36047fca69b3 Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents: 27385
diff changeset
227 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
228 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
229 various Emacs commands to offer to save your abbrevs.
6552
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
230 @end defvar
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
231
26192
01d4feb7e1e4 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents: 25751
diff changeset
232 @deffn Command write-abbrev-file &optional filename
54133
c3fa09d47632 Various corrections and clarifications in addition to the following:
Luc Teirlinck <teirllm@auburn.edu>
parents: 52540
diff changeset
233 Save all abbrev definitions (except ``system'' abbrevs), for all abbrev
c3fa09d47632 Various corrections and clarifications in addition to the following:
Luc Teirlinck <teirllm@auburn.edu>
parents: 52540
diff changeset
234 tables listed in @code{abbrev-table-name-list}, in the file
c3fa09d47632 Various corrections and clarifications in addition to the following:
Luc Teirlinck <teirllm@auburn.edu>
parents: 52540
diff changeset
235 @var{filename}, in the form of a Lisp program that when loaded will
c3fa09d47632 Various corrections and clarifications in addition to the following:
Luc Teirlinck <teirllm@auburn.edu>
parents: 52540
diff changeset
236 define the same abbrevs. If @var{filename} is @code{nil} or omitted,
c3fa09d47632 Various corrections and clarifications in addition to the following:
Luc Teirlinck <teirllm@auburn.edu>
parents: 52540
diff changeset
237 @code{abbrev-file-name} is used. This function returns @code{nil}.
6552
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
238 @end deffn
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
239
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
240 @node Abbrev Expansion, Standard Abbrev Tables, Abbrev Files, Abbrevs
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
241 @comment node-name, next, previous, up
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
242 @section Looking Up and Expanding Abbreviations
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
243
21007
66d807bdc5b4 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 7688
diff changeset
244 Abbrevs are usually expanded by certain interactive commands,
6552
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
245 including @code{self-insert-command}. This section describes the
21007
66d807bdc5b4 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 7688
diff changeset
246 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
247 use for communication.
6552
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
248
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
249 @defun abbrev-symbol abbrev &optional table
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
250 This function returns the symbol representing the abbrev named
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
251 @var{abbrev}. The value returned is @code{nil} if that abbrev is not
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
252 defined. The optional second argument @var{table} is the abbrev table
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
253 to look it up in. If @var{table} is @code{nil}, this function tries
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
254 first the current buffer's local abbrev table, and second the global
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
255 abbrev table.
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
256 @end defun
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
257
7688
ab6b8aa5002e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 6552
diff changeset
258 @defun abbrev-expansion abbrev &optional table
ab6b8aa5002e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 6552
diff changeset
259 This function returns the string that @var{abbrev} would expand into (as
54133
c3fa09d47632 Various corrections and clarifications in addition to the following:
Luc Teirlinck <teirllm@auburn.edu>
parents: 52540
diff changeset
260 defined by the abbrev tables used for the current buffer). If
c3fa09d47632 Various corrections and clarifications in addition to the following:
Luc Teirlinck <teirllm@auburn.edu>
parents: 52540
diff changeset
261 @var{abbrev} is not a valid abbrev, the function returns @code{nil}.
c3fa09d47632 Various corrections and clarifications in addition to the following:
Luc Teirlinck <teirllm@auburn.edu>
parents: 52540
diff changeset
262 The optional argument @var{table} specifies the abbrev table to use,
c3fa09d47632 Various corrections and clarifications in addition to the following:
Luc Teirlinck <teirllm@auburn.edu>
parents: 52540
diff changeset
263 as in @code{abbrev-symbol}.
7688
ab6b8aa5002e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 6552
diff changeset
264 @end defun
ab6b8aa5002e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 6552
diff changeset
265
ab6b8aa5002e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 6552
diff changeset
266 @deffn Command expand-abbrev
26192
01d4feb7e1e4 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents: 25751
diff changeset
267 This command expands the abbrev before point, if any. If point does not
01d4feb7e1e4 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents: 25751
diff changeset
268 follow an abbrev, this command does nothing. The command returns the
01d4feb7e1e4 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents: 25751
diff changeset
269 abbrev symbol if it did expansion, @code{nil} otherwise.
27385
f7b7fdb0f3f4 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 27270
diff changeset
270
f7b7fdb0f3f4 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 27270
diff changeset
271 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
272 @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
273 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
274 returns @code{nil} even though expansion did occur.
7688
ab6b8aa5002e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 6552
diff changeset
275 @end deffn
ab6b8aa5002e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 6552
diff changeset
276
ab6b8aa5002e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 6552
diff changeset
277 @deffn Command abbrev-prefix-mark &optional arg
60260
a8e0abd18501 (Abbrev Expansion): Clarify, fix typo.
Richard M. Stallman <rms@gnu.org>
parents: 56816
diff changeset
278 This command marks the current location of point as the beginning of
a8e0abd18501 (Abbrev Expansion): Clarify, fix typo.
Richard M. Stallman <rms@gnu.org>
parents: 56816
diff changeset
279 an abbrev. The next call to @code{expand-abbrev} will use the text
a8e0abd18501 (Abbrev Expansion): Clarify, fix typo.
Richard M. Stallman <rms@gnu.org>
parents: 56816
diff changeset
280 from here to point (where it is then) as the abbrev to expand, rather
a8e0abd18501 (Abbrev Expansion): Clarify, fix typo.
Richard M. Stallman <rms@gnu.org>
parents: 56816
diff changeset
281 than using the previous word as usual.
54133
c3fa09d47632 Various corrections and clarifications in addition to the following:
Luc Teirlinck <teirllm@auburn.edu>
parents: 52540
diff changeset
282
c3fa09d47632 Various corrections and clarifications in addition to the following:
Luc Teirlinck <teirllm@auburn.edu>
parents: 52540
diff changeset
283 First, this command expands any abbrev before point, unless @var{arg}
c3fa09d47632 Various corrections and clarifications in addition to the following:
Luc Teirlinck <teirllm@auburn.edu>
parents: 52540
diff changeset
284 is non-@code{nil}. (Interactively, @var{arg} is the prefix argument.)
c3fa09d47632 Various corrections and clarifications in addition to the following:
Luc Teirlinck <teirllm@auburn.edu>
parents: 52540
diff changeset
285 Then it inserts a hyphen before point, to indicate the start of the
c3fa09d47632 Various corrections and clarifications in addition to the following:
Luc Teirlinck <teirllm@auburn.edu>
parents: 52540
diff changeset
286 next abbrev to be expanded. The actual expansion removes the hyphen.
7688
ab6b8aa5002e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 6552
diff changeset
287 @end deffn
ab6b8aa5002e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 6552
diff changeset
288
6552
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
289 @defopt abbrev-all-caps
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
290 When this is set non-@code{nil}, an abbrev entered entirely in upper
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
291 case is expanded using all upper case. Otherwise, an abbrev entered
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
292 entirely in upper case is expanded by capitalizing each word of the
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
293 expansion.
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
294 @end defopt
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
295
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
296 @defvar abbrev-start-location
56816
f3448e5d371d (Abbrev Expansion): `abbrev-start-location' can be an integer or a marker.
Luc Teirlinck <teirllm@auburn.edu>
parents: 56450
diff changeset
297 The value of this variable is a buffer position (an integer or a marker)
54212
ba850aa09d2d (Abbrev Expansion): Minor change.
Luc Teirlinck <teirllm@auburn.edu>
parents: 54133
diff changeset
298 for @code{expand-abbrev} to use as the start of the next abbrev to be
ba850aa09d2d (Abbrev Expansion): Minor change.
Luc Teirlinck <teirllm@auburn.edu>
parents: 54133
diff changeset
299 expanded. The value can also be @code{nil}, which means to use the
ba850aa09d2d (Abbrev Expansion): Minor change.
Luc Teirlinck <teirllm@auburn.edu>
parents: 54133
diff changeset
300 word before point instead. @code{abbrev-start-location} is set to
ba850aa09d2d (Abbrev Expansion): Minor change.
Luc Teirlinck <teirllm@auburn.edu>
parents: 54133
diff changeset
301 @code{nil} each time @code{expand-abbrev} is called. This variable is
ba850aa09d2d (Abbrev Expansion): Minor change.
Luc Teirlinck <teirllm@auburn.edu>
parents: 54133
diff changeset
302 also set by @code{abbrev-prefix-mark}.
6552
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
303 @end defvar
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
304
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
305 @defvar abbrev-start-location-buffer
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
306 The value of this variable is the buffer for which
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
307 @code{abbrev-start-location} has been set. Trying to expand an abbrev
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
308 in any other buffer clears @code{abbrev-start-location}. This variable
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
309 is set by @code{abbrev-prefix-mark}.
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
310 @end defvar
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
311
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
312 @defvar last-abbrev
21007
66d807bdc5b4 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 7688
diff changeset
313 This is the @code{abbrev-symbol} of the most recent abbrev expanded. This
6552
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
314 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
315 @code{unexpand-abbrev} command (@pxref{Expanding Abbrevs,, Expanding
66d807bdc5b4 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 7688
diff changeset
316 Abbrevs, emacs, The GNU Emacs Manual}).
6552
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
317 @end defvar
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
318
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
319 @defvar last-abbrev-location
21007
66d807bdc5b4 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 7688
diff changeset
320 This is the location of the most recent abbrev expanded. This contains
6552
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
321 information left by @code{expand-abbrev} for the sake of the
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
322 @code{unexpand-abbrev} command.
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
323 @end defvar
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
324
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
325 @defvar last-abbrev-text
21007
66d807bdc5b4 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 7688
diff changeset
326 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
327 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
328 has already been unexpanded. This contains information left by
66d807bdc5b4 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 7688
diff changeset
329 @code{expand-abbrev} for the sake of the @code{unexpand-abbrev} command.
6552
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
330 @end defvar
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
331
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
332 @c Emacs 19 feature
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
333 @defvar pre-abbrev-expand-hook
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
334 This is a normal hook whose functions are executed, in sequence, just
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
335 before any expansion of an abbrev. @xref{Hooks}. Since it is a normal
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
336 hook, the hook functions receive no arguments. However, they can find
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
337 the abbrev to be expanded by looking in the buffer before point.
26192
01d4feb7e1e4 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents: 25751
diff changeset
338 Running the hook is the first thing that @code{expand-abbrev} does, and
01d4feb7e1e4 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents: 25751
diff changeset
339 so a hook function can be used to change the current abbrev table before
56816
f3448e5d371d (Abbrev Expansion): `abbrev-start-location' can be an integer or a marker.
Luc Teirlinck <teirllm@auburn.edu>
parents: 56450
diff changeset
340 abbrev lookup happens. (Although you have to do this carefully. See
f3448e5d371d (Abbrev Expansion): `abbrev-start-location' can be an integer or a marker.
Luc Teirlinck <teirllm@auburn.edu>
parents: 56450
diff changeset
341 the example below.)
6552
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
342 @end defvar
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
343
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
344 The following sample code shows a simple use of
56816
f3448e5d371d (Abbrev Expansion): `abbrev-start-location' can be an integer or a marker.
Luc Teirlinck <teirllm@auburn.edu>
parents: 56450
diff changeset
345 @code{pre-abbrev-expand-hook}. It assumes that @code{foo-mode} is a
f3448e5d371d (Abbrev Expansion): `abbrev-start-location' can be an integer or a marker.
Luc Teirlinck <teirllm@auburn.edu>
parents: 56450
diff changeset
346 mode for editing certain files in which lines that start with @samp{#}
f3448e5d371d (Abbrev Expansion): `abbrev-start-location' can be an integer or a marker.
Luc Teirlinck <teirllm@auburn.edu>
parents: 56450
diff changeset
347 are comments. You want to use Text mode abbrevs for those lines. The
f3448e5d371d (Abbrev Expansion): `abbrev-start-location' can be an integer or a marker.
Luc Teirlinck <teirllm@auburn.edu>
parents: 56450
diff changeset
348 regular local abbrev table, @code{foo-mode-abbrev-table} is
f3448e5d371d (Abbrev Expansion): `abbrev-start-location' can be an integer or a marker.
Luc Teirlinck <teirllm@auburn.edu>
parents: 56450
diff changeset
349 appropriate for all other lines. Then you can put the following code
f3448e5d371d (Abbrev Expansion): `abbrev-start-location' can be an integer or a marker.
Luc Teirlinck <teirllm@auburn.edu>
parents: 56450
diff changeset
350 in your @file{.emacs} file. @xref{Standard Abbrev Tables}, for the
f3448e5d371d (Abbrev Expansion): `abbrev-start-location' can be an integer or a marker.
Luc Teirlinck <teirllm@auburn.edu>
parents: 56450
diff changeset
351 definitions of @code{local-abbrev-table} and @code{text-mode-abbrev-table}.
6552
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
352
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
353 @smallexample
56816
f3448e5d371d (Abbrev Expansion): `abbrev-start-location' can be an integer or a marker.
Luc Teirlinck <teirllm@auburn.edu>
parents: 56450
diff changeset
354 (defun foo-mode-pre-abbrev-expand ()
f3448e5d371d (Abbrev Expansion): `abbrev-start-location' can be an integer or a marker.
Luc Teirlinck <teirllm@auburn.edu>
parents: 56450
diff changeset
355 (when (save-excursion (forward-line 0) (eq (char-after) ?#))
f3448e5d371d (Abbrev Expansion): `abbrev-start-location' can be an integer or a marker.
Luc Teirlinck <teirllm@auburn.edu>
parents: 56450
diff changeset
356 (let ((local-abbrev-table text-mode-abbrev-table)
f3448e5d371d (Abbrev Expansion): `abbrev-start-location' can be an integer or a marker.
Luc Teirlinck <teirllm@auburn.edu>
parents: 56450
diff changeset
357 ;; Avoid infinite loop.
f3448e5d371d (Abbrev Expansion): `abbrev-start-location' can be an integer or a marker.
Luc Teirlinck <teirllm@auburn.edu>
parents: 56450
diff changeset
358 (pre-abbrev-expand-hook nil))
f3448e5d371d (Abbrev Expansion): `abbrev-start-location' can be an integer or a marker.
Luc Teirlinck <teirllm@auburn.edu>
parents: 56450
diff changeset
359 (expand-abbrev))
f3448e5d371d (Abbrev Expansion): `abbrev-start-location' can be an integer or a marker.
Luc Teirlinck <teirllm@auburn.edu>
parents: 56450
diff changeset
360 ;; We have already called `expand-abbrev' in this hook.
f3448e5d371d (Abbrev Expansion): `abbrev-start-location' can be an integer or a marker.
Luc Teirlinck <teirllm@auburn.edu>
parents: 56450
diff changeset
361 ;; Hence we want the "actual" call following this hook to be a no-op.
f3448e5d371d (Abbrev Expansion): `abbrev-start-location' can be an integer or a marker.
Luc Teirlinck <teirllm@auburn.edu>
parents: 56450
diff changeset
362 (setq abbrev-start-location (point-max)
f3448e5d371d (Abbrev Expansion): `abbrev-start-location' can be an integer or a marker.
Luc Teirlinck <teirllm@auburn.edu>
parents: 56450
diff changeset
363 abbrev-start-location-buffer (current-buffer))))
6552
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
364
56816
f3448e5d371d (Abbrev Expansion): `abbrev-start-location' can be an integer or a marker.
Luc Teirlinck <teirllm@auburn.edu>
parents: 56450
diff changeset
365 (add-hook 'foo-mode-hook
f3448e5d371d (Abbrev Expansion): `abbrev-start-location' can be an integer or a marker.
Luc Teirlinck <teirllm@auburn.edu>
parents: 56450
diff changeset
366 #'(lambda ()
f3448e5d371d (Abbrev Expansion): `abbrev-start-location' can be an integer or a marker.
Luc Teirlinck <teirllm@auburn.edu>
parents: 56450
diff changeset
367 (add-hook 'pre-abbrev-expand-hook
f3448e5d371d (Abbrev Expansion): `abbrev-start-location' can be an integer or a marker.
Luc Teirlinck <teirllm@auburn.edu>
parents: 56450
diff changeset
368 'foo-mode-pre-abbrev-expand
f3448e5d371d (Abbrev Expansion): `abbrev-start-location' can be an integer or a marker.
Luc Teirlinck <teirllm@auburn.edu>
parents: 56450
diff changeset
369 nil t)))
f3448e5d371d (Abbrev Expansion): `abbrev-start-location' can be an integer or a marker.
Luc Teirlinck <teirllm@auburn.edu>
parents: 56450
diff changeset
370 @end smallexample
6552
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
371
60260
a8e0abd18501 (Abbrev Expansion): Clarify, fix typo.
Richard M. Stallman <rms@gnu.org>
parents: 56816
diff changeset
372 Note that @code{foo-mode-pre-abbrev-expand} just returns @code{nil}
56816
f3448e5d371d (Abbrev Expansion): `abbrev-start-location' can be an integer or a marker.
Luc Teirlinck <teirllm@auburn.edu>
parents: 56450
diff changeset
373 without doing anything for lines not starting with @samp{#}. Hence
f3448e5d371d (Abbrev Expansion): `abbrev-start-location' can be an integer or a marker.
Luc Teirlinck <teirllm@auburn.edu>
parents: 56450
diff changeset
374 abbrevs expand normally using @code{foo-mode-abbrev-table} as local
f3448e5d371d (Abbrev Expansion): `abbrev-start-location' can be an integer or a marker.
Luc Teirlinck <teirllm@auburn.edu>
parents: 56450
diff changeset
375 abbrev table for such lines.
6552
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
376
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
377 @node Standard Abbrev Tables, , Abbrev Expansion, Abbrevs
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
378 @comment node-name, next, previous, up
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
379 @section Standard Abbrev Tables
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
380
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
381 Here we list the variables that hold the abbrev tables for the
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
382 preloaded major modes of Emacs.
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
383
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
384 @defvar global-abbrev-table
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
385 This is the abbrev table for mode-independent abbrevs. The abbrevs
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
386 defined in it apply to all buffers. Each buffer may also have a local
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
387 abbrev table, whose abbrev definitions take precedence over those in the
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
388 global table.
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
389 @end defvar
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
390
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
391 @defvar local-abbrev-table
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
392 The value of this buffer-local variable is the (mode-specific)
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
393 abbreviation table of the current buffer.
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
394 @end defvar
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
395
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
396 @defvar fundamental-mode-abbrev-table
7688
ab6b8aa5002e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 6552
diff changeset
397 This is the local abbrev table used in Fundamental mode; in other words,
ab6b8aa5002e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 6552
diff changeset
398 it is the local abbrev table in all buffers in Fundamental mode.
6552
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
399 @end defvar
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
400
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
401 @defvar text-mode-abbrev-table
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
402 This is the local abbrev table used in Text mode.
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
403 @end defvar
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
404
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
405 @defvar lisp-mode-abbrev-table
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
406 This is the local abbrev table used in Lisp mode and Emacs Lisp mode.
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
407 @end defvar
26192
01d4feb7e1e4 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents: 25751
diff changeset
408
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 52136
diff changeset
409 @ignore
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 52136
diff changeset
410 arch-tag: 5ffdbe08-2cd4-48ec-a5a8-080f95756eec
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 52136
diff changeset
411 @end ignore