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