annotate lispref/abbrevs.texi @ 42435:36047fca69b3

Explain about ``system'' abbrevs.
author Richard M. Stallman <rms@gnu.org>
date Sun, 30 Dec 2001 20:07:27 +0000
parents f7b7fdb0f3f4
children 99f8742109a3
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.
27189
d2e5f1b7d8e2 Update copyrights.
Gerd Moellmann <gerd@gnu.org>
parents: 26192
diff changeset
3 @c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1999
d2e5f1b7d8e2 Update copyrights.
Gerd Moellmann <gerd@gnu.org>
parents: 26192
diff changeset
4 @c 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
36047fca69b3 Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents: 27385
diff changeset
27 has been expanded. (Alternatively, the use count is on the
36047fca69b3 Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents: 27385
diff changeset
28 @code{count} property and the system-abbrev flag is on the
36047fca69b3 Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents: 27385
diff changeset
29 @code{system-type} property.) Because these symbols are not interned
36047fca69b3 Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents: 27385
diff changeset
30 in the usual obarray, they will never appear as the result of reading
36047fca69b3 Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents: 27385
diff changeset
31 a Lisp expression; in fact, normally they are never used except by the
36047fca69b3 Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents: 27385
diff changeset
32 code that handles abbrevs. Therefore, it is safe to use them in an
36047fca69b3 Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents: 27385
diff changeset
33 extremely nonstandard way. @xref{Creating Symbols}.
6552
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35 For the user-level commands for abbrevs, see @ref{Abbrevs,, Abbrev
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 Mode, emacs, The GNU Emacs Manual}.
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38 @menu
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39 * Abbrev Mode:: Setting up Emacs for abbreviation.
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40 * Tables: Abbrev Tables. Creating and working with abbrev tables.
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41 * Defining Abbrevs:: Specifying abbreviations and their expansions.
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42 * Files: Abbrev Files. Saving abbrevs in files.
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43 * Expansion: Abbrev Expansion. Controlling expansion; expansion subroutines.
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44 * Standard Abbrev Tables:: Abbrev tables used by various major modes.
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45 @end menu
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47 @node Abbrev Mode, Abbrev Tables, Abbrevs, Abbrevs
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48 @comment node-name, next, previous, up
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
49 @section Setting Up Abbrev Mode
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51 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
52 @code{abbrev-mode}.
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54 @defvar abbrev-mode
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55 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
56 of abbrevs when their abbreviations are inserted into a buffer.
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 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
58 expanded automatically.
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59
21682
90da2489c498 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 21007
diff changeset
60 This variable automatically becomes buffer-local when set in any fashion.
6552
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61 @end defvar
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63 @defvar default-abbrev-mode
7688
ab6b8aa5002e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 6552
diff changeset
64 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
65 This is the same as @code{(default-value 'abbrev-mode)}.
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 @node Abbrev Tables, Defining Abbrevs, Abbrev Mode, Abbrevs
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69 @section Abbrev Tables
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71 This section describes how to create and manipulate abbrev tables.
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 @defun make-abbrev-table
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74 This function creates and returns a new, empty abbrev table---an obarray
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75 containing no symbols. It is a vector filled with zeros.
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 @end defun
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 clear-abbrev-table table
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79 This function undefines all the abbrevs in abbrev table @var{table},
27270
5a4e13447b47 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 27268
diff changeset
80 leaving it empty. It always returns @code{nil}.
6552
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 define-abbrev-table tabname definitions
42435
36047fca69b3 Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents: 27385
diff changeset
84 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
85 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
86 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
87 elements of the form @code{(@var{abbrevname} @var{expansion}
36047fca69b3 Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents: 27385
diff changeset
88 @var{hook} @var{usecount} @r{[}@var{system-flag}@r{]})}. The return
36047fca69b3 Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents: 27385
diff changeset
89 value is always @code{nil}.
6552
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90 @end defun
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92 @defvar abbrev-table-name-list
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93 This is a list of symbols whose values are abbrev tables.
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94 @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
95 @end defvar
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97 @defun insert-abbrev-table-description name &optional human
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98 This function inserts before point a description of the abbrev table
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99 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
100 abbrev table. The return value is always @code{nil}.
6552
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102 If @var{human} is non-@code{nil}, the description is human-oriented.
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103 Otherwise the description is a Lisp expression---a call to
7688
ab6b8aa5002e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 6552
diff changeset
104 @code{define-abbrev-table} that would define @var{name} exactly as it
6552
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105 is currently defined.
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106 @end defun
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108 @node Defining Abbrevs, Abbrev Files, Abbrev Tables, Abbrevs
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109 @comment node-name, next, previous, up
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110 @section Defining Abbrevs
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 These functions define an abbrev in a specified abbrev table.
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113 @code{define-abbrev} is the low-level basic function, while
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114 @code{add-abbrev} is used by commands that ask for information from the
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115 user.
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 add-abbrev table type arg
7688
ab6b8aa5002e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 6552
diff changeset
118 This function adds an abbreviation to abbrev table @var{table} based on
ab6b8aa5002e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 6552
diff changeset
119 information from the user. The argument @var{type} is a string
ab6b8aa5002e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 6552
diff changeset
120 describing in English the kind of abbrev this will be (typically,
ab6b8aa5002e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 6552
diff changeset
121 @code{"global"} or @code{"mode-specific"}); this is used in prompting
ab6b8aa5002e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 6552
diff changeset
122 the user. The argument @var{arg} is the number of words in the
ab6b8aa5002e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 6552
diff changeset
123 expansion.
6552
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124
7688
ab6b8aa5002e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 6552
diff changeset
125 The return value is the symbol that internally represents the new
6552
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126 abbrev, or @code{nil} if the user declines to confirm redefining an
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127 existing abbrev.
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
42435
36047fca69b3 Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents: 27385
diff changeset
130 @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
131 This function defines an abbrev named @var{name}, in @var{table}, to
42435
36047fca69b3 Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents: 27385
diff changeset
132 expand to @var{expansion} and call @var{hook}. The return value is a
36047fca69b3 Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents: 27385
diff changeset
133 symbol that represents the abbrev inside Emacs; its name is
36047fca69b3 Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents: 27385
diff changeset
134 @var{name}.
36047fca69b3 Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents: 27385
diff changeset
135
36047fca69b3 Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents: 27385
diff changeset
136 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
137 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
138 count is initialized to zero.
6552
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140 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
141 @var{expansion} is normally the desired expansion (a string), or
66d807bdc5b4 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 7688
diff changeset
142 @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
143 @code{nil}, then the abbreviation ``expands'' solely by running
66d807bdc5b4 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 7688
diff changeset
144 @var{hook}.
6552
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
145
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146 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
147 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
148 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
149 @var{expansion} when @var{hook} is called.
27385
f7b7fdb0f3f4 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 27270
diff changeset
150
f7b7fdb0f3f4 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 27270
diff changeset
151 If @var{hook} is a non-nil symbol whose @code{no-self-insert} property
f7b7fdb0f3f4 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 27270
diff changeset
152 is non-@code{nil}, @var{hook} can explicitly control whether to insert
f7b7fdb0f3f4 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 27270
diff changeset
153 the self-inserting input character that triggered the expansion. If
f7b7fdb0f3f4 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 27270
diff changeset
154 @var{hook} returns non-@code{nil} in this case, that inhibits insertion
f7b7fdb0f3f4 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 27270
diff changeset
155 of the character. By contrast, if @var{hook} returns @code{nil},
f7b7fdb0f3f4 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 27270
diff changeset
156 @code{expand-abbrev} also returns @code{nil}, as if expansion had not
f7b7fdb0f3f4 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 27270
diff changeset
157 really occurred.
42435
36047fca69b3 Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents: 27385
diff changeset
158
36047fca69b3 Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents: 27385
diff changeset
159 Normally the function @code{define-abbrev} sets the variable
36047fca69b3 Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents: 27385
diff changeset
160 @code{abbrevs-changed} to @code{t}. But if @var{system-flag} is
36047fca69b3 Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents: 27385
diff changeset
161 non-@code{nil}, that says the abbrev is a ``system'' abbrev. In that
36047fca69b3 Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents: 27385
diff changeset
162 case, @code{define-abbrev} does not alter @code{abbrevs-changed}.
36047fca69b3 Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents: 27385
diff changeset
163 Instead it marks the abbrev as a ``system'' abbrev with the
36047fca69b3 Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents: 27385
diff changeset
164 @code{system-type} property.
6552
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165 @end defun
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
166
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
167 @defopt only-global-abbrevs
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
168 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
169 global abbrevs only. This tells the commands that define mode-specific
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
170 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
171 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
172 callers.
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
173 @end defopt
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
174
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
175 @node Abbrev Files, Abbrev Expansion, Defining Abbrevs, Abbrevs
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
176 @section Saving Abbrevs in Files
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
177
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
178 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
179 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
180 abbrev tables with the same contents. Therefore, you can load the file
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
181 with @code{load} (@pxref{How Programs Do Loading}). However, the
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
182 function @code{quietly-read-abbrev-file} is provided as a more
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
183 convenient interface.
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
184
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
185 User-level facilities such as @code{save-some-buffers} can save
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
186 abbrevs in a file automatically, under the control of variables
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
187 described here.
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
188
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
189 @defopt abbrev-file-name
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
190 This is the default file name for reading and saving abbrevs.
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
191 @end defopt
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
192
26192
01d4feb7e1e4 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents: 25751
diff changeset
193 @defun quietly-read-abbrev-file &optional filename
6552
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
194 This function reads abbrev definitions from a file named @var{filename},
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
195 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
196 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
197 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
198 saved.
6552
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
199
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
200 This function does not display any messages. It returns @code{nil}.
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
201 @end defun
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
202
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
203 @defopt save-abbrevs
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
204 A non-@code{nil} value for @code{save-abbrev} means that Emacs should
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
205 save abbrevs when files are saved. @code{abbrev-file-name} specifies
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
206 the file to save the abbrevs in.
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
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
209 @defvar abbrevs-changed
42435
36047fca69b3 Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents: 27385
diff changeset
210 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
211 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
212 various Emacs commands to offer to save your abbrevs.
6552
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
213 @end defvar
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
214
26192
01d4feb7e1e4 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents: 25751
diff changeset
215 @deffn Command write-abbrev-file &optional filename
42435
36047fca69b3 Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents: 27385
diff changeset
216 Save all abbrev definitions (except ``system'' abbrevs), in all abbrev
36047fca69b3 Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents: 27385
diff changeset
217 tables, in the file @var{filename}, in the form of a Lisp program that
36047fca69b3 Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents: 27385
diff changeset
218 when loaded will define the same abbrevs. If @var{filename} is
36047fca69b3 Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents: 27385
diff changeset
219 @code{nil} or omitted, @code{abbrev-file-name} is used. This function
36047fca69b3 Explain about ``system'' abbrevs.
Richard M. Stallman <rms@gnu.org>
parents: 27385
diff changeset
220 returns @code{nil}.
6552
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
221 @end deffn
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
222
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
223 @node Abbrev Expansion, Standard Abbrev Tables, Abbrev Files, Abbrevs
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
224 @comment node-name, next, previous, up
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
225 @section Looking Up and Expanding Abbreviations
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
226
21007
66d807bdc5b4 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 7688
diff changeset
227 Abbrevs are usually expanded by certain interactive commands,
6552
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
228 including @code{self-insert-command}. This section describes the
21007
66d807bdc5b4 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 7688
diff changeset
229 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
230 use for communication.
6552
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
231
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
232 @defun abbrev-symbol abbrev &optional table
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
233 This function returns the symbol representing the abbrev named
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
234 @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
235 defined. The optional second argument @var{table} is the abbrev table
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
236 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
237 first the current buffer's local abbrev table, and second the global
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
238 abbrev table.
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
239 @end defun
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
240
7688
ab6b8aa5002e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 6552
diff changeset
241 @defun abbrev-expansion abbrev &optional table
ab6b8aa5002e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 6552
diff changeset
242 This function returns the string that @var{abbrev} would expand into (as
ab6b8aa5002e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 6552
diff changeset
243 defined by the abbrev tables used for the current buffer). The optional
ab6b8aa5002e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 6552
diff changeset
244 argument @var{table} specifies the abbrev table to use, as in
ab6b8aa5002e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 6552
diff changeset
245 @code{abbrev-symbol}.
ab6b8aa5002e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 6552
diff changeset
246 @end defun
ab6b8aa5002e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 6552
diff changeset
247
ab6b8aa5002e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 6552
diff changeset
248 @deffn Command expand-abbrev
26192
01d4feb7e1e4 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents: 25751
diff changeset
249 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
250 follow an abbrev, this command does nothing. The command returns the
01d4feb7e1e4 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents: 25751
diff changeset
251 abbrev symbol if it did expansion, @code{nil} otherwise.
27385
f7b7fdb0f3f4 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 27270
diff changeset
252
f7b7fdb0f3f4 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 27270
diff changeset
253 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
254 @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
255 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
256 returns @code{nil} even though expansion did occur.
7688
ab6b8aa5002e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 6552
diff changeset
257 @end deffn
ab6b8aa5002e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 6552
diff changeset
258
ab6b8aa5002e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 6552
diff changeset
259 @deffn Command abbrev-prefix-mark &optional arg
ab6b8aa5002e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 6552
diff changeset
260 Mark current point as the beginning of an abbrev. The next call to
ab6b8aa5002e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 6552
diff changeset
261 @code{expand-abbrev} will use the text from here to point (where it is
ab6b8aa5002e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 6552
diff changeset
262 then) as the abbrev to expand, rather than using the previous word as
ab6b8aa5002e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 6552
diff changeset
263 usual.
ab6b8aa5002e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 6552
diff changeset
264 @end deffn
ab6b8aa5002e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 6552
diff changeset
265
6552
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
266 @defopt abbrev-all-caps
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
267 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
268 case is expanded using all upper case. Otherwise, an abbrev entered
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
269 entirely in upper case is expanded by capitalizing each word of the
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
270 expansion.
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
271 @end defopt
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
272
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
273 @defvar abbrev-start-location
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
274 This is the buffer position for @code{expand-abbrev} to use as the start
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
275 of the next abbrev to be expanded. (@code{nil} means use the word
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
276 before point instead.) @code{abbrev-start-location} is set to
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
277 @code{nil} each time @code{expand-abbrev} is called. This variable is
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
278 also set by @code{abbrev-prefix-mark}.
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
279 @end defvar
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
280
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
281 @defvar abbrev-start-location-buffer
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
282 The value of this variable is the buffer for which
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
283 @code{abbrev-start-location} has been set. Trying to expand an abbrev
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
284 in any other buffer clears @code{abbrev-start-location}. This variable
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
285 is set by @code{abbrev-prefix-mark}.
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
286 @end defvar
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
287
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
288 @defvar last-abbrev
21007
66d807bdc5b4 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 7688
diff changeset
289 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
290 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
291 @code{unexpand-abbrev} command (@pxref{Expanding Abbrevs,, Expanding
66d807bdc5b4 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 7688
diff changeset
292 Abbrevs, emacs, The GNU Emacs Manual}).
6552
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
293 @end defvar
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
294
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
295 @defvar last-abbrev-location
21007
66d807bdc5b4 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 7688
diff changeset
296 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
297 information left by @code{expand-abbrev} for the sake of the
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
298 @code{unexpand-abbrev} command.
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
299 @end defvar
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
300
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
301 @defvar last-abbrev-text
21007
66d807bdc5b4 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 7688
diff changeset
302 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
303 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
304 has already been unexpanded. This contains information left by
66d807bdc5b4 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 7688
diff changeset
305 @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
306 @end defvar
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
307
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
308 @c Emacs 19 feature
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
309 @defvar pre-abbrev-expand-hook
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
310 This is a normal hook whose functions are executed, in sequence, just
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
311 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
312 hook, the hook functions receive no arguments. However, they can find
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
313 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
314 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
315 so a hook function can be used to change the current abbrev table before
01d4feb7e1e4 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents: 25751
diff changeset
316 abbrev lookup happens.
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 The following sample code shows a simple use of
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
320 @code{pre-abbrev-expand-hook}. If the user terminates an abbrev with a
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
321 punctuation character, the hook function asks for confirmation. Thus,
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
322 this hook allows the user to decide whether to expand the abbrev, and
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
323 aborts expansion if it is not confirmed.
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 @smallexample
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
326 (add-hook 'pre-abbrev-expand-hook 'query-if-not-space)
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
327
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
328 ;; @r{This is the function invoked by @code{pre-abbrev-expand-hook}.}
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
329
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
330 ;; @r{If the user terminated the abbrev with a space, the function does}
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
331 ;; @r{nothing (that is, it returns so that the abbrev can expand). If the}
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
332 ;; @r{user entered some other character, this function asks whether}
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
333 ;; @r{expansion should continue.}
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
334
7688
ab6b8aa5002e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 6552
diff changeset
335 ;; @r{If the user answers the prompt with @kbd{y}, the function returns}
6552
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
336 ;; @r{@code{nil} (because of the @code{not} function), but that is}
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
337 ;; @r{acceptable; the return value has no effect on expansion.}
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
338
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
339 (defun query-if-not-space ()
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
340 (if (/= ?\ (preceding-char))
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
341 (if (not (y-or-n-p "Do you want to expand this abbrev? "))
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
342 (error "Not expanding this abbrev"))))
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
343 @end smallexample
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
344
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
345 @node Standard Abbrev Tables, , Abbrev Expansion, Abbrevs
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
346 @comment node-name, next, previous, up
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
347 @section Standard Abbrev Tables
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
348
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
349 Here we list the variables that hold the abbrev tables for the
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
350 preloaded major modes of Emacs.
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
351
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
352 @defvar global-abbrev-table
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
353 This is the abbrev table for mode-independent abbrevs. The abbrevs
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
354 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
355 abbrev table, whose abbrev definitions take precedence over those in the
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
356 global table.
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
357 @end defvar
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
358
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
359 @defvar local-abbrev-table
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
360 The value of this buffer-local variable is the (mode-specific)
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
361 abbreviation table of the current buffer.
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
362 @end defvar
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
363
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
364 @defvar fundamental-mode-abbrev-table
7688
ab6b8aa5002e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 6552
diff changeset
365 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
366 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
367 @end defvar
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
368
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
369 @defvar text-mode-abbrev-table
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
370 This is the local abbrev table used in Text mode.
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
371 @end defvar
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
372
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
373 @defvar lisp-mode-abbrev-table
3b84ed22f747 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
374 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
375 @end defvar
26192
01d4feb7e1e4 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents: 25751
diff changeset
376