annotate man/lispref/syntax.texi @ 939:025200a2163c

[xemacs-hg @ 2002-07-31 07:23:39 by michaels] 2002-07-17 Marcus Crestani <crestani@informatik.uni-tuebingen.de> Markus Kaltenbach <makalten@informatik.uni-tuebingen.de> Mike Sperber <mike@xemacs.org> configure flag to turn these changes on: --use-kkcc First we added a dumpable flag to lrecord_implementation. It shows, if the object is dumpable and should be processed by the dumper. * lrecord.h (struct lrecord_implementation): added dumpable flag (MAKE_LRECORD_IMPLEMENTATION): fitted the different makro definitions to the new lrecord_implementation and their calls. Then we changed mark_object, that it no longer needs a mark method for those types that have pdump descritions. * alloc.c: (mark_object): If the object has a description, the new mark algorithm is called, and the object is marked according to its description. Otherwise it uses the mark method like before. These procedures mark objects according to their descriptions. They are modeled on the corresponding pdumper procedures. (mark_with_description): (get_indirect_count): (structure_size): (mark_struct_contents): These procedures still call mark_object, this is needed while there are Lisp_Objects without descriptions left. We added pdump descriptions for many Lisp_Objects: * extents.c: extent_auxiliary_description * database.c: database_description * gui.c: gui_item_description * scrollbar.c: scrollbar_instance_description * toolbar.c: toolbar_button_description * event-stream.c: command_builder_description * mule-charset.c: charset_description * device-msw.c: devmode_description * dialog-msw.c: mswindows_dialog_id_description * eldap.c: ldap_description * postgresql.c: pgconn_description pgresult_description * tooltalk.c: tooltalk_message_description tooltalk_pattern_description * ui-gtk.c: emacs_ffi_description emacs_gtk_object_description * events.c: * events.h: * event-stream.c: * event-Xt.c: * event-gtk.c: * event-tty.c: To write a pdump description for Lisp_Event, we converted every struct in the union event to a Lisp_Object. So we created nine new Lisp_Objects: Lisp_Key_Data, Lisp_Button_Data, Lisp_Motion_Data, Lisp_Process_Data, Lisp_Timeout_Data, Lisp_Eval_Data, Lisp_Misc_User_Data, Lisp_Magic_Data, Lisp_Magic_Eval_Data. We also wrote makro selectors and mutators for the fields of the new designed Lisp_Event and added everywhere these new abstractions. We implemented XD_UNION support in (mark_with_description), so we can describe exspecially console/device specific data with XD_UNION. To describe with XD_UNION, we added a field to these objects, which holds the variant type of the object. This field is initialized in the appendant constructor. The variant is an integer, it has also to be described in an description, if XD_UNION is used. XD_UNION is used in following descriptions: * console.c: console_description (get_console_variant): returns the variant (create_console): added variant initialization * console.h (console_variant): the different console types * console-impl.h (struct console): added enum console_variant contype * device.c: device_description (Fmake_device): added variant initialization * device-impl.h (struct device): added enum console_variant devtype * objects.c: image_instance_description font_instance_description (Fmake_color_instance): added variant initialization (Fmake_font_instance): added variant initialization * objects-impl.h (struct Lisp_Color_Instance): added color_instance_type * objects-impl.h (struct Lisp_Font_Instance): added font_instance_type * process.c: process_description (make_process_internal): added variant initialization * process.h (process_variant): the different process types
author michaels
date Wed, 31 Jul 2002 07:23:39 +0000
parents 1ccc32a20af4
children ccaf90c5a53a
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
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 Under XEmacs 20, a syntax table is a particular subtype of the
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}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 @dfn{Whitespace characters} (designated with @w{@samp{@ }} or @samp{-})
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,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 newline and formfeed are almost always classified as whitespace.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 @deffn {Syntax class} @w{word constituent}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 @dfn{Word constituents} (designated with @samp{w}) are parts of normal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 English words and are typically used in variable and command names in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 programs. All upper- and lower-case letters, and the digits, are typically
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 word constituents.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 @deffn {Syntax class} @w{symbol constituent}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 @dfn{Symbol constituents} (designated with @samp{_}) are the extra
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 characters that are used in variable and command names along with word
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 constituents. For example, the symbol constituents class is used in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 Lisp mode to indicate that certain characters may be part of symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 names even though they are not part of English words. These characters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 are @samp{$&*+-_<>}. In standard C, the only non-word-constituent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 character that is valid in symbols is underscore (@samp{_}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 @deffn {Syntax class} @w{punctuation character}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 @dfn{Punctuation characters} (@samp{.}) are those characters that are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 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
163 language to separate symbols from one another. Most programming
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 language modes, including Emacs Lisp mode, have no characters in this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 class since the few characters that are not symbol or word constituents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 all have other uses.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 @deffn {Syntax class} @w{open parenthesis character}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 @deffnx {Syntax class} @w{close parenthesis character}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 @cindex parenthesis syntax
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 Open and close @dfn{parenthesis characters} are characters used in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 dissimilar pairs to surround sentences or expressions. Such a grouping
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 is begun with an open parenthesis character and terminated with a close.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 Each open parenthesis character matches a particular close parenthesis
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 character, and vice versa. Normally, XEmacs indicates momentarily the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 matching open parenthesis when you insert a close parenthesis.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 @xref{Blinking}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 The class of open parentheses is designated with @samp{(}, and that of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 close parentheses with @samp{)}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 In English text, and in C code, the parenthesis pairs are @samp{()},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 @samp{[]}, and @samp{@{@}}. In XEmacs Lisp, the delimiters for lists and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 vectors (@samp{()} and @samp{[]}) are classified as parenthesis
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 characters.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 @deffn {Syntax class} @w{string quote}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 @dfn{String quote characters} (designated with @samp{"}) are used in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 many languages, including Lisp and C, to delimit string constants. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 same string quote character appears at the beginning and the end of a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 string. Such quoted strings do not nest.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 The parsing facilities of XEmacs consider a string as a single token.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 The usual syntactic meanings of the characters in the string are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 suppressed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 The Lisp modes have two string quote characters: double-quote (@samp{"})
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 and vertical bar (@samp{|}). @samp{|} is not used in XEmacs Lisp, but it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 is used in Common Lisp. C also has two string quote characters:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 double-quote for strings, and single-quote (@samp{'}) for character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 constants.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 English text has no string quote characters because English is not a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 programming language. Although quotation marks are used in English,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 we do not want them to turn off the usual syntactic properties of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 other characters in the quotation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 @deffn {Syntax class} @w{escape}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 An @dfn{escape character} (designated with @samp{\}) starts an escape
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 sequence such as is used in C string and character constants. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 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
215 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
216 to treat it this way throughout C code.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 Characters in this class count as part of words if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 @code{words-include-escapes} is non-@code{nil}. @xref{Word Motion}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 @deffn {Syntax class} @w{character quote}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 A @dfn{character quote character} (designated with @samp{/}) quotes the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 following character so that it loses its normal syntactic meaning. This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 differs from an escape character in that only the character immediately
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 following is ever affected.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 Characters in this class count as part of words if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 @code{words-include-escapes} is non-@code{nil}. @xref{Word Motion}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 This class is used for backslash in @TeX{} mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 @deffn {Syntax class} @w{paired delimiter}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 @dfn{Paired delimiter characters} (designated with @samp{$}) are like
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 string quote characters except that the syntactic properties of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 characters between the delimiters are not suppressed. Only @TeX{} mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 uses a paired delimiter presently---the @samp{$} that both enters and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 leaves math mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 @deffn {Syntax class} @w{expression prefix}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 An @dfn{expression prefix operator} (designated with @samp{'}) is used
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 for syntactic operators that are part of an expression if they appear
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 next to one. These characters in Lisp include the apostrophe, @samp{'}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (used for quoting), the comma, @samp{,} (used in macros), and @samp{#}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (used in the read syntax for certain data types).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 @deffn {Syntax class} @w{comment starter}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 @deffnx {Syntax class} @w{comment ender}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 @cindex comment syntax
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 The @dfn{comment starter} and @dfn{comment ender} characters are used in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 various languages to delimit comments. These classes are designated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 with @samp{<} and @samp{>}, respectively.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 English text has no comment characters. In Lisp, the semicolon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (@samp{;}) starts a comment and a newline or formfeed ends one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 @deffn {Syntax class} @w{inherit}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 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
263 standard syntax table to find the syntax of this character. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 designator for this syntax code is @samp{@@}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 @node Syntax Flags
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 @subsection Syntax Flags
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 @cindex syntax flags
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 In addition to the classes, entries for characters in a syntax table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 can include flags. There are six possible flags, represented by the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 characters @samp{1}, @samp{2}, @samp{3}, @samp{4}, @samp{b} and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 @samp{p}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 All the flags except @samp{p} are used to describe multi-character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 comment delimiters. The digit flags indicate that a character can
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 @emph{also} be part of a comment sequence, in addition to the syntactic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 properties associated with its character class. The flags are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 independent of the class and each other for the sake of characters such
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 as @samp{*} in C mode, which is a punctuation character, @emph{and} the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 second character of a start-of-comment sequence (@samp{/*}), @emph{and}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 the first character of an end-of-comment sequence (@samp{*/}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 The flags for a character @var{c} are:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 @itemize @bullet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 @samp{1} means @var{c} is the start of a two-character comment-start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 sequence.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 @samp{2} means @var{c} is the second character of such a sequence.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 @samp{3} means @var{c} is the start of a two-character comment-end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 sequence.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 @samp{4} means @var{c} is the second character of such a sequence.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 @c Emacs 19 feature
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 @samp{b} means that @var{c} as a comment delimiter belongs to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 alternative ``b'' comment style.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 Emacs supports two comment styles simultaneously in any one syntax
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 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
309 its own comment-start sequence and its own comment-end sequence. Each
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 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
311 the comment-start sequence of style ``b'', it must also end with the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 comment-end sequence of style ``b''.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 The two comment-start sequences must begin with the same character; only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 the second character may differ. Mark the second character of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 ``b''-style comment-start sequence with the @samp{b} flag.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 A comment-end sequence (one or two characters) applies to the ``b''
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 style if its first character has the @samp{b} flag set; otherwise, it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 applies to the ``a'' style.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 The appropriate comment syntax settings for C++ are as follows:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 @table @asis
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 @item @samp{/}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 @samp{124b}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 @item @samp{*}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 @samp{23}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 @item newline
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 @samp{>b}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 This defines four comment-delimiting sequences:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 @table @asis
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 @item @samp{/*}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 This is a comment-start sequence for ``a'' style because the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 second character, @samp{*}, does not have the @samp{b} flag.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 @item @samp{//}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 This is a comment-start sequence for ``b'' style because the second
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 character, @samp{/}, does have the @samp{b} flag.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 @item @samp{*/}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 This is a comment-end sequence for ``a'' style because the first
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 character, @samp{*}, does not have the @samp{b} flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 @item newline
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 This is a comment-end sequence for ``b'' style, because the newline
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 character has the @samp{b} flag.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 @c Emacs 19 feature
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 @samp{p} identifies an additional ``prefix character'' for Lisp syntax.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 These characters are treated as whitespace when they appear between
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 expressions. When they appear within an expression, they are handled
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 according to their usual syntax codes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 The function @code{backward-prefix-chars} moves back over these
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 characters, as well as over characters whose primary syntax class is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 prefix (@samp{'}). @xref{Motion and Syntax}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 @end itemize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 @node Syntax Table Functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 @section Syntax Table Functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 In this section we describe functions for creating, accessing and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 altering syntax tables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 0
diff changeset
371 @defun make-syntax-table &optional oldtable
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 This function creates a new syntax table. Character codes 0 through
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 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
374 table. The other character codes are set up by copying what the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 standard syntax table says about them.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 Most major mode syntax tables are created in this way.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 0
diff changeset
380 @defun copy-syntax-table &optional syntax-table
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 0
diff changeset
381 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
382 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
383 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
384 @var{syntax-table} is not a syntax table.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 0
diff changeset
387 @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
388 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
389 @var{syntax-descriptor}. @var{char-range} is either a single character
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 0
diff changeset
390 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
391 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
392 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
393 @var{syntax-descriptor} specifies the desired syntax; this is a string
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 0
diff changeset
394 beginning with a class designator character, and optionally containing a
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 0
diff changeset
395 matching character and flags as well. @xref{Syntax Descriptors}.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 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
398 the table for @var{char-range} is discarded.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 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
401 one of the twelve syntax class designator characters.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 @exdent @r{Examples:}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 ;; @r{Put the space character in class whitespace.}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 (modify-syntax-entry ?\ " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 @result{} nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 ;; @r{Make @samp{$} an open parenthesis character,}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 ;; @r{with @samp{^} as its matching close.}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (modify-syntax-entry ?$ "(^")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 @result{} nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 ;; @r{Make @samp{^} a close parenthesis character,}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 ;; @r{with @samp{$} as its matching open.}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (modify-syntax-entry ?^ ")$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 @result{} nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 ;; @r{Make @samp{/} a punctuation character,}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 ;; @r{the first character of a start-comment sequence,}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 ;; @r{and the second character of an end-comment sequence.}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 ;; @r{This is used in C mode.}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 (modify-syntax-entry ?/ ". 14")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 @result{} nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 0
diff changeset
437 @defun char-syntax character &optional syntax-table
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 This function returns the syntax class of @var{character}, represented
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 by its mnemonic designator character. This @emph{only} returns the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 class, not any matching parenthesis or flags.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 0
diff changeset
442 An error is signaled if @var{character} is not a character.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 0
diff changeset
443
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 0
diff changeset
444 The characters that correspond to various syntax codes
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 0
diff changeset
445 are listed in the documentation of @code{modify-syntax-entry}.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 0
diff changeset
446
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 0
diff changeset
447 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
448 used, and defaults to the current buffer's syntax table.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 The following examples apply to C mode. The first example shows that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 the syntax class of space is whitespace (represented by a space). The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 second example shows that the syntax of @samp{/} is punctuation. This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 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
454 sequences. The third example shows that open parenthesis is in the class
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 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
456 character, @samp{)}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (char-to-string (char-syntax ?\ ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 @result{} " "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (char-to-string (char-syntax ?/))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 @result{} "."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 (char-to-string (char-syntax ?\())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 @result{} "("
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 0
diff changeset
476 @defun set-syntax-table syntax-table &optional buffer
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 0
diff changeset
477 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
478 defaults to the current buffer if omitted. It returns @var{syntax-table}.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 @defun syntax-table &optional buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 This function returns the syntax table for @var{buffer}, which defaults
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 to the current buffer if omitted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 @node Motion and Syntax
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 @section Motion and Syntax
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 This section describes functions for moving across characters in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 certain syntax classes. None of these functions exists in Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 version 18 or earlier.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 @defun skip-syntax-forward syntaxes &optional limit buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 This function moves point forward across characters having syntax classes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 mentioned in @var{syntaxes}. It stops when it encounters the end of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 the buffer, or position @var{limit} (if specified), or a character it is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 not supposed to skip. Optional argument @var{buffer} defaults to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 current buffer if omitted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 @ignore @c may want to change this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 The return value is the distance traveled, which is a nonnegative
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 integer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 @end ignore
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 @defun skip-syntax-backward syntaxes &optional limit buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 This function moves point backward across characters whose syntax
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 classes are mentioned in @var{syntaxes}. It stops when it encounters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 the beginning of the buffer, or position @var{limit} (if specified), or a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 character it is not supposed to skip. Optional argument @var{buffer}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 defaults to the current buffer if omitted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 @ignore @c may want to change this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 The return value indicates the distance traveled. It is an integer that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 is zero or less.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 @end ignore
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 @defun backward-prefix-chars &optional buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 This function moves point backward over any number of characters with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 expression prefix syntax. This includes both characters in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 expression prefix syntax class, and characters with the @samp{p} flag.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 Optional argument @var{buffer} defaults to the current buffer if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 omitted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 @node Parsing Expressions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 @section Parsing Balanced Expressions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 Here are several functions for parsing and scanning balanced
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 expressions, also known as @dfn{sexps}, in which parentheses match in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 pairs. The syntax table controls the interpretation of characters, so
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 these functions can be used for Lisp expressions when in Lisp mode and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 for C expressions when in C mode. @xref{List Motion}, for convenient
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 higher-level functions for moving over balanced expressions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 @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
537 This function parses a sexp in the current buffer starting at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 @var{start}, not scanning past @var{limit}. It stops at position
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 @var{limit} or when certain criteria described below are met, and sets
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 point to the location where parsing stops. It returns a value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 describing the status of the parse at the point where it stops.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 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
544 level of parenthesis structure, such as the beginning of a function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 definition. Alternatively, you might wish to resume parsing in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 middle of the structure. To do this, you must provide a @var{state}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 argument that describes the initial status of parsing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 @cindex parenthesis depth
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 If the third argument @var{target-depth} is non-@code{nil}, parsing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 stops if the depth in parentheses becomes equal to @var{target-depth}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 The depth starts at 0, or at whatever is given in @var{state}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 If the fourth argument @var{stop-before} is non-@code{nil}, parsing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 stops when it comes to any character that starts a sexp. If
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 @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
557 start of a comment.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 @cindex parse state
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 The fifth argument @var{state} is an eight-element list of the same
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 form as the value of this function, described below. The return value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 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
563 call to @code{parse-partial-sexp}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 The result is a list of eight elements describing the final state of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 the parse:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 @enumerate 0
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 0
diff changeset
569 @item
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 The depth in parentheses, counting from 0.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 0
diff changeset
572 @item
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 @cindex innermost containing parentheses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 The character position of the start of the innermost parenthetical
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 grouping containing the stopping point; @code{nil} if none.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 0
diff changeset
577 @item
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 @cindex previous complete subexpression
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 The character position of the start of the last complete subexpression
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 terminated; @code{nil} if none.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 0
diff changeset
582 @item
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 @cindex inside string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 Non-@code{nil} if inside a string. More precisely, this is the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 character that will terminate the string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 0
diff changeset
587 @item
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 @cindex inside comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 @code{t} if inside a comment (of either style).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 0
diff changeset
591 @item
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 @cindex quote character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 @code{t} if point is just after a quote character.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 0
diff changeset
595 @item
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 The minimum parenthesis depth encountered during this scan.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 @code{t} if inside a comment of style ``b''.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 @end enumerate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 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
603
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 @cindex indenting with parentheses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 This function is most often used to compute indentation for languages
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 that have nested parentheses.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 @defun scan-lists from count depth &optional buffer noerror
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 This function scans forward @var{count} balanced parenthetical groupings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 from character number @var{from}. It returns the character position
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 where the scan stops.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 If @var{depth} is nonzero, parenthesis depth counting begins from that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 value. The only candidates for stopping are places where the depth in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 parentheses becomes zero; @code{scan-lists} counts @var{count} such
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 places and then stops. Thus, a positive value for @var{depth} means go
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 out @var{depth} levels of parenthesis.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 Scanning ignores comments if @code{parse-sexp-ignore-comments} is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 non-@code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 If the scan reaches the beginning or end of the buffer (or its
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 accessible portion), and the depth is not zero, an error is signaled.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 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
626 returned.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 If optional arg @var{buffer} is non-@code{nil}, scanning occurs in that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 buffer instead of in the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 If optional arg @var{noerror} is non-@code{nil}, @code{scan-lists}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 will return @code{nil} instead of signalling an error.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 @defun scan-sexps from count &optional buffer noerror
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 This function scans forward @var{count} sexps from character position
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 @var{from}. It returns the character position where the scan stops.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 Scanning ignores comments if @code{parse-sexp-ignore-comments} is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 non-@code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 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
643 buffer in the middle of a parenthetical grouping, an error is signaled.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 If it reaches the beginning or end between groupings but before count is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 used up, @code{nil} is returned.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 If optional arg @var{buffer} is non-@code{nil}, scanning occurs in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 that buffer instead of in the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 If optional arg @var{noerror} is non-@code{nil}, @code{scan-sexps}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 will return nil instead of signalling an error.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 @defvar parse-sexp-ignore-comments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 @cindex skipping comments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 If the value is non-@code{nil}, then comments are treated as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 whitespace by the functions in this section and by @code{forward-sexp}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 In older Emacs versions, this feature worked only when the comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 terminator is something like @samp{*/}, and appears only to end a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 comment. In languages where newlines terminate comments, it was
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 necessary make this variable @code{nil}, since not every newline is the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 end of a comment. This limitation no longer exists.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 @end defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 You can use @code{forward-comment} to move forward or backward over
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 one comment or several comments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
669 @defun forward-comment &optional count buffer
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 This function moves point forward across @var{count} comments (backward,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 if @var{count} is negative). If it finds anything other than a comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 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
673 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
674
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
675 Optional argument @var{buffer} defaults to the current buffer.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 To move forward over all comments and whitespace following point, use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 @code{(forward-comment (buffer-size))}. @code{(buffer-size)} is a good
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 argument to use, because the number of comments in the buffer cannot
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 exceed that many.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 @node Standard Syntax Tables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 @section Some Standard Syntax Tables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 Most of the major modes in XEmacs have their own syntax tables. Here
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 are several of them:
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 standard-syntax-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 This function returns the standard syntax table, which is the syntax
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 table used in Fundamental mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 @defvar text-mode-syntax-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 The value of this variable is the syntax table used in Text mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 @end defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 @defvar c-mode-syntax-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 The value of this variable is the syntax table for C-mode buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 @end defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 @defvar emacs-lisp-mode-syntax-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 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
704 by editing commands. (It has no effect on the Lisp @code{read}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 function.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 @end defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 @node Syntax Table Internals
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 @section Syntax Table Internals
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 @cindex syntax table internals
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 Each element of a syntax table is an integer that encodes the syntax
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 of one character: the syntax class, possible matching character, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 flags. Lisp programs don't usually work with the elements directly; the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 Lisp-level syntax table functions usually work with syntax descriptors
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 (@pxref{Syntax Descriptors}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 The low 8 bits of each element of a syntax table indicate the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 syntax class.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 @table @asis
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 @item @i{Integer}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 @i{Class}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 @item 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 whitespace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 @item 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 punctuation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 @item 2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 word
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 @item 3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 @item 4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 open parenthesis
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 @item 5
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 close parenthesis
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 @item 6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 expression prefix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 @item 7
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 string quote
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 @item 8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 paired delimiter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 @item 9
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 escape
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 @item 10
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 character quote
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 @item 11
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 comment-start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 @item 12
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 comment-end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 @item 13
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 inherit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 The next 8 bits are the matching opposite parenthesis (if the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 character has parenthesis syntax); otherwise, they are not meaningful.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 The next 6 bits are the flags.