[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

25. Flexible Template Insertion

This file provides a simple way to define powerful templates, or macros, if you wish. It is mainly intended for, but not limited to, other programmers to be used for creating shortcuts for editing certain kind of documents. It was originally written to be used by a HTML editing mode written by Nelson Minar <nelson@santafe.edu>, and his `html-helper-mode.el' is probably the best example of how to use this program.

A template is defined as a list of items to be inserted in the current buffer at point. Some of the items can be simple strings, while other can control formatting or define special points of interest in the inserted text.

If a template defines a "point of interest" that point is inserted in a buffer-local list of "points of interest" that the user can jump between with the commands tempo-backward-mark and tempo-forward-mark. If the template definer provides a prompt for the point, and the variable tempo-interactive is non-nil, the user will be prompted for a string to be inserted in the buffer, using the minibuffer.

The template can also define one point to be replaced with the current region if the template command is called with a prefix (or a non-nil argument).

More flexible templates can be created by including lisp symbols, which will be evaluated as variables, or lists, which will be evaluated as lisp expressions.

See the documentation for tempo-define-template for the different items that can be used to define a tempo template.

One of the more powerful features of tempo templates are automatic completion. With every template can be assigned a special tag that should be recognized by tempo-complete-tag and expanded to the complete template. By default the tags are added to a global list of template tags, and are matched against the last word before point. But if you assign your tags to a specific list, you can also specify another method for matching text in the buffer against the tags. In the HTML mode, for instance, the tags are matched against the text between the last `<' and point.

When defining a template named foo, a symbol named tempo-template-foo will be created whose value as a variable will be the template definition, and its function value will be an interactive function that inserts the template at the point.

To configure this package, type:

 
  M-x customize-group RET tempo RET


[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated by XEmacs shared group account on December, 19 2009 using texi2html 1.65.