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