Authoring Modes for XMode

Overall structure of a mode file

An XMode mode file is an XML document conforming to the XMode DTD. It describes a set of heuristics for tokenizing, colorizing, and editing a defined class of documents (a Mode).

All XMode mode files should have these parts (in the following order):

  1. XML declaration
  2. A DOCTYPE declaration of <!DOCTYPE MODE>
  3. A single root tag of type MODE

The MODE tag

The MODE tag is the root element of an XMode document. It represents a single jEdit editing mode. Each mode is identified by the value of the NAME attribute of its root MODE tag, which should be unique among all installed modes. The name is guaranteed to be unique at run time, because XMode will instantiate only one mode with a specified name.

The MODE tag contains a single PROPS element and any number of RULES elements.

The PROPS tag

The PROPS/ tag encapsulates the jEdit buffer-local properties that are available to be set at the mode level. The TITLE tag is required. All other tags are optional although some tags must occur together. The following properties may be set in the PROPS section:

TITLE

The TITLE tag contains the textual description for this mode.

The value of this tag is stored in the mode.<mode_name>.label property.

INDENT_OPEN_BRACKETS and INDENT_CLOSE_BRACKETS

The INDENT_OPEN_BRACKETS and INDENT_CLOSE_BRACKETS tags specify the character sequences that open and close an indentation level, respectively. These two tags must occur together.

The values of these tags are stored in the mode.<mode_name>.indentOpenBrackets and mode.<mode_name>.indentCloseBrackets properties, respectively.

COMMENT_START, COMMENT_END, and BOX_COMMENT

The COMMENT_START, COMMENT_END, and BOX_COMMENT tags control the behavior of jEdit's "Wing Comment" and "Box Comment" commands while editing a Buffer with this mode. COMMENT_START must occur with COMMENT_END, and BOX_COMMENT cannot occur without the other two.

The values of these tags are stored in the mode.<mode_name>.commentStart, mode.<mode_name>.commentEnd, and mode.<mode_name>.boxComment properties, respectively.

BLOCK_COMMENT

The BLOCK_COMMENT tags controls the behavior of jEdit's "Block Comment" command while editing a Buffer with this mode. If this property is set, then invoking the "Block Comment" command will insert this tag's value into the buffer at the current point. This property does not influence syntax colorization. To perform the equivalent of a "block comment" with the colorizer, see the EOL_SPAN rule below.

The value of this tag is stored in the mode.<mode_name>.blockComment property.

COMPILER

The COMPILER tag specifies the name of the command used to compile Buffers edited with this mode. This property is no longer used by any internal jEdit actions and should be considered deprecated.

EXTENSION and FILENAME

The EXTENSION tag specifies a filename extension for which this mode should be used. A PROPS section may contain any number of EXTENSION tags.

The FILENAME tag specifies a filename glob for which this mode should be used. A PROPS section may contain any number of FILENAME tags.

The values of all EXTENSION and FILENAME tags are combined into a single glob expression that is stored in the mode.<mode_name>.filenameGlob property.

FIRST_LINE

The FIRST_LINE tag specifies the first line globs for which this mode should be used. A PROPS section may contain any number of FIRST_LINE tags.

The values of all FIRST_LINE tags are combined into a larger glob expression that is stored in the mode.<mode_name>.firstlineGlob property.

NO_WORD_SEP

The NO_WORD_SEP tag identifies which characters should be considered part of a "word" in this mode, in addition to letters and numbers.

The value of this tag is stored in the mode.<mode_name>.noWordSep property.

SOFT_TABS

The SOFT_TABS tag specifies whether spaces or tabs are used for indentation. The allowed values are TRUE and FALSE. If the value is TRUE, spaces will be used to indent the buffer in this mode; otherwise, "hard" tabs will be used.

The value of this tag is stored in the mode.<mode_name>.noTabs property.

TAB_SIZE

The TAB_SIZE tag specifies the width of the tab stops in this mode. The value should be parsable as a positive integer. With soft tabs, this is the actual number of space characters inserted when tab is pressed; with hard tabs, it is the width of a tab in proportion to the space character.

The value of this tag is stored in the mode.<mode_name>.tabSize property.

The RULES tag

TERMINATE rule

WHITESPACE rule

SEQ rule

SPAN rule

EOL_SPAN rule

MARK_PREVIOUS rule

MARK_FOLLOWING rule

The KEYWORDS tag