Merge from trunk and resolve conflicts.
[bpt/emacs.git] / doc / misc / autotype.texi
1 \input texinfo
2 @c This is an annex of the Emacs manual.
3 @c Author: Daniel.Pfeiffer@Informatik.START.dbp.de, fax (+49 69) 7588-2389
4 @setfilename ../../info/autotype
5 @c @node Autotypist, Picture, Abbrevs, Top
6 @c @chapter Features for Automatic Typing
7 @settitle Features for Automatic Typing
8 @c @cindex text
9 @c @cindex selfinserting text
10 @c @cindex autotypist
11
12 @copying
13 Copyright @copyright{} 1994--1995, 1999, 2001--2013
14 Free Software Foundation, Inc.
15
16 @quotation
17 Permission is granted to copy, distribute and/or modify this document
18 under the terms of the GNU Free Documentation License, Version 1.3 or
19 any later version published by the Free Software Foundation; with no
20 Invariant Sections, with the Front-Cover texts being ``A GNU Manual'',
21 and with the Back-Cover Texts as in (a) below. A copy of the license
22 is included in the section entitled ``GNU Free Documentation License''.
23
24 (a) The FSF's Back-Cover Text is: ``You have the freedom to copy and
25 modify this GNU manual.''
26 @end quotation
27 @end copying
28
29 @dircategory Emacs misc features
30 @direntry
31 * Autotype: (autotype). Convenient features for text that you
32 enter frequently in Emacs.
33 @end direntry
34
35 @titlepage
36 @sp 10
37
38 @center @titlefont{Autotyping}
39 @sp 2
40 @center Convenient features for text that you enter frequently in Emacs
41 @sp 2
42 @center Daniel Pfeiffer
43 @center additions by Dave Love
44
45 @page
46 @vskip 0pt plus 1filll
47 @insertcopying
48 @end titlepage
49
50 @contents
51
52 @node Top
53 @top Autotyping
54
55 Under certain circumstances you will find yourself typing similar things
56 over and over again. This is especially true of form letters and programming
57 language constructs. Project-specific header comments, flow-control
58 constructs or magic numbers are essentially the same every time. Emacs has
59 various features for doing tedious and repetitive typing chores for you
60 in addition to the Abbrev features (@pxref{Abbrevs,,, emacs, The GNU Emacs Manual}).
61
62 One solution is using skeletons, flexible rules that say what to
63 insert, and how to do it. Various programming language modes offer some
64 ready-to-use skeletons, and you can adapt them to suit your needs or
65 taste, or define new ones.
66
67 Another feature is automatic insertion of what you want into empty files,
68 depending on the file-name or the mode as appropriate. You can have a file or
69 a skeleton inserted, or you can call a function. Then there is the
70 possibility to have Un*x interpreter scripts automatically take on a magic
71 number and be executable as soon as they are saved. Or you can have a
72 copyright notice's year updated, if necessary, every time you save a
73 file. Similarly for time stamps in the file.
74
75 URLs can be inserted based on a word at point. Flexible templates can
76 be defined for inserting and navigating between text more generally. A
77 sort of meta-expansion facility can be used to try a set of alternative
78 completions and expansions of text at point.
79
80 @ifnottex
81 @insertcopying
82 @end ifnottex
83
84 @menu
85 * Using Skeletons:: How to insert a skeleton into your text.
86 * Wrapping Skeletons:: Putting existing text within a skeleton.
87 * Skeletons as Abbrevs:: An alternative for issuing skeleton commands.
88 * Skeleton Language:: Making skeleton commands insert what you want.
89 * Inserting Pairs:: Typing one character and getting another
90 after point.
91 * Autoinserting:: Filling up empty files as soon as you visit them.
92 * Copyrights:: Inserting and updating copyrights.
93 * Executables:: Turning interpreter scripts into executables.
94 * Timestamps:: Updating dates and times in modified files.
95 * QuickURL:: Inserting URLs based on text at point.
96 * Tempo:: Flexible template insertion.
97 * Hippie Expand:: Expansion of text trying various methods.
98
99 * GNU Free Documentation License:: The license for this documentation.
100 * Concept Index::
101 * Command Index::
102 * Variable Index::
103 @end menu
104
105
106 @node Using Skeletons
107 @chapter Using Skeletons
108 @cindex skeletons
109 @cindex using skeletons
110
111 When you want Emacs to insert a form letter or a typical construct of the
112 programming language you are using, skeletons are a means of accomplishing
113 this. Normally skeletons each have a command of their own, that, when called,
114 will insert the skeleton. These commands can be issued in the usual ways
115 (@pxref{Commands,,, emacs, The GNU Emacs Manual}). Modes that offer various skeletons will often
116 bind these to key-sequences on the @kbd{C-c} prefix, as well as having
117 an @cite{Insert} menu and maybe even predefined abbrevs for them
118 (@pxref{Skeletons as Abbrevs}).
119
120 The simplest kind of skeleton will simply insert some text indented
121 according to the major mode and leave the cursor at a likely place in the
122 middle. Interactive skeletons may prompt you for a string that will be part
123 of the inserted text.
124
125 Skeletons may ask for input several times. They even have a looping
126 mechanism in which you will be asked for input as long as you are willing to
127 furnish it. An example would be multiple ``else if'' conditions. You can
128 recognize this situation by a prompt ending in @key{RET}, @kbd{C-g}
129 or @kbd{C-h}. This
130 means that entering an empty string will simply assume that you are finished.
131 Typing quit on the other hand terminates the loop but also the rest of the
132 skeleton, e.g., an ``else'' clause is skipped. Only a syntactically necessary
133 termination still gets inserted.
134
135
136
137 @node Wrapping Skeletons
138 @chapter Wrapping Skeletons Around Existing Text
139 @cindex wrapping skeletons
140
141 Often you will find yourself with some code that for whatever reason
142 suddenly becomes conditional. Or you have written a bit of text and want to
143 put it in the middle of a form letter. Skeletons provide a means for
144 accomplishing this, and can even, in the case of programming languages,
145 reindent the wrapped code for you.
146
147 Skeleton commands take an optional numeric prefix argument
148 (@pxref{Arguments,,, emacs, The GNU Emacs Manual}). This is interpreted in two different ways depending
149 on whether the prefix is positive, i.e., forwards oriented, or negative,
150 i.e., backwards oriented.
151
152 A positive prefix means to wrap the skeleton around that many
153 following words. This is accomplished by putting the words there where
154 the point is normally left after that skeleton is inserted (@pxref{Using
155 Skeletons}). The point (@pxref{Point,,, emacs, The GNU Emacs Manual}) is left at the next
156 interesting spot in the skeleton instead.
157
158 A negative prefix means to do something similar with that many previously
159 marked interregions (@pxref{Mark,,, emacs, The GNU Emacs Manual}). In the simplest case, if you type
160 @kbd{M--} just before issuing the skeleton command, that will wrap the
161 skeleton around the current region, just like a positive argument would have
162 wrapped it around a number of words.
163
164 Smaller negative arguments will wrap that many interregions into successive
165 interesting spots within the skeleton, again leaving the point at the next one.
166 We speak about interregions rather than regions here, because we treat them in
167 the order they appear in the buffer, which coincides with successive regions
168 only if they were marked in order.
169
170 That is, if you marked in alphabetical order the points A B C [] (where []
171 represents the point) and call a skeleton command with @kbd{M-- 3}, you will
172 wrap the text from A to B into the first interesting spot of the skeleton, the
173 text from B to C into the next one, the text from C to the point into the
174 third one, and leave the point in the fourth one. If there are less marks in
175 the buffer, or if the skeleton defines less interesting points, the surplus is
176 ignored.
177
178 If, on the other hand, you marked in alphabetical order the points [] A C B,
179 and call a skeleton command with @kbd{M-- 3}, you will wrap the text from
180 point to A, then the text from A to C and finally the text from C to B@. This
181 is done because the regions overlap and Emacs would be helplessly lost if it
182 tried to follow the order in which you marked these points.
183
184
185
186 @node Skeletons as Abbrevs
187 @chapter Skeletons as Abbrev Expansions
188 @cindex skeletons as abbrevs
189
190 Rather than use a key binding for every skeleton command, you can also
191 define an abbreviation (@pxref{Defining Abbrevs,,, emacs, The GNU Emacs Manual}) that will expand
192 (@pxref{Expanding Abbrevs,,, emacs, The GNU Emacs Manual}) into the skeleton.
193
194 Say you want @samp{ifst} to be an abbreviation for the C language if
195 statement. You will tell Emacs that @samp{ifst} expands to the empty string
196 and then calls the skeleton command. In Emacs Lisp you can say something like
197 @code{(define-abbrev c-mode-abbrev-table "ifst" "" 'c-if)}. Or you can edit
198 the output from @kbd{M-x list-abbrevs} to make it look like this:
199
200 @example
201 (c-mode-abbrev-table)
202 "if" 0 "" c-if
203 @end example
204
205 @noindent
206 (Some blank lines of no semantic significance, and other abbrev tables,
207 have been omitted.)
208
209
210
211 @node Skeleton Language
212 @chapter Skeleton Language
213 @cindex skeleton language
214
215 @findex skeleton-insert
216 Skeletons are an shorthand extension to the Lisp language, where various
217 atoms directly perform either actions on the current buffer or rudimentary
218 flow control mechanisms. Skeletons are interpreted by the function
219 @code{skeleton-insert}.
220
221 A skeleton is a list starting with an interactor, which is usually a
222 prompt-string, or @code{nil} when not needed, but can also be a Lisp
223 expression for complex read functions or for returning some calculated value.
224 The rest of the list are any number of elements as described in the following
225 table:
226
227 @table @asis
228 @item @code{"@var{string}"}, @code{?@var{c}}, @code{?\@var{c}}
229 @vindex skeleton-transformation
230 Insert string or character. Literal strings and characters are passed through
231 @code{skeleton-transformation} when that is non-@code{nil}.
232 @item @code{?\n}
233 @c ??? something seems very wrong here.
234 Insert a newline and align under current line. Use newline character
235 @code{?\n} to prevent alignment.
236 @item @code{_}
237 Interesting point. When wrapping skeletons around successive regions, they are
238 put at these places. Point is left at first @code{_} where nothing is wrapped.
239 @item @code{>}
240 Indent line according to major mode. When following element is @code{_}, and
241 there is a interregion that will be wrapped here, indent that interregion.
242 @item @code{&}
243 Logical and. Iff preceding element moved point, i.e., usually inserted
244 something, do following element.
245 @item @code{|}
246 Logical xor. Iff preceding element didn't move point, i.e., usually inserted
247 nothing, do following element.
248 @item @code{-@var{number}}
249 Delete preceding number characters. Depends on value of
250 @code{skeleton-untabify}.
251 @item @code{()} or @code{nil}
252 Ignored.
253 @item @var{lisp-expression}
254 Evaluated, and the return value is again interpreted as a skeleton element.
255 @item @code{str}
256 A special variable that, when evaluated the first time, usually prompts
257 for input according to the skeleton's interactor. It is then set to the
258 return value resulting from the interactor. Each subskeleton has its local
259 copy of this variable.
260 @item @code{v1}, @code{v2}
261 Skeleton-local user variables.
262 @item @code{'@var{expression}}
263 Evaluate following Lisp expression for its side-effect, but prevent it from
264 being interpreted as a skeleton element.
265 @item @var{skeleton}
266 Subskeletons are inserted recursively, not once, but as often as the user
267 enters something at the subskeletons interactor. Thus there must be a
268 @code{str} in the subskeleton. They can also be used non-interactively, when
269 prompt is a lisp-expression that returns successive list-elements.
270 @item @code{resume:}
271 Ignored. Execution resumes here if the user quits during skeleton
272 interpretation.
273 @item @code{quit}
274 A constant which is non-@code{nil} when the @code{resume:} section was entered
275 because the user quit.
276 @end table
277
278 @findex skeleton-further-elements
279 Some modes also use other skeleton elements they themselves defined. For
280 example in shell script mode's skeletons you will find @code{<} which does a
281 rigid indentation backwards, or in CC mode's skeletons you find the
282 self-inserting elements @code{@{} and @code{@}}. These are defined by the
283 buffer-local variable @code{skeleton-further-elements} which is a list of
284 variables bound while interpreting a skeleton.
285
286 @findex define-skeleton
287 The macro @code{define-skeleton} defines a command for interpreting a
288 skeleton. The first argument is the command name, the second is a
289 documentation string, and the rest is an interactor and any number of skeleton
290 elements together forming a skeleton. This skeleton is assigned to a variable
291 of the same name as the command and can thus be overridden from your
292 @file{~/.emacs} file (@pxref{Init File,,, emacs, The GNU Emacs Manual}).
293
294
295
296 @node Inserting Pairs
297 @chapter Inserting Matching Pairs of Characters
298 @cindex inserting pairs
299 @cindex pairs
300
301 Various characters usually appear in pairs. When, for example, you insert
302 an open parenthesis, no matter whether you are programming or writing prose,
303 you will surely enter a closing one later. By entering both at the same time
304 and leaving the cursor inbetween, Emacs can guarantee you that such
305 parentheses are always balanced. And if you have a non-qwerty keyboard, where
306 typing some of the stranger programming language symbols makes you bend your
307 fingers backwards, this can be quite relieving too.
308
309 @findex skeleton-pair-insert-maybe
310 @vindex skeleton-pair
311 This is done by binding the first key (@pxref{Rebinding,,, emacs, The GNU Emacs Manual}) of
312 the pair to @code{skeleton-pair-insert-maybe} instead of
313 @code{self-insert-command}. The ``maybe'' comes from the fact that
314 this at-first surprising behavior is initially turned off. To enable
315 it, you must set @code{skeleton-pair} to some non-@code{nil} value.
316 And even then, a positive argument (@pxref{Arguments,,, emacs, The GNU Emacs Manual}) will
317 make this key behave like a self-inserting key
318 (@pxref{Inserting Text,,, emacs, The GNU Emacs Manual}).
319
320 @vindex skeleton-pair-on-word
321 While this breaks with the stated intention of always balancing pairs, it
322 turns out that one often doesn't want pairing to occur, when the following
323 character is part of a word. If you want pairing to occur even then, set
324 @code{skeleton-pair-on-word} to some non-@code{nil} value.
325
326 @vindex skeleton-pair-alist
327 Pairing is possible for all visible characters. By default the
328 parenthesis @samp{(}, the square bracket @samp{[}, the brace
329 @samp{@{}, the pointed bracket @samp{<} and the backquote @samp{`} all
330 pair with the symmetrical character. All other characters pair
331 themselves. This behavior can be modified by the variable
332 @code{skeleton-pair-alist}. This is in fact an alist of skeletons
333 (@pxref{Skeleton Language}), with the first part of each sublist
334 matching the typed character. This is the position of the interactor,
335 but since pairs don't need the @code{str} element, this is ignored.
336
337 Some modes have bound the command @code{skeleton-pair-insert-maybe}
338 to relevant keys. These modes also configure the pairs as
339 appropriate. For example, when typing english prose, you'd expect the
340 backquote (@samp{`}) to pair with the quote (@samp{'}), while in Shell
341 script mode it must pair to itself. They can also inhibit pairing in
342 certain contexts. For example an escaped character stands for itself.
343
344
345
346 @node Autoinserting
347 @chapter Autoinserting Text in Empty Files
348 @cindex autoinserting
349
350 @findex auto-insert
351 @kbd{M-x auto-insert} will put some predefined text at the beginning of
352 the buffer. The main application for this function, as its name suggests,
353 is to have it be called automatically every time an empty, and only an
354 empty file is visited. This is accomplished by putting @code{(add-hook
355 'find-file-hook 'auto-insert)} into your @file{~/.emacs} file
356 (@pxref{Init File,,, emacs, The GNU Emacs Manual}).
357
358 @vindex auto-insert-alist
359 What gets inserted, if anything, is determined by the variable
360 @code{auto-insert-alist}. The @sc{car}s of this list are each either
361 a mode name, making an element applicable when a buffer is in that
362 mode. Or they can be a string, which is a regexp matched against the
363 buffer's file name. In that way different kinds of files that have
364 the same mode in Emacs can be distinguished. The @sc{car}s may also
365 be cons cells consisting of mode name or regexp as above and an
366 additional descriptive string.
367
368 When a matching element is found, the @sc{cdr} says what to do. It may
369 be a string, which is a file name, whose contents are to be inserted, if
370 that file is found in the directory @code{auto-insert-directory} or under a
371 absolute file name. Or it can be a skeleton (@pxref{Skeleton Language}) to
372 be inserted.
373
374 It can also be a function, which allows doing various things. The function
375 can simply insert some text, indeed, it can be skeleton command (@pxref{Using
376 Skeletons}). It can be a lambda function which will for example conditionally
377 call another function. Or it can even reset the mode for the buffer. If you
378 want to perform several such actions in order, you use a vector, i.e., several
379 of the above elements between square brackets (@samp{[@r{@dots{}}]}).
380
381 By default C and C++ headers insert a definition of a symbol derived from
382 the filename to prevent multiple inclusions. C and C++ sources insert an
383 include of the header. Makefiles insert the file makefile.inc if it exists.
384
385 TeX and bibTeX mode files insert the file tex-insert.tex if it exists, while
386 LaTeX mode files insert a typical @code{\documentclass} frame. Html
387 files insert a skeleton with the usual frame.
388
389 Ada mode files call the Ada header skeleton command. Emacs lisp
390 source files insert the usual header, with a copyright of your
391 environment variable @env{$ORGANIZATION} or else the FSF, and prompt
392 for valid keywords describing the contents. Files in a @file{bin}
393 directory for which Emacs could determine no specialized mode
394 (@pxref{Choosing Modes,,, emacs, The GNU Emacs Manual}) are set to Shell script mode.
395
396 @findex define-auto-insert
397 In Lisp (@pxref{Init File,,, emacs, The GNU Emacs Manual}) you can use the function
398 @code{define-auto-insert} to add to or modify
399 @code{auto-insert-alist}. See its documentation with @kbd{C-h f
400 define-auto-insert}.
401
402 @vindex auto-insert
403 The variable @code{auto-insert} says what to do when @code{auto-insert} is
404 called non-interactively, e.g., when a newly found file is empty (see above):
405 @table @asis
406 @item @code{nil}
407 Do nothing.
408 @item @code{t}
409 Insert something if possible, i.e., there is a matching entry in
410 @code{auto-insert-alist}.
411 @item other
412 Insert something if possible, but mark as unmodified.
413 @end table
414
415 @vindex auto-insert-query
416 The variable @code{auto-insert-query} controls whether to ask about
417 inserting something. When this is @code{nil}, inserting is only done with
418 @kbd{M-x auto-insert}. When this is @code{function}, you are queried
419 whenever @code{auto-insert} is called as a function, such as when Emacs
420 visits an empty file and you have set the above-mentioned hook. Otherwise
421 you are always queried.
422
423 @vindex auto-insert-prompt
424 When querying, the variable @code{auto-insert-prompt}'s value is used as a
425 prompt for a y-or-n-type question. If this includes a @samp{%s} construct,
426 that is replaced by what caused the insertion rule to be chosen. This is
427 either a descriptive text, the mode-name of the buffer or the regular
428 expression that matched the filename.
429
430
431
432 @node Copyrights
433 @chapter Inserting and Updating Copyrights
434 @cindex copyrights
435
436 @findex copyright
437 @kbd{M-x copyright} is a skeleton inserting command, that adds a copyright
438 notice at the point. The ``by'' part is taken from your environment variable
439 @env{$ORGANIZATION} or if that isn't set you are prompted for it. If the
440 buffer has a comment syntax (@pxref{Comments,,, emacs, The GNU Emacs Manual}), this is inserted as a comment.
441
442 @findex copyright-update
443 @vindex copyright-limit
444 @vindex copyright-current-year
445 @kbd{M-x copyright-update} looks for a copyright notice in the first
446 @code{copyright-limit} characters of the buffer and updates it when necessary.
447 The current year (variable @code{copyright-current-year}) is added to the
448 existing ones, in the same format as the preceding year, i.e., 1994, '94 or 94.
449 If a dash-separated year list up to last year is found, that is extended to
450 current year, else the year is added separated by a comma. Or it replaces
451 them when this is called with a prefix argument. If a header referring to a
452 wrong version of the GNU General Public License (@pxref{Copying,,, emacs, The GNU Emacs Manual}) is found,
453 that is updated too.
454
455 An interesting application for this function is to have it be called
456 automatically every time a file is saved. This is accomplished by
457 putting @code{(add-hook 'before-save-hook 'copyright-update)} into
458 your @file{~/.emacs} file (@pxref{Init File,,, emacs, The GNU Emacs Manual}). Alternative,
459 you can do @kbd{M-x customize-variable @key{RET} before-save-hook
460 @key{RET}}. @code{copyright-update} is conveniently listed as an
461 option in the customization buffer.
462
463 @vindex copyright-query
464 The variable @code{copyright-query} controls whether to update the
465 copyright or whether to ask about it. When this is @code{nil} updating is
466 only done with @kbd{M-x copyright-update}. When this is @code{function}
467 you are queried whenever @code{copyright-update} is called as a function,
468 such as in the @code{before-save-hook} feature mentioned above. Otherwise
469 you are always queried.
470
471
472
473 @node Executables
474 @chapter Making Interpreter Scripts Executable
475 @cindex executables
476
477 @vindex executable-prefix
478 @vindex executable-chmod
479 Various interpreter modes such as Shell script mode or AWK mode will
480 automatically insert or update the buffer's magic number, a special
481 comment on the first line that makes the @code{exec} systemcall know
482 how to execute the script. To this end the script is automatically
483 made executable upon saving, with @code{executable-chmod} as argument
484 to the system @code{chmod} command. The magic number is prefixed by
485 the value of @code{executable-prefix}.
486
487 @vindex executable-magicless-file-regexp
488 Any file whose name matches @code{executable-magicless-file-regexp} is not
489 furnished with a magic number, nor is it made executable. This is mainly
490 intended for resource files, which are only meant to be read in.
491
492 @vindex executable-insert
493 The variable @code{executable-insert} says what to do when
494 @code{executable-set-magic} is called non-interactively, e.g., when file has no
495 or the wrong magic number:
496 @table @asis
497 @item @code{nil}
498 Do nothing.
499 @item @code{t}
500 Insert or update magic number.
501 @item other
502 Insert or update magic number, but mark as unmodified.
503 @end table
504
505 @findex executable-set-magic
506 @vindex executable-query
507 The variable @code{executable-query} controls whether to ask about
508 inserting or updating the magic number. When this is @code{nil} updating
509 is only done with @kbd{M-x executable-set-magic}. When this is
510 @code{function} you are queried whenever @code{executable-set-magic} is
511 called as a function, such as when Emacs puts a buffer in Shell script
512 mode. Otherwise you are always queried.
513
514 @findex executable-self-display
515 @kbd{M-x executable-self-display} adds a magic number to the buffer, which
516 will turn it into a self displaying text file, when called as a Un*x command.
517 The ``interpreter'' used is @code{executable-self-display} with argument
518 @samp{+2}.
519
520 @node Timestamps
521 @chapter Maintaining Timestamps in Modified Files
522 @cindex timestamps
523
524 @findex time-stamp
525 @vindex before-save-hook
526 The @code{time-stamp} command can be used to update automatically a
527 template in a file with a new time stamp every time you save the file.
528 Customize the hook @code{before-save-hook} to add the function
529 @code{time-stamp} to arrange this. It you use Custom to do this,
530 then @code{time-stamp} is conveniently listed as an option in the
531 customization buffer.
532
533 @vindex time-stamp-active
534 @vindex time-stamp-format
535 @vindex time-stamp-start
536 The time stamp is updated only if the customizable variable
537 @code{time-stamp-active} is on, which it is by default; the command
538 @code{time-stamp-toggle-active} can be used to toggle it. The format of
539 the time stamp is set by the customizable variable
540 @code{time-stamp-format}.
541
542 @vindex time-stamp-line-limit
543 @vindex time-stamp-end
544 @vindex time-stamp-count
545 @vindex time-stamp-inserts-lines
546 The variables @code{time-stamp-line-limit}, @code{time-stamp-start},
547 @code{time-stamp-end}, @code{time-stamp-count}, and
548 @code{time-stamp-inserts-lines} control finding the template. Do not
549 change these in your init file or you will be incompatible with other
550 people's files. If you must change them, do so only in the local
551 variables section of the file itself.
552
553 Normally the template must appear in the first 8 lines of a file and
554 look like one of the following:
555
556 @example
557 Time-stamp: <>
558 Time-stamp: " "
559 @end example
560
561 The time stamp is written between the brackets or quotes:
562
563 @example
564 Time-stamp: <1998-02-18 10:20:51 gildea>
565 @end example
566
567 @node QuickURL
568 @chapter QuickURL: Inserting URLs Based on Text at Point
569
570 @vindex quickurl-url-file
571 @findex quickurl
572 @cindex URLs
573 @kbd{M-x quickurl} can be used to insert a URL into a buffer based on
574 the text at point. The URLs are stored in an external file defined by
575 the variable @code{quickurl-url-file} as a list of either cons cells of
576 the form @code{(@var{key} . @var{URL})} or
577 lists of the form @code{(@var{key} @var{URL} @var{comment})}. These
578 specify that @kbd{M-x quickurl} should insert @var{URL} if the word
579 @var{key} is at point, for example:
580
581 @example
582 (("FSF" "http://www.fsf.org/" "The Free Software Foundation")
583 ("emacs" . "http://www.emacs.org/")
584 ("hagbard" "http://www.hagbard.demon.co.uk" "Hagbard's World"))
585 @end example
586
587 @findex quickurl-add-url
588 @findex quickurl-list
589 @kbd{M-x quickurl-add-url} can be used to add a new @var{key}/@var{URL}
590 pair. @kbd{M-x quickurl-list} provides interactive editing of the URL
591 list.
592
593 @node Tempo
594 @chapter Tempo: Flexible Template Insertion
595
596 @cindex templates
597 The Tempo package provides a simple way to define powerful templates, or
598 macros, if you wish. It is mainly intended for, but not limited to,
599 programmers to be used for creating shortcuts for editing
600 certain kinds of documents.
601
602 @findex tempo-backward-mark
603 @findex tempo-forward-mark
604 A template is defined as a list of items to be inserted in the current
605 buffer at point. Some can be simple strings, while others can control
606 formatting or define special points of interest in the inserted text.
607 @kbd{M-x tempo-backward-mark} and @kbd{M-x tempo-forward-mark} can be
608 used to jump between such points.
609
610 More flexible templates can be created by including Lisp symbols, which
611 will be evaluated as variables, or lists, which will be evaluated
612 as Lisp expressions. Automatic completion of specified tags to expanded
613 templates can be provided.
614
615 @findex tempo-define-template
616 See the documentation for @code{tempo-define-template} for the different
617 items that can be used to define a tempo template with a command for
618 inserting it.
619
620 See the commentary in @file{tempo.el} for more information on using the
621 Tempo package.
622
623 @node Hippie Expand
624 @chapter `Hippie' Expansion
625
626 @findex hippie-expand
627 @kindex M-/
628 @vindex hippie-expand-try-functions-list
629 @kbd{M-x hippie-expand} is a single command providing a variety of
630 completions and expansions. Called repeatedly, it tries all possible
631 completions in succession.
632
633 Which ones to try, and in which order, is determined by the contents of
634 the customizable option @code{hippie-expand-try-functions-list}. Much
635 customization of the expansion behavior can be made by changing the
636 order of, removing, or inserting new functions in this list. Given a
637 positive numeric argument, @kbd{M-x hippie-expand} jumps directly that
638 number of functions forward in this list. Given some other argument (a
639 negative argument or just @kbd{C-u}) it undoes the tried completion.
640
641 See the commentary in @file{hippie-exp.el} for more information on the
642 possibilities.
643
644 Typically you would bind @code{hippie-expand} to @kbd{M-/} with
645 @code{dabbrev-expand}, the standard binding of @kbd{M-/}, providing one
646 of the expansion possibilities.
647
648 @node GNU Free Documentation License
649 @appendix GNU Free Documentation License
650 @include doclicense.texi
651
652 @node Concept Index
653 @unnumbered Concept Index
654 @printindex cp
655
656 @node Command Index
657 @unnumbered Command Index
658 @printindex fn
659
660 @node Variable Index
661 @unnumbered Variable Index
662 @printindex vr
663
664 @bye