srecode: Inserting Tag Lists
9 Inserting Tag Lists
*********************
Since SRecode is the Semantic Recoder, the ultimate goal for SRecode is
to convert lists of tags, as produced by Semantic back into code.
A single function provides the interface for programs to do this, but
it requires any particular language to have provided the correct
templates to make it work.
-- Function: srecode-semantic-insert-tag tag &optional style-option
point-insert-fcn &rest dict-entries
Insert TAG into a buffer using srecode templates at point.
Optional STYLE-OPTION is a list of minor configuration of styles,
such as the symbol ‘'prototype’ for prototype functions, or
‘'system’ for system includes, and ‘'doxygen’, for a doxygen style
comment.
Optional third argument POINT-INSERT-FCN is a hook that is run
after TAG is inserted that allows an opportunity to fill in the
body of some thing. This hook function is called with one
argument, the TAG being inserted.
The rest of the arguments are DICT-ENTRIES. DICT-ENTRIES is of the
form ( NAME1 VALUE1 NAME2 VALUE2 ... NAMEn VALUEn).
The exact template used is based on the current context. The
template used is found within the toplevel context as calculated by
“srecode-calculate-context”, such as ‘declaration’, ‘classdecl’, or
‘code’.
For various conditions, this function looks for a template with the
name CLASS-tag, where CLASS is the tag class. If it cannot find
that, it will look for that template in the ‘declaration’context
(if the current context was not ‘declaration’).
If PROTOTYPE is specified, it will first look for templates with
the name CLASS-tag-prototype, or CLASS-prototype as above.
See “srecode-semantic-apply-tag-to-dict” for details on what is in
the dictionary when the templates are called.
This function returns to location in the buffer where the inserted
tag ENDS, and will leave point inside the inserted text based on
any occurrence of a point-inserter. Templates such as “function”
will leave point where code might be inserted.