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


45.1 Syntax Table Concepts

Under all SXEmacs versions a syntax table is a particular subtype of the primitive char table type (see Char Tables), and each element of the char table is an integer that encodes the syntax of the character in question, or a cons of such an integer and a matching character (for characters with parenthesis syntax). XEmacs version 20 and later handles it this way, too.

Under XEmacs 19, a syntax table is a vector of 256 elements; it contains one entry for each of the 256 possible characters in an 8-bit byte. Each element is an integer that encodes the syntax of the character in question. (The matching character, if any, is embedded in the bits of this integer.)

Syntax tables are used only for moving across text, not for the Emacs Lisp reader. SXEmacs Lisp uses built-in syntactic rules when reading Lisp expressions, and these rules cannot be changed.

Each buffer has its own major mode, and each major mode has its own idea of the syntactic class of various characters. For example, in Lisp mode, the character ‘;’ begins a comment, but in C mode, it terminates a statement. To support these variations, SXEmacs makes the choice of syntax table local to each buffer. Typically, each major mode has its own syntax table and installs that table in each buffer that uses that mode. Changing this table alters the syntax in all those buffers as well as in any buffers subsequently put in that mode. Occasionally several similar modes share one syntax table. See Example Major Modes, for an example of how to set up a syntax table.

A syntax table can inherit the data for some characters from the standard syntax table, while specifying other characters itself. The “inherit” syntax class means “inherit this character’s syntax from the standard syntax table.” Most major modes’ syntax tables inherit the syntax of character codes 0 through 31 and 128 through 255. This is useful with character sets such as ISO Latin-1 that have additional alphabetic characters in the range 128 to 255. Just changing the standard syntax for these characters affects all major modes.

Function: syntax-table-p object

This function returns t if object is a vector of length 256 elements. This means that the vector may be a syntax table. However, according to this test, any vector of length 256 is considered to be a syntax table, no matter what its contents.


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