Skeleton Language
*****************
Skeletons are an shorthand extension to the Lisp language, where
various atoms directly perform either actions on the current buffer or
rudimentary flow control mechanisms. Skeletons are interpreted by the
function `skeleton-insert'.
A skeleton is a list starting with an interactor, which is usually a
prompt-string, or `nil' when not needed, but can also be a Lisp
expression for complex read functions or for returning some calculated
value. The rest of the list are any number of elements as described in
the following table:
`"STRING"', `?C', `?\C'
Insert string or character. Literal strings and characters are
passed through `skeleton-transformation' when that is non-`nil'.
`?\n'
Insert a newline and align under current line. Use newline
character `?\n' to prevent alignment.
`_'
Interesting point. When wrapping skeletons around successive
regions, they are put at these places. Point is left at first `_'
where nothing is wrapped.
`>'
Indent line according to major mode. When following element is
`_', and there is a interregion that will be wrapped here, indent
that interregion.
`&'
Logical and. Iff preceding element moved point, i.e. usually
inserted something, do following element.
`|'
Logical xor. Iff preceding element didn't move point, i.e.
usually inserted nothing, do following element.
`-NUMBER'
Delete preceding number characters. Depends on value of
`skeleton-untabify'.
`()' or `nil'
Ignored.
LISP-EXPRESSION
Evaluated, and the return value is again interpreted as a skeleton
element.
`str'
A special variable that, when evaluated the first time, usually
prompts for input according to the skeleton's interactor. It is
then set to the return value resulting from the interactor. Each
subskeleton has its local copy of this variable.
`v1', `v2'
Skeleton-local user variables.
`'EXPRESSION'
Evaluate following lisp expression for its side-effect, but
prevent it from being interpreted as a skeleton element.
SKELETON
Subskeletons are inserted recursively, not once, but as often as
the user enters something at the subskeletons interactor. Thus
there must be a `str' in the subskeleton. They can also be used
non-interactively, when prompt is a lisp-expression that returns
successive list-elements.
`resume:'
Ignored. Execution resumes here if the user quits during skeleton
interpretation.
`quit'
A constant which is non-`nil' when the `resume:' section was
entered because the user quit.
Some modes also use other skeleton elements they themselves defined.
For example in shell script mode's skeletons you will find `<' which
does a rigid indentation backwards, or in CC mode's skeletons you find
the self-inserting elements `{' and `}'. These are defined by the
buffer-local variable `skeleton-further-elements' which is a list of
variables bound while interpreting a skeleton.
The macro `define-skeleton' defines a command for interpreting a
skeleton. The first argument is the command name, the second is a
documentation string, and the rest is an interactor and any number of
skeleton elements together forming a skeleton. This skeleton is
assigned to a variable of the same name as the command and can thus be
overridden from your `~/.emacs' file (Note:(emacs)Init File).