comparison lispref/abbrevs.texi @ 7688:ab6b8aa5002e

entered into RCS
author Richard M. Stallman <rms@gnu.org>
date Thu, 26 May 1994 05:45:30 +0000
parents 3b84ed22f747
children 66d807bdc5b4
comparison
equal deleted inserted replaced
7687:6447f9b3c966 7688:ab6b8aa5002e
17 table}. Each buffer has a local abbrev table, but normally all buffers 17 table}. Each buffer has a local abbrev table, but normally all buffers
18 in the same major mode share one abbrev table. There is also a global 18 in the same major mode share one abbrev table. There is also a global
19 abbrev table. Normally both are used. 19 abbrev table. Normally both are used.
20 20
21 An abbrev table is represented as an obarray containing a symbol for 21 An abbrev table is represented as an obarray containing a symbol for
22 each abbreviation. The symbol's name is the abbreviation. Its value is 22 each abbreviation. The symbol's name is the abbreviation; its value is
23 the expansion; its function definition is the hook function to do the 23 the expansion; its function definition is the hook function to do the
24 expansion (if any); its property list cell contains the use count, the 24 expansion (@pxref{Defining Abbrevs}); its property list cell contains
25 number of times the abbreviation has been expanded. Because these 25 the use count, the number of times the abbreviation has been expanded.
26 symbols are not interned in the usual obarray, they will never appear as 26 Because these symbols are not interned in the usual obarray, they will
27 the result of reading a Lisp expression; in fact, normally they are 27 never appear as the result of reading a Lisp expression; in fact,
28 never used except by the code that handles abbrevs. Therefore, it is 28 normally they are never used except by the code that handles abbrevs.
29 safe to use them in an extremely nonstandard way. @xref{Creating 29 Therefore, it is safe to use them in an extremely nonstandard way.
30 Symbols}. 30 @xref{Creating Symbols}.
31 31
32 For the user-level commands for abbrevs, see @ref{Abbrevs,, Abbrev 32 For the user-level commands for abbrevs, see @ref{Abbrevs,, Abbrev
33 Mode, emacs, The GNU Emacs Manual}. 33 Mode, emacs, The GNU Emacs Manual}.
34 34
35 @menu 35 @menu
56 56
57 This variable automatically becomes local when set in any fashion. 57 This variable automatically becomes local when set in any fashion.
58 @end defvar 58 @end defvar
59 59
60 @defvar default-abbrev-mode 60 @defvar default-abbrev-mode
61 This is the value @code{abbrev-mode} for buffers that do not override it. 61 This is the value of @code{abbrev-mode} for buffers that do not override it.
62 This is the same as @code{(default-value 'abbrev-mode)}. 62 This is the same as @code{(default-value 'abbrev-mode)}.
63 @end defvar 63 @end defvar
64 64
65 @node Abbrev Tables, Defining Abbrevs, Abbrev Mode, Abbrevs 65 @node Abbrev Tables, Defining Abbrevs, Abbrev Mode, Abbrevs
66 @section Abbrev Tables 66 @section Abbrev Tables
95 named @var{name}. The argument @var{name} is a symbol whose value is an 95 named @var{name}. The argument @var{name} is a symbol whose value is an
96 abbrev table. The value is always @code{nil}. 96 abbrev table. The value is always @code{nil}.
97 97
98 If @var{human} is non-@code{nil}, the description is human-oriented. 98 If @var{human} is non-@code{nil}, the description is human-oriented.
99 Otherwise the description is a Lisp expression---a call to 99 Otherwise the description is a Lisp expression---a call to
100 @code{define-abbrev-table} which would define @var{name} exactly as it 100 @code{define-abbrev-table} that would define @var{name} exactly as it
101 is currently defined. 101 is currently defined.
102 @end defun 102 @end defun
103 103
104 @node Defining Abbrevs, Abbrev Files, Abbrev Tables, Abbrevs 104 @node Defining Abbrevs, Abbrev Files, Abbrev Tables, Abbrevs
105 @comment node-name, next, previous, up 105 @comment node-name, next, previous, up
109 @code{define-abbrev} is the low-level basic function, while 109 @code{define-abbrev} is the low-level basic function, while
110 @code{add-abbrev} is used by commands that ask for information from the 110 @code{add-abbrev} is used by commands that ask for information from the
111 user. 111 user.
112 112
113 @defun add-abbrev table type arg 113 @defun add-abbrev table type arg
114 This function adds an abbreviation to abbrev table @var{table}. The 114 This function adds an abbreviation to abbrev table @var{table} based on
115 argument @var{type} is a string describing in English the kind of abbrev 115 information from the user. The argument @var{type} is a string
116 this will be (typically, @code{"global"} or @code{"mode-specific"}); 116 describing in English the kind of abbrev this will be (typically,
117 this is used in prompting the user. The argument @var{arg} is the 117 @code{"global"} or @code{"mode-specific"}); this is used in prompting
118 number of words in the expansion. 118 the user. The argument @var{arg} is the number of words in the
119 119 expansion.
120 The return value is the symbol which internally represents the new 120
121 The return value is the symbol that internally represents the new
121 abbrev, or @code{nil} if the user declines to confirm redefining an 122 abbrev, or @code{nil} if the user declines to confirm redefining an
122 existing abbrev. 123 existing abbrev.
123 @end defun 124 @end defun
124 125
125 @defun define-abbrev table name expansion hook 126 @defun define-abbrev table name expansion hook
126 This function defines an abbrev in @var{table} named @var{name}, to 127 This function defines an abbrev in @var{table} named @var{name}, to
127 expand to @var{expansion}, and call @var{hook}. The return value is an 128 expand to @var{expansion}, and call @var{hook}. The return value is an
128 uninterned symbol which represents the abbrev inside Emacs; its name is 129 uninterned symbol that represents the abbrev inside Emacs; its name is
129 @var{name}. 130 @var{name}.
130 131
131 The argument @var{name} should be a string. The argument 132 The argument @var{name} should be a string. The argument
132 @var{expansion} should be a string, or @code{nil}, to undefine the 133 @var{expansion} should be a string, or @code{nil} to undefine the
133 abbrev. 134 abbrev.
134 135
135 The argument @var{hook} is a function or @code{nil}. If @var{hook} is 136 The argument @var{hook} is a function or @code{nil}. If @var{hook} is
136 non-@code{nil}, then it is called with no arguments after the abbrev is 137 non-@code{nil}, then it is called with no arguments after the abbrev is
137 replaced with @var{expansion}; point is located at the end of 138 replaced with @var{expansion}; point is located at the end of
138 @var{expansion}. 139 @var{expansion} when @var{hook} is called.
139 140
140 The use count of the abbrev is initialized to zero. 141 The use count of the abbrev is initialized to zero.
141 @end defun 142 @end defun
142 143
143 @defopt only-global-abbrevs 144 @defopt only-global-abbrevs
144 If this variable is non-@code{nil}, it means that the user plans to use 145 If this variable is non-@code{nil}, it means that the user plans to use
145 global abbrevs only. This tells the commands that define mode-specific 146 global abbrevs only. This tells the commands that define mode-specific
146 abbrevs to define global ones instead. This variable does not alter the 147 abbrevs to define global ones instead. This variable does not alter the
147 functioning of the functions in this section; it is examined by their 148 behavior of the functions in this section; it is examined by their
148 callers. 149 callers.
149 @end defopt 150 @end defopt
150 151
151 @node Abbrev Files, Abbrev Expansion, Defining Abbrevs, Abbrevs 152 @node Abbrev Files, Abbrev Expansion, Defining Abbrevs, Abbrevs
152 @section Saving Abbrevs in Files 153 @section Saving Abbrevs in Files
187 save your abbrevs. 188 save your abbrevs.
188 @end defvar 189 @end defvar
189 190
190 @deffn Command write-abbrev-file filename 191 @deffn Command write-abbrev-file filename
191 Save all abbrev definitions, in all abbrev tables, in the file 192 Save all abbrev definitions, in all abbrev tables, in the file
192 @var{filename}, in the form of a Lisp program which when loaded will 193 @var{filename}, in the form of a Lisp program that when loaded will
193 define the same abbrevs. This function returns @code{nil}. 194 define the same abbrevs. This function returns @code{nil}.
194 @end deffn 195 @end deffn
195 196
196 @node Abbrev Expansion, Standard Abbrev Tables, Abbrev Files, Abbrevs 197 @node Abbrev Expansion, Standard Abbrev Tables, Abbrev Files, Abbrevs
197 @comment node-name, next, previous, up 198 @comment node-name, next, previous, up
209 to look it up in. If @var{table} is @code{nil}, this function tries 210 to look it up in. If @var{table} is @code{nil}, this function tries
210 first the current buffer's local abbrev table, and second the global 211 first the current buffer's local abbrev table, and second the global
211 abbrev table. 212 abbrev table.
212 @end defun 213 @end defun
213 214
215 @defun abbrev-expansion abbrev &optional table
216 This function returns the string that @var{abbrev} would expand into (as
217 defined by the abbrev tables used for the current buffer). The optional
218 argument @var{table} specifies the abbrev table to use, as in
219 @code{abbrev-symbol}.
220 @end defun
221
222 @deffn Command expand-abbrev
223 This command expands the abbrev before point, if any.
224 If point does not follow an abbrev, this command does nothing.
225 The command returns @code{t} if it did expansion, @code{nil} otherwise.
226 @end deffn
227
228 @deffn Command abbrev-prefix-mark &optional arg
229 Mark current point as the beginning of an abbrev. The next call to
230 @code{expand-abbrev} will use the text from here to point (where it is
231 then) as the abbrev to expand, rather than using the previous word as
232 usual.
233 @end deffn
234
214 @defopt abbrev-all-caps 235 @defopt abbrev-all-caps
215 When this is set non-@code{nil}, an abbrev entered entirely in upper 236 When this is set non-@code{nil}, an abbrev entered entirely in upper
216 case is expanded using all upper case. Otherwise, an abbrev entered 237 case is expanded using all upper case. Otherwise, an abbrev entered
217 entirely in upper case is expanded by capitalizing each word of the 238 entirely in upper case is expanded by capitalizing each word of the
218 expansion. 239 expansion.
219 @end defopt 240 @end defopt
220 241
221 @defun abbrev-expansion abbrev &optional table
222 This function returns the string that @var{abbrev} would expand into (as
223 defined by the abbrev tables used for the current buffer). The optional
224 argument @var{table} specifies the abbrev table to use; if it is
225 specified, the abbrev is looked up in that table only.
226 @end defun
227
228 @defvar abbrev-start-location 242 @defvar abbrev-start-location
229 This is the buffer position for @code{expand-abbrev} to use as the start 243 This is the buffer position for @code{expand-abbrev} to use as the start
230 of the next abbrev to be expanded. (@code{nil} means use the word 244 of the next abbrev to be expanded. (@code{nil} means use the word
231 before point instead.) @code{abbrev-start-location} is set to 245 before point instead.) @code{abbrev-start-location} is set to
232 @code{nil} each time @code{expand-abbrev} is called. This variable is 246 @code{nil} each time @code{expand-abbrev} is called. This variable is
251 information left by @code{expand-abbrev} for the sake of the 265 information left by @code{expand-abbrev} for the sake of the
252 @code{unexpand-abbrev} command. 266 @code{unexpand-abbrev} command.
253 @end defvar 267 @end defvar
254 268
255 @defvar last-abbrev-text 269 @defvar last-abbrev-text
256 This is the exact expansion text of the last abbrev expanded, as 270 This is the exact expansion text of the last abbrev expanded, after case
257 results from case conversion. Its value is 271 conversion (if any). Its value is @code{nil} if the abbrev has already
258 @code{nil} if the abbrev has already been unexpanded. This 272 been unexpanded. This contains information left by @code{expand-abbrev}
259 contains information left by @code{expand-abbrev} for the sake of the 273 for the sake of the @code{unexpand-abbrev} command.
260 @code{unexpand-abbrev} command.
261 @end defvar 274 @end defvar
262 275
263 @c Emacs 19 feature 276 @c Emacs 19 feature
264 @defvar pre-abbrev-expand-hook 277 @defvar pre-abbrev-expand-hook
265 This is a normal hook whose functions are executed, in sequence, just 278 This is a normal hook whose functions are executed, in sequence, just
282 ;; @r{If the user terminated the abbrev with a space, the function does} 295 ;; @r{If the user terminated the abbrev with a space, the function does}
283 ;; @r{nothing (that is, it returns so that the abbrev can expand). If the} 296 ;; @r{nothing (that is, it returns so that the abbrev can expand). If the}
284 ;; @r{user entered some other character, this function asks whether} 297 ;; @r{user entered some other character, this function asks whether}
285 ;; @r{expansion should continue.} 298 ;; @r{expansion should continue.}
286 299
287 ;; @r{If the user enters the prompt with @kbd{y}, the function returns} 300 ;; @r{If the user answers the prompt with @kbd{y}, the function returns}
288 ;; @r{@code{nil} (because of the @code{not} function), but that is} 301 ;; @r{@code{nil} (because of the @code{not} function), but that is}
289 ;; @r{acceptable; the return value has no effect on expansion.} 302 ;; @r{acceptable; the return value has no effect on expansion.}
290 303
291 (defun query-if-not-space () 304 (defun query-if-not-space ()
292 (if (/= ?\ (preceding-char)) 305 (if (/= ?\ (preceding-char))
312 The value of this buffer-local variable is the (mode-specific) 325 The value of this buffer-local variable is the (mode-specific)
313 abbreviation table of the current buffer. 326 abbreviation table of the current buffer.
314 @end defvar 327 @end defvar
315 328
316 @defvar fundamental-mode-abbrev-table 329 @defvar fundamental-mode-abbrev-table
317 This is the local abbrev table used in Fundamental mode. It is the 330 This is the local abbrev table used in Fundamental mode; in other words,
318 local abbrev table in all buffers in Fundamental mode. 331 it is the local abbrev table in all buffers in Fundamental mode.
319 @end defvar 332 @end defvar
320 333
321 @defvar text-mode-abbrev-table 334 @defvar text-mode-abbrev-table
322 This is the local abbrev table used in Text mode. 335 This is the local abbrev table used in Text mode.
323 @end defvar 336 @end defvar