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 declarationcontext (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.