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