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