[Top] | [Contents] | [Index] | [ ? ] |
This is the manual of Emacs template package
1. Overview | ||
2. Installation | how to install the template package. | |
3. Basics | How to make and use templates. | |
4. Templates for advanced users | ||
5. Indexes for commands, keyword, and variable | ||
6. News for Package Template | ||
• Acknowledgements |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
When you create a new file with Emacs, package Template supplies an initial buffer content via a template: a file with normal text and expansion forms. There is a menu to easily create such templates. You can also use new commands to decorate comments and update the buffer contents.
The main difference between Template and other similar packages is that you can define very flexible templates without having to learn Lisp or changing your Emacs init file. This package does not help Lisp programmers to define complex macros.
There is a menu to support the creation of template files. Additionally, this package provides the following features:
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
There are template packages of two different categories, which are determined by one question:
What do you want to do with templates? Do you want to use templates when creating new files, or do you want to insert some stuff during editing (but you are not satisfied with the standard macro mechanism)?
Well, templates could be seen as both new-file templates and macro-like template, but the main application of templates determines the answers for the following questions:
Here is a little list of related files, collected around 1998, some discarded later (no URLs, no active updating, but you can send me a mail):
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
(require 'template) (template-initialize) |
Installation instructions with further explanations can be found in file ‘template/INSTALL’ of the distribution.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Emacs, template, file template, comment decoration, auto-updating, time stamp, details
3.1 Menus and Key-Bindings | ||
3.2 Using a Template | ||
3.3 Finding a Template | ||
3.4 Creating a Template | ||
3.5 Decorating a Comment | ||
3.6 Updating a Buffer |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
For Emacs-21.1+ and XEmacs, this package defines the following menu entries and key-bindings:
template-single-comment
) to
insert dashes and alike into the current line and end the comment.
template-single-comment
) to
insert dashes and alike around the current comment block.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Package Template offers various ways how to use template files:
In Emacs, the usual way to create a new file is by typing C-x C-f,
using the menu or the toolbar (running command find-file
or
ffap
) and entering a non-existent file name. In this case,
you will be asked whether to use a template for the new file. You can
turn off this feature.
template-new-file
(1) to create a new file using a template. Here, you have
the chance to edit the name of the template file. This command also
supports file name refinement which is useful to create a file in a
series of files like ‘exercise2.tex’ etc.
For more template-new-file
and template-auto-insert
,
See section Customization of keyword expansion rules.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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:
For more on derivation See section Customization of how templates are derived.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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:
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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:
template-single-comment
to jump to the
end of the current line and insert the dashes and the final
comment end-string up-to the fill position. This command works with any
comment style, including for languages having mixed comments like C++ and Java.
It also works in major modes without a defined comment syntax.
template-block-comment
to surround the
current comment block (i.e., contiguous comment lines) with extra lines
containing dashes and alike and to put the correct number of newlines around
the block. This command only works with comments which are terminated with the
end of the line (like Java’s //
comment).
The comment decoration style is highly customizable and can be controlled by
;
).
For more on comments See section Customization of comments.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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 .
@(#) FileName
or
;;; FileName --
where
;;;
stands for any comment start (with optional
repetition of a single-character comment start).
address
element of a HTML buffer.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
4.1 Templates customization |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
4.1.1 Customization of keyword expansion rules | ||
4.1.2 Customization of how templates are derived | ||
4.1.3 Customization of comments |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Open a new file file by using a template. Using a template for creating a new file consists of, steps 1 to 3 are only executed when called interactively:
template-derivation-alist
.
template-definition-start
and delete it.
template-message-buffer
.
template-expansion-regexp
) They are defined in the definition
section, in template-expansion-alist
, or provided by default,
see template-expansion-regexp
and
template-register-regexp
.
normal-mode
and functions in find-file-hooks
.
template-update-header
with
argument if-exists
.
template-message-buffer
.
template-message-timeout
.
If optional with-undo is non-nil, store corresponding changes in
buffer-undo-list
. If file is nil, the buffer for file has
already been created and the accessible part will be replaced by the
expanded template. If template is nil (empty input when called
interactively), do not use a template.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
It is bound to C-x C-;, and <menu-bar> <edit> <Comment> <Decorate Comment Block>.
Decorate the current block of comment-only lines with dashes and alike. That is, surround the the contiguous comment-only lines around point with extra lines containing dashes and alike and to put the correct number of newlines around the block.
Barf if the comment syntax at point has a non-empty comment-end
or if
point is not in a comment-only line.
A block comment consists of all neighboring lines which start with
spaces and comment-start
. If comment-start
is a string of length 1,
the number of repetitions of comment-start
must be the same or larger
than in the line where the command is invoked from, too.
Prefix argument arg and template-comment-specification
determines the
comment style to use. The length of the separator line is determined by
template-max-column
.
This command can also be used with point in an empty line after a block comment. A second invocation of this command directly after a successful invocation deletes the remaining empty lines from the current line on.
List of specifications for comment functions. Each specification at
level, starting at 1, is a list (separator
before-block after-block DELETE-LINES)
separator is the string which is inserted repeatedly by commands
C-x C-= and C-x C-; up to template-max-column
.
After that, C-x C-; deletes DELETE-LINES after the comment block and inserts string after-block at the end of the block and before-block at the front of the block.
The specification level to use is determined by:
template-comment-specification-special
is a function or the
current major mode has a property with this name and its value is a
function, this function returns the specification.
comment-end
is empty and comment-start
is a string of
length 1: level is number of repetitions of comment-start
at the beginning of the line. Otherwise, if the correctly indented line
starts at the beginning of the line, level=3, else level=2.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
5.1 Keyword Index | ||
5.2 Keyword Index | Command Index. | |
5.3 Variable Index | Customizable Variable Index. |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Jump to: | T |
---|
Index Entry | Section | |
---|---|---|
| ||
T | ||
template-block-comment | 4.1.3 Customization of comments | |
template-new-file | 4.1.1 Customization of keyword expansion rules | |
|
Jump to: | T |
---|
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Jump to: | T |
---|
Jump to: | T |
---|
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
3.1c (21 Aug 2003).
Emacs-20.2, XEmacs-20.2, or higher.
No menu support for Emacs before Version 21.1.
GNU General Public License.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
M-x template-single-comment
.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
ffap
to always add an entry to
command-history
if the filename is read from terminal. Special
setup for ffap
and html-helper
.
y-or-n-p
.
Christoph Wedler http://sourceforge.net/users/wedler/, 21 Aug 2003
[Top] | [Contents] | [Index] | [ ? ] |
for the menu entry and its key-binding type C-h f template-new-file, @xref{EExpansion}
[Top] | [Contents] | [Index] | [ ? ] |
This document was generated by a tester on a sunny day using texi2html.
The buttons in the navigation panels have the following meaning:
Button | Name | Go to | From 1.2.3 go to |
---|---|---|---|
[ < ] | Back | Previous section in reading order | 1.2.2 |
[ > ] | Forward | Next section in reading order | 1.2.4 |
[ << ] | FastBack | Beginning of this chapter or previous chapter | 1 |
[ Up ] | Up | Up section | 1.2 |
[ >> ] | FastForward | Next chapter | 2 |
[Top] | Top | Cover (top) of document | |
[Contents] | Contents | Table of contents | |
[Index] | Index | Index | |
[ ? ] | About | About (help) |
where the Example assumes that the current position is at Subsubsection One-Two-Three of a document of the following structure:
This document was generated by a tester on a sunny day using texi2html.