SourceForge.net Logo

Next: , Previous: Setup, Up: Top



5 Extending Languide: how to define languages and statements

Languide comes with definitions of common statement types for several programming languages. You can add more, and of course contribute them for public use should you so wish. The file statement-nav-directions.el implements the basic movements needed to navigate around statements. Directions for specific statement parts in various programming languages are defined in such files as languide-lisp-like.el, languide-c-like.el and so forth; languide-c-like is a fairly rich source of examples. Normally, a sequence of directions is followed, and the last one is taken as the result, that is, the thing to leave selected. To allow multipart selections, as versor does, you can indicate a step of the directions as selecting what it moves over, by wrapping it in a call to “remember”. Strings in the directions are searched for (as regexps) and moved over. Any elisp function calls may be used in the directions, and their effect on point will be, but those listed on statement-navigate-list-selector-functions are treated specially: they are expected to return a cons of the start and end positions of the piece of text they describe. Thus, only such functions should be used as the last step of a set of directions, and only these should be given as the argument to “remember”. You can write your own functions of this nature, but you must add them to statement-navigate-list-selector-functions for them to work properly. The selection functions are as follows:

expression
Selects the following s-exp.
expressions
Selects as many following s-exps as possible at the current level of nesting.
expression-contents
Selects the contents of the following s-exp (but not its brackets).
preceding-expression
Selects the preceding s-exp.
statement
Selects the following statement. This is defined by “defmodal” definitions for the major mode concerned, for the functions move-into-previous-statement, move-into-next-statement, beginning-of-statement-internal, and end-of-statement-internal. (If you define these, you should also define identify-statement, compound-statement-open, compound-statement-close, insert-compound-statement-open, and insert-compound-statement-close.)
statements
Selects as many following statements as possible, at the current level of nesting.
statement-contents
If the following statement is a simple statement, select it. If it is a compound statement, select the statements that it is made of, but not the bracketing that groups them together.
from-start-of-statement
upto
start-of-match

SourceForge.net Logo