Template Overview Related Details News »Project »Download

Details of Package Template

  1. Menus and Key-Bindings
  2. Using a Template
  3. Finding a Template
  4. Creating a Template
  5. Decorating a Comment
  6. Updating a Buffer

Menus and Key-Bindings

For Emacs-21.1+ and XEmacs, this package defines the following menu entries and key-bindings:

Using a Template

Package Template offers various ways how to use template files:

Technical detail: documentation of command template-new-file and variable template-auto-insert.

Finding a Template

The algorithm for finding the most appropriate template can be best explained with a little example:

The creation of the template files in the right directory is already enough for packages Template to find the most appropriate template for a new file:

Technical detail: documentation of variable template-derivation-alist.

Creating a Template

There are various predefined expansions which are probably enough for most templates. A corresponding expansion forms can be easily inserted by selecting the appropriate entry in the new submenu Template Creation:

You can define your own expansions in your Emacs init file and at the end of a template file. A corresponding definition can be easily inserted by selecting the appropriate entry in the new submenu Template Creation:

Technical detail: documentation of variables template-default-expansion-alist and template-definition-start.

Decorating a Comment

There are commands to decorate comments with dashes and alike (-, = and # by default). Both commands are included in the new submenu Comments and bound to keys:

The comment decoration style is highly customizable and can be controlled by

Technical detail: documentation of commands template-single-comment and template-block-comment, and variable template-comment-specification-alist.

Updating a Buffer

A buffer is automatically updated according to some rules when saving the file. This updating can be invoked explicitly by selecting the menu entry Update Buffer in the new submenu Comments.

Technical detail: documentation of command template-update-buffer, and variables template-auto-update, template-update-buffer-alist, and template-header-regexp-alist.

Christoph Wedler, 21 Aug 2003