Previous: , Up: Syntax   [Contents][Index]


27.5.2 Altering Syntax Information

It is possible to alter a character’s syntax table entry by storing a new number in the appropriate element of the syntax table, but it would be hard to determine what number to use. Emacs therefore provides a command that allows you to specify the syntactic properties of a character in a convenient way.

M-x modify-syntax-entry is the command to change a character’s syntax. It can be used interactively and is also used by major modes to initialize their own syntax tables. Its first argument is the character to change. The second argument is a string that specifies the new syntax. When called from Lisp code, there is a third, optional argument, which specifies the syntax table in which to make the change. If not supplied, or if this command is called interactively, the third argument defaults to the current buffer’s syntax table.

  1. The first character in the string specifies the syntactic class. It is one of the characters in the previous table (see Syntax Entry).
  2. The second character is the matching delimiter. For a character that is not an opening or closing delimiter, this should be a space, and may be omitted if no following characters are needed.
  3. The remaining characters are flags. The flag characters allowed are:
    1

    Flag this character as the first of a two-character comment starting sequence.

    2

    Flag this character as the second of a two-character comment starting sequence.

    3

    Flag this character as the first of a two-character comment ending sequence.

    4

    Flag this character as the second of a two-character comment ending sequence.

Use C-h s (describe-syntax) to display a description of the contents of the current syntax table. The description of each character includes both the string you have to pass to modify-syntax-entry to set up that character’s current syntax, and some English to explain that string if necessary.


Previous: , Up: Syntax   [Contents][Index]