Mercurial > emacs
comparison man/autotype.texi @ 26463:2bf82b32f9f8
Fix makeinfo errors.
author | Dave Love <fx@gnu.org> |
---|---|
date | Tue, 16 Nov 1999 12:49:28 +0000 |
parents | 983ad33e1d97 |
children | 3f09d2029838 |
comparison
equal
deleted
inserted
replaced
26462:1ccde8678afd | 26463:2bf82b32f9f8 |
---|---|
95 | 95 |
96 When you want Emacs to insert a form letter or a typical construct of the | 96 When you want Emacs to insert a form letter or a typical construct of the |
97 programming language you are using, skeletons are a means of accomplishing | 97 programming language you are using, skeletons are a means of accomplishing |
98 this. Normally skeletons each have a command of their own, that, when called, | 98 this. Normally skeletons each have a command of their own, that, when called, |
99 will insert the skeleton. These commands can be issued in the usual ways | 99 will insert the skeleton. These commands can be issued in the usual ways |
100 (@xref{(emacs)Commands}). Modes that offer various skeletons will often | 100 (@pxref{(emacs)Commands}). Modes that offer various skeletons will often |
101 bind these to key-sequences on the @kbd{C-c} prefix, as well as having | 101 bind these to key-sequences on the @kbd{C-c} prefix, as well as having |
102 an @cite{Insert} menu and maybe even predefined abbrevs for them | 102 an @cite{Insert} menu and maybe even predefined abbrevs for them |
103 (@xref{Skeletons as Abbrevs}). | 103 (@pxref{Skeletons as Abbrevs}). |
104 | 104 |
105 The simplest kind of skeleton will simply insert some text indented | 105 The simplest kind of skeleton will simply insert some text indented |
106 according to the major mode and leave the cursor at a likely place in the | 106 according to the major mode and leave the cursor at a likely place in the |
107 middle. Interactive skeletons may prompt you for a string that will be part | 107 middle. Interactive skeletons may prompt you for a string that will be part |
108 of the inserted text. | 108 of the inserted text. |
127 put it in the middle of a form letter. Skeletons provide a means for | 127 put it in the middle of a form letter. Skeletons provide a means for |
128 accomplishing this, and can even, in the case of programming languages, | 128 accomplishing this, and can even, in the case of programming languages, |
129 reindent the wrapped code for you. | 129 reindent the wrapped code for you. |
130 | 130 |
131 Skeleton commands take an optional numeric prefix argument | 131 Skeleton commands take an optional numeric prefix argument |
132 (@xref{(emacs)Arguments}). This is interpreted in two different ways depending | 132 (@pxref{(emacs)Arguments}). This is interpreted in two different ways depending |
133 on whether the prefix is positive, i.e. forwards oriented or negative, | 133 on whether the prefix is positive, i.e. forwards oriented or negative, |
134 i.e. backwards oriented. | 134 i.e. backwards oriented. |
135 | 135 |
136 A positive prefix means to wrap the skeleton around that many | 136 A positive prefix means to wrap the skeleton around that many |
137 following words. This is accomplished by putting the words there where | 137 following words. This is accomplished by putting the words there where |
138 the point is normally left after that skeleton is inserted (@xref{Using | 138 the point is normally left after that skeleton is inserted (@pxref{Using |
139 Skeletons}). The point (@xref{(emacs)Point}) is left at the next | 139 Skeletons}). The point (@pxref{(emacs)Point}) is left at the next |
140 interesting spot in the skeleton instead. | 140 interesting spot in the skeleton instead. |
141 | 141 |
142 A negative prefix means to do something similar with that many precedingly | 142 A negative prefix means to do something similar with that many precedingly |
143 marked interregions (@xref{(emacs)Mark}). In the simplest case, if you type | 143 marked interregions (@pxref{(emacs)Mark}). In the simplest case, if you type |
144 @kbd{M--} just before issuing the skeleton command, that will wrap the | 144 @kbd{M--} just before issuing the skeleton command, that will wrap the |
145 skeleton around the current region, just like a positive argument would have | 145 skeleton around the current region, just like a positive argument would have |
146 wrapped it around a number of words. | 146 wrapped it around a number of words. |
147 | 147 |
148 Smaller negative arguments will wrap that many interregions into successive | 148 Smaller negative arguments will wrap that many interregions into successive |
170 @node Skeletons as Abbrevs | 170 @node Skeletons as Abbrevs |
171 @chapter Skeletons as Abbrev Expansions | 171 @chapter Skeletons as Abbrev Expansions |
172 @cindex skeletons as abbrevs | 172 @cindex skeletons as abbrevs |
173 | 173 |
174 Rather than use a keybinding for every skeleton command, you can also | 174 Rather than use a keybinding for every skeleton command, you can also |
175 define an abbreviation (@xref{(emacs)Defining Abbrevs}) that will expand | 175 define an abbreviation (@pxref{(emacs)Defining Abbrevs}) that will expand |
176 (@xref{(emacs)Expanding Abbrevs}) into the skeleton. | 176 (@pxref{(emacs)Expanding Abbrevs}) into the skeleton. |
177 | 177 |
178 Say you want @samp{ifst} to be an abbreviation for the C language if | 178 Say you want @samp{ifst} to be an abbreviation for the C language if |
179 statement. You will tell Emacs that @samp{ifst} expands to the empty string | 179 statement. You will tell Emacs that @samp{ifst} expands to the empty string |
180 and then calls the skeleton command. In Emacs-lisp you can say something like | 180 and then calls the skeleton command. In Emacs-lisp you can say something like |
181 @code{(define-abbrev c-mode-abbrev-table "ifst" "" 'c-if)}. Or you can edit | 181 @code{(define-abbrev c-mode-abbrev-table "ifst" "" 'c-if)}. Or you can edit |
270 The macro @code{define-skeleton} defines a command for interpreting a | 270 The macro @code{define-skeleton} defines a command for interpreting a |
271 skeleton. The first argument is the command name, the second is a | 271 skeleton. The first argument is the command name, the second is a |
272 documentation string, and the rest is an interactor and any number of skeleton | 272 documentation string, and the rest is an interactor and any number of skeleton |
273 elements together forming a skeleton. This skeleton is assigned to a variable | 273 elements together forming a skeleton. This skeleton is assigned to a variable |
274 of the same name as the command and can thus be overridden from your | 274 of the same name as the command and can thus be overridden from your |
275 @file{~/.emacs} file (@xref{(emacs)Init File}). | 275 @file{~/.emacs} file (@pxref{(emacs)Init File}). |
276 | 276 |
277 | 277 |
278 | 278 |
279 @node Inserting Pairs | 279 @node Inserting Pairs |
280 @chapter Inserting Matching Pairs of Characters | 280 @chapter Inserting Matching Pairs of Characters |
289 typing some of the stranger programming language symbols makes you bend your | 289 typing some of the stranger programming language symbols makes you bend your |
290 fingers backwards, this can be quite relieving too. | 290 fingers backwards, this can be quite relieving too. |
291 | 291 |
292 @findex pair-insert-maybe | 292 @findex pair-insert-maybe |
293 @vindex pair | 293 @vindex pair |
294 This is done by binding the first key (@xref{(emacs)Rebinding}) of the | 294 This is done by binding the first key (@pxref{(emacs)Rebinding}) of the |
295 pair to @code{pair-insert-maybe} instead of @code{self-insert-command}. | 295 pair to @code{pair-insert-maybe} instead of @code{self-insert-command}. |
296 The maybe comes from the fact that this at first surprising behaviour is | 296 The maybe comes from the fact that this at first surprising behaviour is |
297 initially turned off. To enable it, you must set @code{pair} to some | 297 initially turned off. To enable it, you must set @code{pair} to some |
298 non-@code{nil} value. And even then, a positive argument | 298 non-@code{nil} value. And even then, a positive argument |
299 (@xref{(emacs)Arguments}) will make this key behave like a self | 299 (@pxref{(emacs)Arguments}) will make this key behave like a self |
300 inserting key (@xref{(emacs)Inserting Text}). | 300 inserting key (@pxref{(emacs)Inserting Text}). |
301 | 301 |
302 @findex pair-on-word | 302 @findex pair-on-word |
303 While this breaks with the stated intention of always balancing pairs, it | 303 While this breaks with the stated intention of always balancing pairs, it |
304 turns out that one often doesn't want pairing to occur, when the following | 304 turns out that one often doesn't want pairing to occur, when the following |
305 character is part of a word. If you want pairing to occur even then, set | 305 character is part of a word. If you want pairing to occur even then, set |
309 Pairing is possible for all visible characters. By default the parenthesis | 309 Pairing is possible for all visible characters. By default the parenthesis |
310 `(', the square bracket `[', the brace `@{', the pointed bracket `<' and the | 310 `(', the square bracket `[', the brace `@{', the pointed bracket `<' and the |
311 backquote ``' will all pair to the symmetrical character. All other | 311 backquote ``' will all pair to the symmetrical character. All other |
312 characters will pair themselves. This behaviour can be modified by the | 312 characters will pair themselves. This behaviour can be modified by the |
313 variable @code{pair-alist}. This is in fact an alist of skeletons | 313 variable @code{pair-alist}. This is in fact an alist of skeletons |
314 (@xref{Skeleton Language}), with the first part of each sublist matching the | 314 (@pxref{Skeleton Language}), with the first part of each sublist matching the |
315 typed character. This is the position of the interactor, but since pairs | 315 typed character. This is the position of the interactor, but since pairs |
316 don't need the @code{str} element, this is ignored. | 316 don't need the @code{str} element, this is ignored. |
317 | 317 |
318 Some modes have bound the command @code{pair-insert-maybe} to relevant keys. | 318 Some modes have bound the command @code{pair-insert-maybe} to relevant keys. |
319 These modes also configure the pairs as appropriate. For example, when typing | 319 These modes also configure the pairs as appropriate. For example, when typing |
331 @kbd{M-x auto-insert} will put some predefined text at the beginning of | 331 @kbd{M-x auto-insert} will put some predefined text at the beginning of |
332 the buffer. The main application for this function, as its name suggests, | 332 the buffer. The main application for this function, as its name suggests, |
333 is to have it be called automatically every time an empty, and only an | 333 is to have it be called automatically every time an empty, and only an |
334 empty file is visited. This is accomplished by putting @code{(add-hook | 334 empty file is visited. This is accomplished by putting @code{(add-hook |
335 'find-file-hooks 'auto-insert)} into your @file{~/.emacs} file | 335 'find-file-hooks 'auto-insert)} into your @file{~/.emacs} file |
336 (@xref{(emacs)Init File}). | 336 (@pxref{(emacs)Init File}). |
337 | 337 |
338 @vindex auto-insert-alist | 338 @vindex auto-insert-alist |
339 What gets inserted, if anything, is determined by the variable | 339 What gets inserted, if anything, is determined by the variable |
340 @code{auto-insert-alist}. The @code{car}s of this list are each either a mode | 340 @code{auto-insert-alist}. The @code{car}s of this list are each either a mode |
341 name, making an element applicable when a buffer is in that mode. Or they | 341 name, making an element applicable when a buffer is in that mode. Or they |
345 mode name or regexp as above and an additional descriptive string. | 345 mode name or regexp as above and an additional descriptive string. |
346 | 346 |
347 When a matching element is found, the @code{cdr} says what to do. It may | 347 When a matching element is found, the @code{cdr} says what to do. It may |
348 be a string, which is a file name, whose contents are to be inserted, if | 348 be a string, which is a file name, whose contents are to be inserted, if |
349 that file is found in the directory @code{auto-insert-directory} or under a | 349 that file is found in the directory @code{auto-insert-directory} or under a |
350 absolute file name. Or it can be a skeleton (@xref{Skeleton Language}) to | 350 absolute file name. Or it can be a skeleton (@pxref{Skeleton Language}) to |
351 be inserted. | 351 be inserted. |
352 | 352 |
353 It can also be a function, which allows doing various things. The function | 353 It can also be a function, which allows doing various things. The function |
354 can simply insert some text, indeed, it can be skeleton command (@xref{Using | 354 can simply insert some text, indeed, it can be skeleton command (@pxref{Using |
355 Skeletons}). It can be a lambda function which will for example conditionally | 355 Skeletons}). It can be a lambda function which will for example conditionally |
356 call another function. Or it can even reset the mode for the buffer. If you | 356 call another function. Or it can even reset the mode for the buffer. If you |
357 want to perform several such actions in order, you use a vector, i.e. several | 357 want to perform several such actions in order, you use a vector, i.e. several |
358 of the above elements between square brackets ([...]). | 358 of the above elements between square brackets ([...]). |
359 | 359 |
367 | 367 |
368 Ada mode files call the Ada header skeleton command. Emacs lisp source | 368 Ada mode files call the Ada header skeleton command. Emacs lisp source |
369 files insert the usual header, with a copyright of your environment variable | 369 files insert the usual header, with a copyright of your environment variable |
370 @code{$ORGANIZATION} or else the FSF, and prompt for valid keywords describing | 370 @code{$ORGANIZATION} or else the FSF, and prompt for valid keywords describing |
371 the contents. Files in a @code{bin/} directory for which Emacs could | 371 the contents. Files in a @code{bin/} directory for which Emacs could |
372 determine no specialised mode (@xref{(emacs)Choosing Modes}) are set to Shell script | 372 determine no specialised mode (@pxref{(emacs)Choosing Modes}) are set to Shell script |
373 mode. | 373 mode. |
374 | 374 |
375 @findex define-auto-insert | 375 @findex define-auto-insert |
376 In Lisp (@xref{(emacs)Init File}) you can use the function @code{define-auto-insert} | 376 In Lisp (@pxref{(emacs)Init File}) you can use the function @code{define-auto-insert} |
377 to add to or modify @code{auto-insert-alist}. See its documentation with | 377 to add to or modify @code{auto-insert-alist}. See its documentation with |
378 @kbd{C-h f auto-insert-alist}. | 378 @kbd{C-h f auto-insert-alist}. |
379 | 379 |
380 @vindex auto-insert | 380 @vindex auto-insert |
381 The variable @code{auto-insert} says what to do when @code{auto-insert} is | 381 The variable @code{auto-insert} says what to do when @code{auto-insert} is |
413 | 413 |
414 @findex copyright | 414 @findex copyright |
415 @kbd{M-x copyright} is a skeleton inserting command, that adds a copyright | 415 @kbd{M-x copyright} is a skeleton inserting command, that adds a copyright |
416 notice at the point. The ``by'' part is taken from your environment variable | 416 notice at the point. The ``by'' part is taken from your environment variable |
417 @code{$ORGANIZATION} or if that isn't set you are prompted for it. If the | 417 @code{$ORGANIZATION} or if that isn't set you are prompted for it. If the |
418 buffer has a comment syntax (@xref{(emacs)Comments}), this is inserted as a comment. | 418 buffer has a comment syntax (@pxref{(emacs)Comments}), this is inserted as a comment. |
419 | 419 |
420 @findex copyright-update | 420 @findex copyright-update |
421 @vindex copyright-limit | 421 @vindex copyright-limit |
422 @vindex copyright-current-year | 422 @vindex copyright-current-year |
423 @kbd{M-x copyright-update} looks for a copyright notice in the first | 423 @kbd{M-x copyright-update} looks for a copyright notice in the first |
425 The current year (variable @code{copyright-current-year}) is added to the | 425 The current year (variable @code{copyright-current-year}) is added to the |
426 existing ones, in the same format as the preceding year, i.e. 1994, '94 or 94. | 426 existing ones, in the same format as the preceding year, i.e. 1994, '94 or 94. |
427 If a dash-separated year list up to last year is found, that is extended to | 427 If a dash-separated year list up to last year is found, that is extended to |
428 current year, else the year is added separated by a comma. Or it replaces | 428 current year, else the year is added separated by a comma. Or it replaces |
429 them when this is called with a prefix argument. If a header referring to a | 429 them when this is called with a prefix argument. If a header referring to a |
430 wrong version of the GNU General Public License (@xref{(emacs)Copying}) is found, | 430 wrong version of the GNU General Public License (@pxref{(emacs)Copying}) is found, |
431 that is updated too. | 431 that is updated too. |
432 | 432 |
433 An interesting application for this function is to have it be called | 433 An interesting application for this function is to have it be called |
434 automatically every time a file is saved. This is accomplished by putting | 434 automatically every time a file is saved. This is accomplished by putting |
435 @code{(add-hook 'write-file-hooks 'copyright-update)} into your @file{~/.emacs} | 435 @code{(add-hook 'write-file-hooks 'copyright-update)} into your @file{~/.emacs} |
436 file (@xref{(emacs)Init File}). | 436 file (@pxref{(emacs)Init File}). |
437 | 437 |
438 @vindex copyright-query | 438 @vindex copyright-query |
439 The variable @code{copyright-query} controls whether to update the | 439 The variable @code{copyright-query} controls whether to update the |
440 copyright or whether to ask about it. When this is @code{nil} updating is | 440 copyright or whether to ask about it. When this is @code{nil} updating is |
441 only done with @kbd{M-x copyright-update}. When this is @code{'function} | 441 only done with @kbd{M-x copyright-update}. When this is @code{'function} |