The PROPS Tag
Prev | Chapter 10. Mode Definition Syntax | Next

## The PROPS Tag

The `PROPS` tag and the `PROPERTY` tags inside it are used to define mode-specific properties. Each `PROPERTY` tag must have a `NAME` attribute set to the property's name, and a `VALUE` attribute with the property's value.

All buffer-local properties listed in the section called “Buffer-Local Properties” may be given values in edit modes.

The following mode properties specify commenting strings:

- `commentEnd` - the comment end string, used by the Range Comment command.

- `commentStart` - the comment start string, used by the Range Comment command.

- `lineComment` - the line comment string, used by the Line Comment command.

When performing auto indent, a number of mode properties determine the resulting indent level:

- The line and the one before it are scanned for brackets listed in the `indentCloseBrackets` and `indentOpenBrackets` properties. Opening brackets in the previous line increase indent.

  If `lineUpClosingBracket` is set to `true`, then closing brackets on the current line will line up with the line containing the matching opening bracket. For example, in Java mode `lineUpClosingBracket` is set to `true`, resulting in brackets being indented like so:

      {
          // Code
          {
              // More code
          }
      }

  If `lineUpClosingBracket` is set to `false`, the line after a closing bracket will be lined up with the line containing the matching opening bracket. For example, in Lisp mode `lineUpClosingBracket` is set to `false`, resulting in brackets being indented like so:

      (foo 'a-parameter
          (crazy-p)
          (bar baz ()))
      (print "hello world")

- If the previous line contains no opening brackets, or if the `doubleBracketIndent` property is set to `true`, the previous line is checked against the regular expressions in the `indentNextLine` and `indentNextLines` properties. If the previous line matches the former, the indent of the current line is increased and the subsequent line is shifted back again. If the previous line matches the latter, the indent of the current and subsequent lines is increased.

  In Java mode, for example, the `indentNextLine` property is set to match control structures such as “if”, “else”, “while”, and so on.

  The `doubleBracketIndent` property, if set to the default of `false`, results in code indented like so:

      while(objects.hasNext())
      {
          Object next = objects.hasNext();
          if(next instanceof Paintable)
              next.paint(g);
      }

  On the other hand, settings this property to “true” will give the following result:

      while(objects.hasNext())
          {
              Object next = objects.hasNext();
              if(next instanceof Paintable)
                  next.paint(g);
          }

Here is the complete `<PROPS>` tag for Java mode:

    <PROPS>
        <PROPERTY NAME="commentStart" VALUE="/*" />
        <PROPERTY NAME="commentEnd" VALUE="*/" />
        <PROPERTY NAME="lineComment" VALUE="//" />
        <PROPERTY NAME="wordBreakChars" VALUE=",+-=&lt;&gt;/?^&amp;*" />

        <!-- Auto indent -->
        <PROPERTY NAME="indentOpenBrackets" VALUE="{" />
        <PROPERTY NAME="indentCloseBrackets" VALUE="}" />
        <PROPERTY NAME="unalignedOpenBrackets" VALUE="(" />
        <PROPERTY NAME="unalignedCloseBrackets" VALUE=")" />
        <PROPERTY NAME="indentNextLine"
        	VALUE="\s*(((if|while)\s*\(|else\s*|else\s+if\s*\(|for\s*\(.*\))[^{;]*)" />
        <PROPERTY NAME="unindentThisLine"
        	VALUE="^.*(default:\s*|case.*:.*)$" />
        <PROPERTY NAME="electricKeys" VALUE=":" />
        <!-- set this to 'true' if you want to use GNU coding style -->
        <PROPERTY NAME="doubleBracketIndent" VALUE="false" />
        <PROPERTY NAME="lineUpClosingBracket" VALUE="true" />
    </PROPS>

Prev | Up | Next
The Preamble and MODE tag | Home | The RULES Tag