annotate doc/lispref/abbrevs.texi @ 85732:f62dcdb06cab

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