aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2009-05-13 01:26:47 +0000
committerChong Yidong2009-05-13 01:26:47 +0000
commit925672cdc78806da406cacd41d816223c11ee0bb (patch)
tree54ae1b873d30dc69fd33459f40a5a4a092fd3ded
parent78e4a31a2d6df1b57e154fea0bf1fee623a0346e (diff)
downloademacs-925672cdc78806da406cacd41d816223c11ee0bb.tar.gz
emacs-925672cdc78806da406cacd41d816223c11ee0bb.zip
* abbrevs.texi (Abbrevs): Add xref to Creating Symbols when
obarrays are first mentioned. Define "system abbrev" more prominently, and add it to the index. (Abbrev Mode, Abbrev Tables, Defining Abbrevs, Abbrev Properties): Copyedits. (Abbrev Expansion): Document abbrev-insert.
-rw-r--r--doc/lispref/ChangeLog9
-rw-r--r--doc/lispref/abbrevs.texi164
2 files changed, 100 insertions, 73 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog
index f07f4ca1cd0..a1dd728e655 100644
--- a/doc/lispref/ChangeLog
+++ b/doc/lispref/ChangeLog
@@ -1,3 +1,12 @@
12009-05-13 Chong Yidong <cyd@stupidchicken.com>
2
3 * abbrevs.texi (Abbrevs): Add xref to Creating Symbols when
4 obarrays are first mentioned. Define "system abbrev" more
5 prominently, and add it to the index.
6 (Abbrev Mode, Abbrev Tables, Defining Abbrevs, Abbrev Properties):
7 Copyedits.
8 (Abbrev Expansion): Document abbrev-insert.
9
12009-05-12 Chong Yidong <cyd@stupidchicken.com> 102009-05-12 Chong Yidong <cyd@stupidchicken.com>
2 11
3 * frames.texi (Font and Color Parameters): Rename from Color 12 * frames.texi (Font and Color Parameters): Rename from Color
diff --git a/doc/lispref/abbrevs.texi b/doc/lispref/abbrevs.texi
index b6544567680..c1eb562d56b 100644
--- a/doc/lispref/abbrevs.texi
+++ b/doc/lispref/abbrevs.texi
@@ -19,20 +19,27 @@ table}. Each buffer has a local abbrev table, but normally all buffers
19in the same major mode share one abbrev table. There is also a global 19in the same major mode share one abbrev table. There is also a global
20abbrev table. Normally both are used. 20abbrev table. Normally both are used.
21 21
22 An abbrev table is represented as an obarray containing a symbol for 22 An abbrev table is represented as an obarray. @xref{Creating
23each abbreviation. The symbol's name is the abbreviation; its value 23Symbols}, for information about obarrays. Each abbreviation is
24is the expansion; its function definition is the hook function to do 24represented by a symbol in the obarray. The symbol's name is the
25the expansion (@pxref{Defining Abbrevs}); its property list cell 25abbreviation; its value is the expansion; its function definition is
26typically contains various additional properties such as the use 26the hook function for performing the expansion (@pxref{Defining
27count, the number of times the abbreviation has been expanded, or 27Abbrevs}); and its property list cell contains various additional
28whether the abbrev is a so-called ``system'' abbrev defined by a major 28properties, including the use count and the number of times the
29mode rather than by the user (@pxref{Abbrev Properties}). 29abbreviation has been expanded (@pxref{Abbrev Properties}).
30 30
31Because the symbols used for abbrevs are not interned in the usual 31@cindex system abbrev
32 Certain abbrevs, called @dfn{system abbrevs}, are defined by a major
33mode instead of the user. A system abbrev is identified by its
34non-@code{nil} @code{:system} property (@pxref{Abbrev Properties}).
35When abbrevs are saved to an abbrev file, system abbrevs are omitted.
36@xref{Abbrev Files}.
37
38 Because the symbols used for abbrevs are not interned in the usual
32obarray, they will never appear as the result of reading a Lisp 39obarray, they will never appear as the result of reading a Lisp
33expression; in fact, normally they are never used except by the code 40expression; in fact, normally they are never used except by the code
34that handles abbrevs. Therefore, it is safe to use them in an 41that handles abbrevs. Therefore, it is safe to use them in an
35extremely nonstandard way. @xref{Creating Symbols}. 42extremely nonstandard way.
36 43
37 For the user-level commands for abbrevs, see @ref{Abbrevs,, Abbrev 44 For the user-level commands for abbrevs, see @ref{Abbrevs,, Abbrev
38Mode, emacs, The GNU Emacs Manual}. 45Mode, emacs, The GNU Emacs Manual}.
@@ -54,21 +61,20 @@ Mode, emacs, The GNU Emacs Manual}.
54@comment node-name, next, previous, up 61@comment node-name, next, previous, up
55@section Setting Up Abbrev Mode 62@section Setting Up Abbrev Mode
56 63
57 Abbrev mode is a minor mode controlled by the value of the variable 64 Abbrev mode is a minor mode controlled by the variable
58@code{abbrev-mode}. 65@code{abbrev-mode}.
59 66
60@defvar abbrev-mode 67@defvar abbrev-mode
61A non-@code{nil} value of this variable turns on the automatic expansion 68If this variable is non-@code{nil}, abbrevs are automatically expanded
62of abbrevs when their abbreviations are inserted into a buffer. 69in the buffer. If the value is @code{nil}, abbrevs may be defined,
63If the value is @code{nil}, abbrevs may be defined, but they are not 70but they are not expanded automatically.
64expanded automatically.
65 71
66This variable automatically becomes buffer-local when set in any fashion. 72This variable automatically becomes buffer-local when set in any fashion.
67@end defvar 73@end defvar
68 74
69@defvar default-abbrev-mode 75@defvar default-abbrev-mode
70This is the value of @code{abbrev-mode} for buffers that do not override it. 76This is the value of @code{abbrev-mode} for buffers that do not
71This is the same as @code{(default-value 'abbrev-mode)}. 77override it. It is the same as @code{(default-value 'abbrev-mode)}.
72@end defvar 78@end defvar
73 79
74@node Abbrev Tables, Defining Abbrevs, Abbrev Mode, Abbrevs 80@node Abbrev Tables, Defining Abbrevs, Abbrev Mode, Abbrevs
@@ -77,26 +83,27 @@ This is the same as @code{(default-value 'abbrev-mode)}.
77 This section describes how to create and manipulate abbrev tables. 83 This section describes how to create and manipulate abbrev tables.
78 84
79@defun make-abbrev-table &rest props 85@defun make-abbrev-table &rest props
80This function creates and returns a new, empty abbrev table---an obarray 86This function creates and returns a new, empty abbrev table---an
81containing no symbols. It is a vector filled with zeros. @var{props} 87obarray containing no symbols. It is a vector filled with zeros.
82is a property list that is applied to the new table 88@var{props} is a property list that is applied to the new table
83(@pxref{Abbrev Table Properties}). 89(@pxref{Abbrev Table Properties}).
84@end defun 90@end defun
85 91
86@defun abbrev-table-p table 92@defun abbrev-table-p object
87Return non-@code{nil} is @var{table} is an abbrev table. 93This function returns a non-@code{nil} value if @var{object} is an
94abbrev table.
88@end defun 95@end defun
89 96
90@defun clear-abbrev-table table 97@defun clear-abbrev-table abbrev-table
91This function undefines all the abbrevs in abbrev table @var{table}, 98This function undefines all the abbrevs in @var{abbrev-table}, leaving
92leaving it empty. It always returns @code{nil}. 99it empty. It always returns @code{nil}.
93@end defun 100@end defun
94 101
95@defun copy-abbrev-table table 102@defun copy-abbrev-table abbrev-table
96This function returns a copy of abbrev table @var{table}---a new 103This function returns a copy of @var{abbrev-table}---a new abbrev
97abbrev table that contains the same abbrev definitions. The only 104table containing the same abbrev definitions. There is one difference
98difference between @var{table} and the returned copy is that this 105between the contents of @var{abbrev-table} and the returned copy: all
99function sets the property lists of all copied abbrevs to 0. 106abbrevs in the latter have their property lists set to @code{nil}.
100@end defun 107@end defun
101 108
102@defun define-abbrev-table tabname definitions &optional docstring &rest props 109@defun define-abbrev-table tabname definitions &optional docstring &rest props
@@ -140,28 +147,30 @@ to add these to @var{name} separately.)
140@node Defining Abbrevs, Abbrev Files, Abbrev Tables, Abbrevs 147@node Defining Abbrevs, Abbrev Files, Abbrev Tables, Abbrevs
141@comment node-name, next, previous, up 148@comment node-name, next, previous, up
142@section Defining Abbrevs 149@section Defining Abbrevs
150
143 @code{define-abbrev} is the low-level basic function for defining an 151 @code{define-abbrev} is the low-level basic function for defining an
144abbrev in a specified abbrev table. When major modes predefine standard 152abbrev in an abbrev table.
145abbrevs, they should call @code{define-abbrev} and specify a @code{t} for 153
146the @code{:system} property. 154 When a major mode defines a system abbrev, it should call
147Be aware that any saved non-``system'' abbrevs are 155@code{define-abbrev} and specify a @code{t} for the @code{:system}
148restored at startup, i.e. before some major modes are loaded. Major modes 156property. Be aware that any saved non-``system'' abbrevs are restored
149should therefore not assume that when they are first loaded their abbrev 157at startup, i.e. before some major modes are loaded. Therefore, major
150tables are empty. 158modes should not assume that their abbrev tables are empty when they
151 159are first loaded.
152@defun define-abbrev table name expansion &optional hook &rest props 160
153This function defines an abbrev named @var{name}, in @var{table}, to 161@defun define-abbrev abbrev-table name expansion &optional hook &rest props
154expand to @var{expansion} and call @var{hook}, with properties 162This function defines an abbrev named @var{name}, in
155@var{props} (@pxref{Abbrev Properties}). The return value is @var{name}. 163@var{abbrev-table}, to expand to @var{expansion} and call @var{hook},
156The @code{:system} property in @var{props} is treated specially here: 164with properties @var{props} (@pxref{Abbrev Properties}). The return
157if it has the value @code{force}, then it will overwrite an existing 165value is @var{name}. The @code{:system} property in @var{props} is
158definition even for a non-``system'' abbrev of the same name. 166treated specially here: if it has the value @code{force}, then it will
159 167overwrite an existing definition even for a non-``system'' abbrev of
160The argument @var{name} should be a string. The argument 168the same name.
161@var{expansion} is normally the desired expansion (a string), or 169
162@code{nil} to undefine the abbrev. If it is anything but a string or 170@var{name} should be a string. The argument @var{expansion} is
163@code{nil}, then the abbreviation ``expands'' solely by running 171normally the desired expansion (a string), or @code{nil} to undefine
164@var{hook}. 172the abbrev. If it is anything but a string or @code{nil}, then the
173abbreviation ``expands'' solely by running @var{hook}.
165 174
166The argument @var{hook} is a function or @code{nil}. If @var{hook} is 175The argument @var{hook} is a function or @code{nil}. If @var{hook} is
167non-@code{nil}, then it is called with no arguments after the abbrev is 176non-@code{nil}, then it is called with no arguments after the abbrev is
@@ -177,11 +186,10 @@ inhibits insertion of the character. By contrast, if @var{hook}
177returns @code{nil}, @code{expand-abbrev} also returns @code{nil}, as 186returns @code{nil}, @code{expand-abbrev} also returns @code{nil}, as
178if expansion had not really occurred. 187if expansion had not really occurred.
179 188
180Normally the function @code{define-abbrev} sets the variable 189Normally, @code{define-abbrev} sets the variable
181@code{abbrevs-changed} to @code{t}, if it actually changes the abbrev. 190@code{abbrevs-changed} to @code{t}, if it actually changes the abbrev.
182(This is so that some commands will offer to save the abbrevs.) It 191(This is so that some commands will offer to save the abbrevs.) It
183does not do this for a ``system'' abbrev, since those won't be saved 192does not do this for a system abbrev, since those aren't saved anyway.
184anyway.
185@end defun 193@end defun
186 194
187@defopt only-global-abbrevs 195@defopt only-global-abbrevs
@@ -229,12 +237,12 @@ offer the user to save abbrevs when files are saved. If the value is
229 237
230@defvar abbrevs-changed 238@defvar abbrevs-changed
231This variable is set non-@code{nil} by defining or altering any 239This variable is set non-@code{nil} by defining or altering any
232abbrevs (except ``system'' abbrevs). This serves as a flag for 240abbrevs (except system abbrevs). This serves as a flag for various
233various Emacs commands to offer to save your abbrevs. 241Emacs commands to offer to save your abbrevs.
234@end defvar 242@end defvar
235 243
236@deffn Command write-abbrev-file &optional filename 244@deffn Command write-abbrev-file &optional filename
237Save all abbrev definitions (except ``system'' abbrevs), for all abbrev 245Save all abbrev definitions (except system abbrevs), for all abbrev
238tables listed in @code{abbrev-table-name-list}, in the file 246tables listed in @code{abbrev-table-name-list}, in the file
239@var{filename}, in the form of a Lisp program that when loaded will 247@var{filename}, in the form of a Lisp program that when loaded will
240define the same abbrevs. If @var{filename} is @code{nil} or omitted, 248define the same abbrevs. If @var{filename} is @code{nil} or omitted,
@@ -254,9 +262,9 @@ use for communication.
254This function returns the symbol representing the abbrev named 262This function returns the symbol representing the abbrev named
255@var{abbrev}. The value returned is @code{nil} if that abbrev is not 263@var{abbrev}. The value returned is @code{nil} if that abbrev is not
256defined. The optional second argument @var{table} is the abbrev table 264defined. The optional second argument @var{table} is the abbrev table
257to look it up in. If @var{table} is @code{nil}, this function tries 265in which to look it up. If @var{table} is @code{nil}, this function
258first the current buffer's local abbrev table, and second the global 266tries first the current buffer's local abbrev table, and second the
259abbrev table. 267global abbrev table.
260@end defun 268@end defun
261 269
262@defun abbrev-expansion abbrev &optional table 270@defun abbrev-expansion abbrev &optional table
@@ -278,6 +286,16 @@ function returns @code{nil} as its value, then @code{expand-abbrev}
278returns @code{nil} even though expansion did occur. 286returns @code{nil} even though expansion did occur.
279@end deffn 287@end deffn
280 288
289@deffn abbrev-insert abbrev &optional name start end
290This function inserts the abbrev expansion of @code{abbrev}, replacing
291the text between @code{start} and @code{end}. If @code{start} is
292omitted, it defaults to point. @code{name}, if non-@code{nil}, should
293be the name by which this abbrev was found (a string); it is used to
294figure out whether to adjust the capitalization of the expansion. The
295function returns @code{abbrev} if the abbrev was successfully
296inserted.
297@end deffn
298
281@deffn Command abbrev-prefix-mark &optional arg 299@deffn Command abbrev-prefix-mark &optional arg
282This command marks the current location of point as the beginning of 300This command marks the current location of point as the beginning of
283an abbrev. The next call to @code{expand-abbrev} will use the text 301an abbrev. The next call to @code{expand-abbrev} will use the text
@@ -335,11 +353,11 @@ has already been unexpanded. This contains information left by
335 353
336@defvar abbrev-expand-functions 354@defvar abbrev-expand-functions
337This is a special hook run @emph{around} the @code{expand-abbrev} 355This is a special hook run @emph{around} the @code{expand-abbrev}
338function. Functions on this hook are called with a single argument 356function. Each function on this hook is called with a single
339which is a function that performs the normal abbrev expansion. 357argument: a function that performs the normal abbrev expansion. The
340The hook function can hence do anything it wants before and after 358hook function can hence do anything it wants before and after
341performing the expansion. It can also choose not to call its argument 359performing the expansion. It can also choose not to call its
342and thus override the default behavior, or it may even call it 360argument, thus overriding the default behavior; or it may even call it
343several times. The function should return the abbrev symbol if 361several times. The function should return the abbrev symbol if
344expansion took place. 362expansion took place.
345@end defvar 363@end defvar
@@ -415,18 +433,18 @@ This is the local abbrev table used in Lisp mode and Emacs Lisp mode.
415 433
416Abbrevs have properties, some of which influence the way they work. 434Abbrevs have properties, some of which influence the way they work.
417You can provide them as arguments to @code{define-abbrev} and you can 435You can provide them as arguments to @code{define-abbrev} and you can
418manipulate them with the functions: 436manipulate them with the following functions:
419 437
420@defun abbrev-put abbrev prop val 438@defun abbrev-put abbrev prop val
421Set the property @var{prop} of abbrev @var{abbrev} to value @var{val}. 439Set the property @var{prop} of @var{abbrev} to value @var{val}.
422@end defun 440@end defun
423 441
424@defun abbrev-get abbrev prop 442@defun abbrev-get abbrev prop
425Return the property @var{prop} of abbrev @var{abbrev}, or @code{nil} 443Return the property @var{prop} of @var{abbrev}, or @code{nil} if the
426if the abbrev has no such property. 444abbrev has no such property.
427@end defun 445@end defun
428 446
429The following properties have special meaning: 447The following properties have special meanings:
430 448
431@table @code 449@table @code
432@item :count 450@item :count
@@ -435,8 +453,8 @@ been expanded. If not explicitly set, it is initialized to 0 by
435@code{define-abbrev}. 453@code{define-abbrev}.
436 454
437@item :system 455@item :system
438If non-@code{nil}, this property marks the abbrev as a ``system'' 456If non-@code{nil}, this property marks the abbrev as a system abbrev.
439abbrev. Such abbrevs will not be saved to @var{abbrev-file-name}. 457Such abbrevs are not saved (@pxref{Abbrev Files}).
440 458
441@item :enable-function 459@item :enable-function
442If non-@code{nil}, this property should be a function of no 460If non-@code{nil}, this property should be a function of no