antlr-insert-option
antlr-insert-option is an interactive compiled Lisp function in `antlr-mode.el
'.
(antlr-insert-option LEVEL OPTION &optional LOCATION)
Insert file/grammar/rule/subrule option near point.
LEVEL determines option kind to insert: 1=file, 2=grammar, 3=rule,
4=subrule. OPTION is a string with the name of the option to insert.
LOCATION can be specified for not calling `antlr-option-kind' twice.
Inserting an option with this command works as follows:
1. When called interactively, LEVEL is determined by the prefix
argument or automatically deduced without prefix argument.
2. Signal an error if no option of that level could be inserted, e.g.,
if the buffer is read-only, the option area is outside the visible
part of the buffer or a subrule/rule option should be inserted with
point outside a subrule/rule.
3. When called interactively, OPTION is read from the minibuffer with
completion over the known options of the given LEVEL.
4. Ask user for confirmation if the given OPTION does not seem to be a
valid option to insert into the current file.
5. Find a correct position to insert the option.
6. Depending on the option, insert it the following way (inserting an
option also means inserting the option section if necessary):
- Insert the option and let user insert the value at point.
- Read a value (with completion) from the minibuffer, using a
previous value as initial contents, and insert option with value.
7. Final action depending on the option. For example, set the language
according to a newly inserted language option.
The name of all options with a specification for their values are stored
in `antlr-options-alists'. The used specification also depends on the
value of `antlr-tool-version', i.e., step 4 will warn you if you use an
option that has been introduced in newer version of ANTLR, and step 5
will offer completion using version-correct values.
If the option already exists inside the visible part of the buffer, this
command can be used to change the value of that option. Otherwise, find
a correct position where the option can be inserted near point.
The search for a correct position is as follows:
* If search is within an area where options can be inserted, use the
position of point. Inside the options section and if point is in
the middle of a option definition, skip the rest of it.
* If an options section already exists, insert the options at the end.
If only the beginning of the area is visible, insert at the
beginning.
* Otherwise, find the position where an options section can be
inserted and insert a new section before any comments. If the
position before the comments is not visible, insert the new section
after the comments.
This function also inserts "options {...}" and the ":" if necessary,
see `antlr-options-auto-colon'. See also `antlr-options-assign-string'.
This command might also set the mark like C-SPC does, see
`antlr-options-push-mark'.