tempo-define-template

tempo-define-template is a compiled Lisp function in `tempo.el'.

(tempo-define-template NAME ELEMENTS &optional TAG DOCUMENTATION TAGLIST)

Define a template.
This function creates a template variable `tempo-template-NAME' and an
interactive function `tempo-template-NAME' that inserts the template
at the point. The created function is returned.

NAME is a string that contains the name of the template, ELEMENTS is a
list of elements in the template, TAG is the tag used for completion,
DOCUMENTATION is the documentation string for the insertion command
created, and TAGLIST (a symbol) is the tag list that TAG (if provided)
should be added to. If TAGLIST is nil and TAG is non-nil, TAG is
added to `tempo-tags'.

The elements in ELEMENTS can be of several types:

- A string: It is sent to the hooks in `tempo-insert-string-functions',
and the result is inserted.
- The symbol `p': This position is saved in `tempo-marks'.
- The symbol `r': If `tempo-insert' is called with ON-REGION non-nil
the current region is placed here. Otherwise it works like `p'.
- (p PROMPT <NAME> <NOINSERT>): If `tempo-interactive' is non-nil, the
user is prompted in the minibuffer with PROMPT for a string to be
inserted. If the optional parameter NAME is non-nil, the text is
saved for later insertion with the `s' tag. If there already is
something saved under NAME that value is used instead and no
prompting is made. If NOINSERT is provided and non-nil, nothing is
inserted, but text is still saved when a NAME is provided. For
clarity, the symbol `noinsert' should be used as argument.
- (P PROMPT <NAME> <NOINSERT>): Works just like the previous tag, but
forces `tempo-interactive' to be true.
- (r PROMPT <NAME> <NOINSERT>): Like the previous tag, but if
`tempo-interactive' is nil and `tempo-insert' is called with
ON-REGION non-nil, the current region is placed here. This usually
happens when you call the template function with a prefix argument.
- (s NAME): Inserts text previously read with the (p ..) construct.
Finds the insertion saved under NAME and inserts it. Acts like `p'
if tempo-interactive is nil.
- `&': If there is only whitespace between the line start and point,
nothing happens. Otherwise a newline is inserted.
- `%': If there is only whitespace between point and end of line,
nothing happens. Otherwise a newline is inserted.
- `n': Inserts a newline.
- `>': The line is indented using `indent-according-to-mode'. Note
that you often should place this item after the text you want on
the line.
- `r>': Like `r', but it also indents the region.
- (r> PROMPT <NAME> <NOINSERT>): Like (r ...), but is also indents
the region.
- `n>': Inserts a newline and indents line.
- `o': Like `%' but leaves the point before the newline.
- nil: It is ignored.
- Anything else: It is evaluated and the result is treated as an
element to be inserted. One additional tag is useful for these
cases. If an expression returns a list '(l foo bar), the elements
after `l' will be inserted according to the usual rules. This makes
it possible to return several elements from one expression.