annotate man/lispref/syntax.texi @ 1024:ccaf90c5a53a

[xemacs-hg @ 2002-10-02 09:29:37 by stephent] 21.4 -> R21.5 stuff manual improvements <87k7l1p6su.fsf@tleepslib.sk.tsukuba.ac.jp> regexp tests <87fzvpp6mf.fsf@tleepslib.sk.tsukuba.ac.jp> add-to-list doc Ville Skyttä <87bs6dp6io.fsf@tleepslib.sk.tsukuba.ac.jp> Move filename associations Ville Skyttä <877kh1p6ee.fsf@tleepslib.sk.tsukuba.ac.jp> lookup-syntax-properties <87admil2e0.fsf_-_@tleepslib.sk.tsukuba.ac.jp> fix stale submatches <873crpp50v.fsf_-_@tleepslib.sk.tsukuba.ac.jp> info for developers <87y99hnqc4.fsf@tleepslib.sk.tsukuba.ac.jp>
author stephent
date Wed, 02 Oct 2002 09:31:40 +0000
parents 1ccc32a20af4
children 9fae6227ede5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 @c -*-texinfo-*-
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 @c This is part of the XEmacs Lisp Reference Manual.
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 0
diff changeset
3 @c Copyright (C) 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 @c See the file lispref.texi for copying conditions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 @setfilename ../../info/syntax.info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 @node Syntax Tables, Abbrevs, Searching and Matching, Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 @chapter Syntax Tables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 @cindex parsing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 @cindex syntax table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 @cindex text parsing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 A @dfn{syntax table} specifies the syntactic textual function of each
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 character. This information is used by the parsing commands, the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 complex movement commands, and others to determine where words, symbols,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 and other syntactic constructs begin and end. The current syntax table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 controls the meaning of the word motion functions (@pxref{Word Motion})
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 and the list motion functions (@pxref{List Motion}) as well as the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 functions in this chapter.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 @menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 * Basics: Syntax Basics. Basic concepts of syntax tables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 * Desc: Syntax Descriptors. How characters are classified.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 * Syntax Table Functions:: How to create, examine and alter syntax tables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 * Motion and Syntax:: Moving over characters with certain syntaxes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 * Parsing Expressions:: Parsing balanced expressions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 using the syntax table.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 * Standard Syntax Tables:: Syntax tables used by various major modes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 * Syntax Table Internals:: How syntax table information is stored.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 @end menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 @node Syntax Basics
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 @section Syntax Table Concepts
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 @ifinfo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 A @dfn{syntax table} provides Emacs with the information that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 determines the syntactic use of each character in a buffer. This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 information is used by the parsing commands, the complex movement
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 commands, and others to determine where words, symbols, and other
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 syntactic constructs begin and end. The current syntax table controls
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 the meaning of the word motion functions (@pxref{Word Motion}) and the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 list motion functions (@pxref{List Motion}) as well as the functions in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 this chapter.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 @end ifinfo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44
1024
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
45 Under XEmacs 20 and later, a syntax table is a particular subtype of the
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 primitive char table type (@pxref{Char Tables}), and each element of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 char table is an integer that encodes the syntax of the character in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 question, or a cons of such an integer and a matching character (for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 characters with parenthesis syntax).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 Under XEmacs 19, a syntax table is a vector of 256 elements; it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 contains one entry for each of the 256 possible characters in an 8-bit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 byte. Each element is an integer that encodes the syntax of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 character in question. (The matching character, if any, is embedded
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 in the bits of this integer.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 Syntax tables are used only for moving across text, not for the Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 Lisp reader. XEmacs Lisp uses built-in syntactic rules when reading Lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 expressions, and these rules cannot be changed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 Each buffer has its own major mode, and each major mode has its own
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 idea of the syntactic class of various characters. For example, in Lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 mode, the character @samp{;} begins a comment, but in C mode, it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 terminates a statement. To support these variations, XEmacs makes the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 choice of syntax table local to each buffer. Typically, each major
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 mode has its own syntax table and installs that table in each buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 that uses that mode. Changing this table alters the syntax in all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 those buffers as well as in any buffers subsequently put in that mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 Occasionally several similar modes share one syntax table.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 @xref{Example Major Modes}, for an example of how to set up a syntax
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 table.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 A syntax table can inherit the data for some characters from the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 standard syntax table, while specifying other characters itself. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 ``inherit'' syntax class means ``inherit this character's syntax from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 the standard syntax table.'' Most major modes' syntax tables inherit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 the syntax of character codes 0 through 31 and 128 through 255. This is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 useful with character sets such as ISO Latin-1 that have additional
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 alphabetic characters in the range 128 to 255. Just changing the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 standard syntax for these characters affects all major modes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 @defun syntax-table-p object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 This function returns @code{t} if @var{object} is a vector of length 256
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 elements. This means that the vector may be a syntax table. However,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 according to this test, any vector of length 256 is considered to be a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 syntax table, no matter what its contents.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 @node Syntax Descriptors
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 @section Syntax Descriptors
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 @cindex syntax classes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 This section describes the syntax classes and flags that denote the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 syntax of a character, and how they are represented as a @dfn{syntax
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 descriptor}, which is a Lisp string that you pass to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 @code{modify-syntax-entry} to specify the desired syntax.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 XEmacs defines a number of @dfn{syntax classes}. Each syntax table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 puts each character into one class. There is no necessary relationship
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 between the class of a character in one syntax table and its class in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 any other table.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 Each class is designated by a mnemonic character, which serves as the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 name of the class when you need to specify a class. Usually the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 designator character is one that is frequently in that class; however,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 its meaning as a designator is unvarying and independent of what syntax
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 that character currently has.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 @cindex syntax descriptor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 A syntax descriptor is a Lisp string that specifies a syntax class, a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 matching character (used only for the parenthesis classes) and flags.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 The first character is the designator for a syntax class. The second
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 character is the character to match; if it is unused, put a space there.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 Then come the characters for any desired flags. If no matching
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 character or flags are needed, one character is sufficient.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 For example, the descriptor for the character @samp{*} in C mode is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 @samp{@w{. 23}} (i.e., punctuation, matching character slot unused,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 second character of a comment-starter, first character of an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 comment-ender), and the entry for @samp{/} is @samp{@w{. 14}} (i.e.,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 punctuation, matching character slot unused, first character of a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 comment-starter, second character of a comment-ender).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 @menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 * Syntax Class Table:: Table of syntax classes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 * Syntax Flags:: Additional flags each character can have.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 @end menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 @node Syntax Class Table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 @subsection Table of Syntax Classes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 Here is a table of syntax classes, the characters that stand for them,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 their meanings, and examples of their use.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 @deffn {Syntax class} @w{whitespace character}
1024
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
136 @dfn{Whitespace characters} (designated with @samp{-})
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 separate symbols and words from each other. Typically, whitespace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 characters have no other syntactic significance, and multiple whitespace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 characters are syntactically equivalent to a single one. Space, tab,
1024
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
140 newline and formfeed are almost always classified as whitespace. (The
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
141 designator @w{@samp{@ }} is accepted for backwards compatibility with
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
142 older versions of XEmacs, but is deprecated. It is invalid in GNU Emacs.)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 @deffn {Syntax class} @w{word constituent}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 @dfn{Word constituents} (designated with @samp{w}) are parts of normal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 English words and are typically used in variable and command names in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 programs. All upper- and lower-case letters, and the digits, are typically
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 word constituents.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 @deffn {Syntax class} @w{symbol constituent}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 @dfn{Symbol constituents} (designated with @samp{_}) are the extra
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 characters that are used in variable and command names along with word
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 constituents. For example, the symbol constituents class is used in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 Lisp mode to indicate that certain characters may be part of symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 names even though they are not part of English words. These characters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 are @samp{$&*+-_<>}. In standard C, the only non-word-constituent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 character that is valid in symbols is underscore (@samp{_}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 @deffn {Syntax class} @w{punctuation character}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 @dfn{Punctuation characters} (@samp{.}) are those characters that are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 used as punctuation in English, or are used in some way in a programming
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 language to separate symbols from one another. Most programming
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 language modes, including Emacs Lisp mode, have no characters in this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 class since the few characters that are not symbol or word constituents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 all have other uses.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 @deffn {Syntax class} @w{open parenthesis character}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 @deffnx {Syntax class} @w{close parenthesis character}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 @cindex parenthesis syntax
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 Open and close @dfn{parenthesis characters} are characters used in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 dissimilar pairs to surround sentences or expressions. Such a grouping
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 is begun with an open parenthesis character and terminated with a close.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 Each open parenthesis character matches a particular close parenthesis
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 character, and vice versa. Normally, XEmacs indicates momentarily the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 matching open parenthesis when you insert a close parenthesis.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 @xref{Blinking}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 The class of open parentheses is designated with @samp{(}, and that of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 close parentheses with @samp{)}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 In English text, and in C code, the parenthesis pairs are @samp{()},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 @samp{[]}, and @samp{@{@}}. In XEmacs Lisp, the delimiters for lists and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 vectors (@samp{()} and @samp{[]}) are classified as parenthesis
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 characters.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 @deffn {Syntax class} @w{string quote}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 @dfn{String quote characters} (designated with @samp{"}) are used in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 many languages, including Lisp and C, to delimit string constants. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 same string quote character appears at the beginning and the end of a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 string. Such quoted strings do not nest.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 The parsing facilities of XEmacs consider a string as a single token.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 The usual syntactic meanings of the characters in the string are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 suppressed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 The Lisp modes have two string quote characters: double-quote (@samp{"})
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 and vertical bar (@samp{|}). @samp{|} is not used in XEmacs Lisp, but it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 is used in Common Lisp. C also has two string quote characters:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 double-quote for strings, and single-quote (@samp{'}) for character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 constants.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 English text has no string quote characters because English is not a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 programming language. Although quotation marks are used in English,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 we do not want them to turn off the usual syntactic properties of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 other characters in the quotation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 @deffn {Syntax class} @w{escape}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 An @dfn{escape character} (designated with @samp{\}) starts an escape
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 sequence such as is used in C string and character constants. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 character @samp{\} belongs to this class in both C and Lisp. (In C, it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 is used thus only inside strings, but it turns out to cause no trouble
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 to treat it this way throughout C code.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 Characters in this class count as part of words if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 @code{words-include-escapes} is non-@code{nil}. @xref{Word Motion}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 @deffn {Syntax class} @w{character quote}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 A @dfn{character quote character} (designated with @samp{/}) quotes the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 following character so that it loses its normal syntactic meaning. This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 differs from an escape character in that only the character immediately
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 following is ever affected.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 Characters in this class count as part of words if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 @code{words-include-escapes} is non-@code{nil}. @xref{Word Motion}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 This class is used for backslash in @TeX{} mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 @deffn {Syntax class} @w{paired delimiter}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 @dfn{Paired delimiter characters} (designated with @samp{$}) are like
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 string quote characters except that the syntactic properties of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 characters between the delimiters are not suppressed. Only @TeX{} mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 uses a paired delimiter presently---the @samp{$} that both enters and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 leaves math mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 @deffn {Syntax class} @w{expression prefix}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 An @dfn{expression prefix operator} (designated with @samp{'}) is used
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 for syntactic operators that are part of an expression if they appear
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 next to one. These characters in Lisp include the apostrophe, @samp{'}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (used for quoting), the comma, @samp{,} (used in macros), and @samp{#}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (used in the read syntax for certain data types).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 @deffn {Syntax class} @w{comment starter}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 @deffnx {Syntax class} @w{comment ender}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 @cindex comment syntax
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 The @dfn{comment starter} and @dfn{comment ender} characters are used in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 various languages to delimit comments. These classes are designated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 with @samp{<} and @samp{>}, respectively.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 English text has no comment characters. In Lisp, the semicolon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (@samp{;}) starts a comment and a newline or formfeed ends one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 @deffn {Syntax class} @w{inherit}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 This syntax class does not specify a syntax. It says to look in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 standard syntax table to find the syntax of this character. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 designator for this syntax code is @samp{@@}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 @node Syntax Flags
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 @subsection Syntax Flags
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 @cindex syntax flags
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272
1024
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
273 @c This is a bit inaccurate, the ``a'' and ``b'' flags actually don't
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
274 @c exist in the internal implementation. AFAICT it doesn't affect the
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
275 @c semantics as perceived by the LISP programmer.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 In addition to the classes, entries for characters in a syntax table
1024
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
277 can include flags. There are eleven possible flags, represented by the
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
278 digits @samp{1}--@samp{8}, and the lowercase letters @samp{a}, @samp{b},
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
279 and @samp{p}.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280
1024
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
281 All the flags except @samp{p} are used to describe comment delimiters.
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
282 The digit flags indicate that a character can @emph{also} be part of a
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
283 multi-character comment sequence, in addition to the syntactic
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
284 properties associated with its character class. The flags must be
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 independent of the class and each other for the sake of characters such
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 as @samp{*} in C mode, which is a punctuation character, @emph{and} the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 second character of a start-of-comment sequence (@samp{/*}), @emph{and}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 the first character of an end-of-comment sequence (@samp{*/}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 Emacs supports two comment styles simultaneously in any one syntax
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 table. This is for the sake of C++. Each style of comment syntax has
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 its own comment-start sequence and its own comment-end sequence. Each
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 comment must stick to one style or the other; thus, if it starts with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 the comment-start sequence of style ``b'', it must also end with the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 comment-end sequence of style ``b''.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296
1024
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
297 @c #### Compatibility note; index here.
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
298 As an extension to GNU Emacs 19 and 20, XEmacs supports two arbitrary
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
299 comment-start sequences and two arbitrary comment-end sequences. (Thus
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
300 the need for 8 flags.) GNU Emacs restricts the comment-start sequences
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
301 to start with the same character, XEmacs does not. This means that for
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
302 two-character sequences, where GNU Emacs uses the @samp{b} flag, XEmacs
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
303 uses the digit flags @samp{5}--@samp{8}.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304
1024
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
305 A one character comment-end sequence applies to the ``b'' style if its
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
306 first character has the @samp{b} flag set; otherwise, it applies to the
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
307 ``a'' style. The @samp{a} flag is optional. These flags have no effect
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
308 on non-comment characters; two-character styles are determined by the
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
309 digit flags.
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
310
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
311 The flags for a character @var{c} are:
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312
1024
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
313 @itemize @bullet
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
314 @item
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
315 @samp{1} means @var{c} is the start of a two-character comment-start
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
316 sequence of style ``a''.
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
317
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
318 @item
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
319 @samp{2} means @var{c} is the second character of such a sequence.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320
1024
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
321 @item
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
322 @samp{3} means @var{c} is the start of a two-character comment-end
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
323 sequence of style ``a''.
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
324
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
325 @item
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
326 @samp{4} means @var{c} is the second character of such a sequence.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327
1024
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
328 @item
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
329 @samp{5} means @var{c} is the start of a two-character comment-start
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
330 sequence of style ``b''.
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
331
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
332 @item
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
333 @samp{6} means @var{c} is the second character of such a sequence.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334
1024
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
335 @item
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
336 @samp{7} means @var{c} is the start of a two-character comment-end
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
337 sequence of style ``b''.
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
338
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
339 @item
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
340 @samp{8} means @var{c} is the second character of such a sequence.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341
1024
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
342 @item
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
343 @samp{a} means that @var{c} as a comment delimiter belongs to the
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
344 default ``a'' comment style. (This flag is optional.)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345
1024
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
346 @item
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
347 @c Emacs 19 feature
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
348 @samp{b} means that @var{c} as a comment delimiter belongs to the
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
349 alternate ``b'' comment style.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 @c Emacs 19 feature
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 @samp{p} identifies an additional ``prefix character'' for Lisp syntax.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 These characters are treated as whitespace when they appear between
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 expressions. When they appear within an expression, they are handled
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 according to their usual syntax codes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 The function @code{backward-prefix-chars} moves back over these
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 characters, as well as over characters whose primary syntax class is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 prefix (@samp{'}). @xref{Motion and Syntax}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 @end itemize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362
1024
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
363 Lisp (as you would expect) has a simple comment syntax.
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
364
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
365 @table @asis
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
366 @item @samp{;}
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
367 @samp{<}
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
368 @item newline
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
369 @samp{>}
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
370 @end table
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
371
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
372 Note that no flags are used.
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
373 This defines two comment-delimiting sequences:
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
374
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
375 @table @asis
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
376 @item @samp{;}
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
377 This is a single-character comment-start sequence because the syntax
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
378 class is @samp{<}.
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
379
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
380 @item newline
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
381 This is a single character comment-end sequence because the syntax class
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
382 is @samp{>} and the @samp{b} flag is not set.
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
383 @end table
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
384
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
385 C++ (again, as you would expect) has a baroque, overrich, and
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
386 excessively complex comment syntax.
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
387
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
388 @table @asis
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
389 @item @samp{/}
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
390 @samp{1456}
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
391 @item @samp{*}
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
392 @samp{23}
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
393 @item newline
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
394 @samp{>b}
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
395 @end table
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
396
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
397 Note that the ``b'' style mixes one-character and two-character
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
398 sequences. The table above defines four comment-delimiting sequences:
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
399
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
400 @table @asis
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
401 @item @samp{/*}
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
402 This is a comment-start sequence for ``a'' style because the @samp{1}
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
403 flag is set on @samp{/} and the @samp{2} flag is set on @samp{*}.
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
404
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
405 @item @samp{//}
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
406 This is a comment-start sequence for ``b'' style because both the @samp{5}
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
407 and the @samp{6} flags are set on @samp{/}.
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
408
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
409 @item @samp{*/}
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
410 This is a comment-end sequence for ``a'' style because the @samp{3}
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
411 flag is set on @samp{*} and the @samp{4} flag is set on @samp{/}.
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
412
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
413 @item newline
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
414 This is a comment-end sequence for ``b'' style, because the newline
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
415 character has the @samp{b} flag.
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
416 @end table
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
417
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 446
diff changeset
418
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 @node Syntax Table Functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 @section Syntax Table Functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 In this section we describe functions for creating, accessing and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 altering syntax tables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 0
diff changeset
425 @defun make-syntax-table &optional oldtable
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 This function creates a new syntax table. Character codes 0 through
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 31 and 128 through 255 are set up to inherit from the standard syntax
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 table. The other character codes are set up by copying what the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 standard syntax table says about them.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 Most major mode syntax tables are created in this way.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 0
diff changeset
434 @defun copy-syntax-table &optional syntax-table
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 0
diff changeset
435 This function constructs a copy of @var{syntax-table} and returns it.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 0
diff changeset
436 If @var{syntax-table} is not supplied (or is @code{nil}), it returns a
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 0
diff changeset
437 copy of the current syntax table. Otherwise, an error is signaled if
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 0
diff changeset
438 @var{syntax-table} is not a syntax table.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 0
diff changeset
441 @deffn Command modify-syntax-entry char-range syntax-descriptor &optional syntax-table
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 0
diff changeset
442 This function sets the syntax entry for @var{char-range} according to
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 0
diff changeset
443 @var{syntax-descriptor}. @var{char-range} is either a single character
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 0
diff changeset
444 or a range of characters, as used with @code{put-char-table}. The syntax
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 0
diff changeset
445 is changed only for @var{syntax-table}, which defaults to the current
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 0
diff changeset
446 buffer's syntax table, and not in any other syntax table. The argument
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 0
diff changeset
447 @var{syntax-descriptor} specifies the desired syntax; this is a string
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 0
diff changeset
448 beginning with a class designator character, and optionally containing a
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 0
diff changeset
449 matching character and flags as well. @xref{Syntax Descriptors}.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 This function always returns @code{nil}. The old syntax information in
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 0
diff changeset
452 the table for @var{char-range} is discarded.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 An error is signaled if the first character of the syntax descriptor is not
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 0
diff changeset
455 one of the twelve syntax class designator characters.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 @exdent @r{Examples:}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 ;; @r{Put the space character in class whitespace.}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (modify-syntax-entry ?\ " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 @result{} nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 ;; @r{Make @samp{$} an open parenthesis character,}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 ;; @r{with @samp{^} as its matching close.}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 (modify-syntax-entry ?$ "(^")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 @result{} nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 ;; @r{Make @samp{^} a close parenthesis character,}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 ;; @r{with @samp{$} as its matching open.}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (modify-syntax-entry ?^ ")$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 @result{} nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 ;; @r{Make @samp{/} a punctuation character,}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 ;; @r{the first character of a start-comment sequence,}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 ;; @r{and the second character of an end-comment sequence.}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 ;; @r{This is used in C mode.}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 (modify-syntax-entry ?/ ". 14")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 @result{} nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 0
diff changeset
491 @defun char-syntax character &optional syntax-table
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 This function returns the syntax class of @var{character}, represented
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 by its mnemonic designator character. This @emph{only} returns the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 class, not any matching parenthesis or flags.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 0
diff changeset
496 An error is signaled if @var{character} is not a character.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 0
diff changeset
497
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 0
diff changeset
498 The characters that correspond to various syntax codes
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 0
diff changeset
499 are listed in the documentation of @code{modify-syntax-entry}.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 0
diff changeset
500
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 0
diff changeset
501 Optional second argument @var{syntax-table} is the syntax table to be
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 0
diff changeset
502 used, and defaults to the current buffer's syntax table.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 The following examples apply to C mode. The first example shows that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 the syntax class of space is whitespace (represented by a space). The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 second example shows that the syntax of @samp{/} is punctuation. This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 does not show the fact that it is also part of comment-start and -end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 sequences. The third example shows that open parenthesis is in the class
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 of open parentheses. This does not show the fact that it has a matching
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 character, @samp{)}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 (char-to-string (char-syntax ?\ ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 @result{} " "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 (char-to-string (char-syntax ?/))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 @result{} "."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 (char-to-string (char-syntax ?\())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 @result{} "("
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 0
diff changeset
530 @defun set-syntax-table syntax-table &optional buffer
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 0
diff changeset
531 This function makes @var{syntax-table} the syntax table for @var{buffer}, which
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 0
diff changeset
532 defaults to the current buffer if omitted. It returns @var{syntax-table}.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 @defun syntax-table &optional buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 This function returns the syntax table for @var{buffer}, which defaults
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 to the current buffer if omitted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 @node Motion and Syntax
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 @section Motion and Syntax
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 This section describes functions for moving across characters in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 certain syntax classes. None of these functions exists in Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 version 18 or earlier.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 @defun skip-syntax-forward syntaxes &optional limit buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 This function moves point forward across characters having syntax classes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 mentioned in @var{syntaxes}. It stops when it encounters the end of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 the buffer, or position @var{limit} (if specified), or a character it is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 not supposed to skip. Optional argument @var{buffer} defaults to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 current buffer if omitted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 @ignore @c may want to change this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 The return value is the distance traveled, which is a nonnegative
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 integer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 @end ignore
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 @defun skip-syntax-backward syntaxes &optional limit buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 This function moves point backward across characters whose syntax
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 classes are mentioned in @var{syntaxes}. It stops when it encounters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 the beginning of the buffer, or position @var{limit} (if specified), or a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 character it is not supposed to skip. Optional argument @var{buffer}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 defaults to the current buffer if omitted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 @ignore @c may want to change this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 The return value indicates the distance traveled. It is an integer that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 is zero or less.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 @end ignore
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 @defun backward-prefix-chars &optional buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 This function moves point backward over any number of characters with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 expression prefix syntax. This includes both characters in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 expression prefix syntax class, and characters with the @samp{p} flag.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 Optional argument @var{buffer} defaults to the current buffer if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 omitted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 @node Parsing Expressions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 @section Parsing Balanced Expressions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 Here are several functions for parsing and scanning balanced
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 expressions, also known as @dfn{sexps}, in which parentheses match in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 pairs. The syntax table controls the interpretation of characters, so
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 these functions can be used for Lisp expressions when in Lisp mode and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 for C expressions when in C mode. @xref{List Motion}, for convenient
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 higher-level functions for moving over balanced expressions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 @defun parse-partial-sexp start limit &optional target-depth stop-before state stop-comment buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 This function parses a sexp in the current buffer starting at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 @var{start}, not scanning past @var{limit}. It stops at position
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 @var{limit} or when certain criteria described below are met, and sets
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 point to the location where parsing stops. It returns a value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 describing the status of the parse at the point where it stops.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 If @var{state} is @code{nil}, @var{start} is assumed to be at the top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 level of parenthesis structure, such as the beginning of a function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 definition. Alternatively, you might wish to resume parsing in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 middle of the structure. To do this, you must provide a @var{state}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 argument that describes the initial status of parsing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 @cindex parenthesis depth
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 If the third argument @var{target-depth} is non-@code{nil}, parsing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 stops if the depth in parentheses becomes equal to @var{target-depth}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 The depth starts at 0, or at whatever is given in @var{state}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 If the fourth argument @var{stop-before} is non-@code{nil}, parsing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 stops when it comes to any character that starts a sexp. If
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 @var{stop-comment} is non-@code{nil}, parsing stops when it comes to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 start of a comment.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 @cindex parse state
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 The fifth argument @var{state} is an eight-element list of the same
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 form as the value of this function, described below. The return value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 of one call may be used to initialize the state of the parse on another
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 call to @code{parse-partial-sexp}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 The result is a list of eight elements describing the final state of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 the parse:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 @enumerate 0
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 0
diff changeset
623 @item
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 The depth in parentheses, counting from 0.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 0
diff changeset
626 @item
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 @cindex innermost containing parentheses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 The character position of the start of the innermost parenthetical
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 grouping containing the stopping point; @code{nil} if none.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 0
diff changeset
631 @item
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 @cindex previous complete subexpression
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 The character position of the start of the last complete subexpression
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 terminated; @code{nil} if none.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 0
diff changeset
636 @item
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 @cindex inside string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 Non-@code{nil} if inside a string. More precisely, this is the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 character that will terminate the string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 0
diff changeset
641 @item
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 @cindex inside comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 @code{t} if inside a comment (of either style).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 0
diff changeset
645 @item
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 @cindex quote character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 @code{t} if point is just after a quote character.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 0
diff changeset
649 @item
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 The minimum parenthesis depth encountered during this scan.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 @code{t} if inside a comment of style ``b''.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 @end enumerate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 Elements 0, 3, 4, 5 and 7 are significant in the argument @var{state}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 @cindex indenting with parentheses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 This function is most often used to compute indentation for languages
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 that have nested parentheses.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 @defun scan-lists from count depth &optional buffer noerror
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 This function scans forward @var{count} balanced parenthetical groupings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 from character number @var{from}. It returns the character position
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 where the scan stops.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 If @var{depth} is nonzero, parenthesis depth counting begins from that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 value. The only candidates for stopping are places where the depth in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 parentheses becomes zero; @code{scan-lists} counts @var{count} such
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 places and then stops. Thus, a positive value for @var{depth} means go
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 out @var{depth} levels of parenthesis.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 Scanning ignores comments if @code{parse-sexp-ignore-comments} is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 non-@code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 If the scan reaches the beginning or end of the buffer (or its
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 accessible portion), and the depth is not zero, an error is signaled.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 If the depth is zero but the count is not used up, @code{nil} is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 returned.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 If optional arg @var{buffer} is non-@code{nil}, scanning occurs in that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 buffer instead of in the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 If optional arg @var{noerror} is non-@code{nil}, @code{scan-lists}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 will return @code{nil} instead of signalling an error.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 @defun scan-sexps from count &optional buffer noerror
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 This function scans forward @var{count} sexps from character position
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 @var{from}. It returns the character position where the scan stops.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 Scanning ignores comments if @code{parse-sexp-ignore-comments} is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 non-@code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 If the scan reaches the beginning or end of (the accessible part of) the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 buffer in the middle of a parenthetical grouping, an error is signaled.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 If it reaches the beginning or end between groupings but before count is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 used up, @code{nil} is returned.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 If optional arg @var{buffer} is non-@code{nil}, scanning occurs in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 that buffer instead of in the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 If optional arg @var{noerror} is non-@code{nil}, @code{scan-sexps}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 will return nil instead of signalling an error.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 @defvar parse-sexp-ignore-comments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 @cindex skipping comments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 If the value is non-@code{nil}, then comments are treated as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 whitespace by the functions in this section and by @code{forward-sexp}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 In older Emacs versions, this feature worked only when the comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 terminator is something like @samp{*/}, and appears only to end a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 comment. In languages where newlines terminate comments, it was
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 necessary make this variable @code{nil}, since not every newline is the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 end of a comment. This limitation no longer exists.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 @end defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 You can use @code{forward-comment} to move forward or backward over
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 one comment or several comments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
723 @defun forward-comment &optional count buffer
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 This function moves point forward across @var{count} comments (backward,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 if @var{count} is negative). If it finds anything other than a comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 or whitespace, it stops, leaving point at the place where it stopped.
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
727 It also stops after satisfying @var{count}. @var{count} defaults to @code{1}.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
729 Optional argument @var{buffer} defaults to the current buffer.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 To move forward over all comments and whitespace following point, use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 @code{(forward-comment (buffer-size))}. @code{(buffer-size)} is a good
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 argument to use, because the number of comments in the buffer cannot
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 exceed that many.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 @node Standard Syntax Tables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 @section Some Standard Syntax Tables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 Most of the major modes in XEmacs have their own syntax tables. Here
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 are several of them:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 @defun standard-syntax-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 This function returns the standard syntax table, which is the syntax
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 table used in Fundamental mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 @defvar text-mode-syntax-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 The value of this variable is the syntax table used in Text mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 @end defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 @defvar c-mode-syntax-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 The value of this variable is the syntax table for C-mode buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 @end defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 @defvar emacs-lisp-mode-syntax-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 The value of this variable is the syntax table used in Emacs Lisp mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 by editing commands. (It has no effect on the Lisp @code{read}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 function.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 @end defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 @node Syntax Table Internals
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 @section Syntax Table Internals
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 @cindex syntax table internals
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 Each element of a syntax table is an integer that encodes the syntax
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 of one character: the syntax class, possible matching character, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 flags. Lisp programs don't usually work with the elements directly; the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 Lisp-level syntax table functions usually work with syntax descriptors
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 (@pxref{Syntax Descriptors}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 The low 8 bits of each element of a syntax table indicate the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 syntax class.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 @table @asis
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 @item @i{Integer}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 @i{Class}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 @item 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 whitespace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 @item 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 punctuation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 @item 2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 word
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 @item 3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 @item 4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 open parenthesis
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 @item 5
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 close parenthesis
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 @item 6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 expression prefix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 @item 7
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 string quote
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 @item 8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 paired delimiter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 @item 9
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 escape
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 @item 10
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 character quote
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 @item 11
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 comment-start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 @item 12
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 comment-end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 @item 13
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 inherit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 The next 8 bits are the matching opposite parenthesis (if the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 character has parenthesis syntax); otherwise, they are not meaningful.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 The next 6 bits are the flags.