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