The SRecode system is made up of several layers which work together to generate code.
The template layer provides a way to write, and compile templates. The template layer is the scheme used to insert text into an Emacs buffer.
The SRecode template layer is more advanced than other modes like the
tempo in that it allows
multiple layers of templates to be created with the same names. This
means that SRecode can provide a wide range of templates, and users
can override only the small sections they want, instead of either
accepting someone else’s template, or writing large new templates of
Templates are written in .srt files. You can learn how to author new .srt files Template Writing.
While the template system was designed for SRecode based applications it can also be used independently for simple template insertion during typical coding.
Once templates have been written, a scheme for loading and selecting templates is needed. The template manager has a loader for finding template files, and determining which templates are relevant to the current buffer. Template files are sorted by priority, with user templates being found first, and system level default templates last. Templates are also sorted by application. Each application has its own templates, and are kept separate from the generic templates.
Dictionaries contain values associated with variable. Variables are
used in macros in a template. Variables are what allows a generic
template such as a function to be made specific, such as a function
named foo. The value of a variable can be one of three things; a
string, a list of more dictionaries, or a special
srecode-dictionary-compound-value object subclass. See
Variables for more.
The template insertion layer involves extensions to the basic template layer. A wide range of custom variables are available for mixing derived data as macros into the plain text of a template.
In addition, templates can be declared with arguments. These arguments represent predetermined sets of dictionary values, such as features of the current file name, user name, time, etc.
Some arguments are major-mode specific, such as the
A context can be provided for templates in a file. This helps
auto-selection of templates by name, or allows templates in different
contexts to have the same name. Some standard contexts are
A context can be automatically derived as well based on the parsing state from Semantic. See (semantic)Semantic Manual.
Commands that do a particular user task which involves also writing
Emacs Lisp code. Applications are at the top layer. These
applications have their own template files and logic needed to fill in
dictionaries or position a cursor. SRecode comes with an example
srecode-document application for creating comments for Semantic
tags. The CEDET application EDE has a project type that is an
If the variable
srecode-insert-ask-variable-method is set to
’field, then variables that would normally ask a question, will
instead create “fields” in the buffer. A field-editing layer
provides simple interaction through the fields. Typing in a field
will cause all variable locations that are the same to edit at the
same time. Pressing TAB on a field will move you to the