Merge: user-interface timestamps and other int overflow patches.
[bpt/emacs.git] / doc / lispref / syntax.texi
index 36907dd..55ee2de 100644 (file)
@@ -1,7 +1,7 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
-@c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1998, 1999, 2001,
-@c   2002, 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+@c Copyright (C) 1990-1995, 1998-1999, 2001-2011
+@c   Free Software Foundation, Inc.
 @c See the file elisp.texi for copying conditions.
 @setfilename ../../info/syntax
 @node Syntax Tables, Abbrevs, Searching and Matching, Top
@@ -23,7 +23,7 @@ functions in this chapter.
 * Desc: Syntax Descriptors.  How characters are classified.
 * Syntax Table Functions::   How to create, examine and alter syntax tables.
 * Syntax Properties::        Overriding syntax with text properties.
-* Motion and Syntax::       Moving over characters with certain syntaxes.
+* Motion and Syntax::        Moving over characters with certain syntaxes.
 * Parsing Expressions::      Parsing balanced expressions
                                 using the syntax table.
 * Standard Syntax Tables::   Syntax tables used by various major modes.
@@ -291,19 +291,21 @@ identifying them as generic string delimiters.
 @cindex syntax flags
 
   In addition to the classes, entries for characters in a syntax table
-can specify flags.  There are seven possible flags, represented by the
-characters @samp{1}, @samp{2}, @samp{3}, @samp{4}, @samp{b}, @samp{n},
-and @samp{p}.
-
-  All the flags except @samp{n} and @samp{p} are used to describe
-multi-character comment delimiters.  The digit flags indicate that a
-character can @emph{also} be part of a comment sequence, in addition to
-the syntactic properties associated with its character class.  The flags
-are independent of the class and each other for the sake of characters
-such as @samp{*} in C mode, which is a punctuation character, @emph{and}
-the second character of a start-of-comment sequence (@samp{/*}),
-@emph{and} the first character of an end-of-comment sequence
-(@samp{*/}).
+can specify flags.  There are eight possible flags, represented by the
+characters @samp{1}, @samp{2}, @samp{3}, @samp{4}, @samp{b}, @samp{c},
+@samp{n}, and @samp{p}.
+
+  All the flags except @samp{p} are used to describe comment
+delimiters.  The digit flags are used for comment delimiters made up
+of 2 characters.  They indicate that a character can @emph{also} be
+part of a comment sequence, in addition to the syntactic properties
+associated with its character class.  The flags are independent of the
+class and each other for the sake of characters such as @samp{*} in
+C mode, which is a punctuation character, @emph{and} the second
+character of a start-of-comment sequence (@samp{/*}), @emph{and} the
+first character of an end-of-comment sequence (@samp{*/}).  The flags
+@samp{b}, @samp{c}, and @samp{n} are used to qualify the corresponding
+comment delimiter.
 
   Here is a table of the possible flags for a character @var{c},
 and what they mean:
@@ -324,62 +326,61 @@ sequence.
 @samp{4} means @var{c} is the second character of such a sequence.
 
 @item
-@c Emacs 19 feature
 @samp{b} means that @var{c} as a comment delimiter belongs to the
-alternative ``b'' comment style.
+alternative ``b'' comment style.  For a two-character comment starter,
+this flag is only significant on the second char, and for a 2-character
+comment ender it is only significant on the first char.
 
-Emacs supports two comment styles simultaneously in any one syntax
-table.  This is for the sake of C++.  Each style of comment syntax has
-its own comment-start sequence and its own comment-end sequence.  Each
-comment must stick to one style or the other; thus, if it starts with
-the comment-start sequence of style ``b,'' it must also end with the
-comment-end sequence of style ``b.''
+@item
+@samp{c} means that @var{c} as a comment delimiter belongs to the
+alternative ``c'' comment style.  For a two-character comment
+delimiter, @samp{c} on either character makes it of style ``c''.
 
-The two comment-start sequences must begin with the same character; only
-the second character may differ.  Mark the second character of the
-``b''-style comment-start sequence with the @samp{b} flag.
+@item
+@samp{n} on a comment delimiter character specifies
+that this kind of comment can be nested.  For a two-character
+comment delimiter, @samp{n} on either character makes it
+nestable.
 
-A comment-end sequence (one or two characters) applies to the ``b''
-style if its first character has the @samp{b} flag set; otherwise, it
-applies to the ``a'' style.
+Emacs supports several comment styles simultaneously in any one syntax
+table.  A comment style is a set of flags @samp{b}, @samp{c}, and
+@samp{n}, so there can be up to 8 different comment styles.
+Each comment delimiter has a style and only matches comment delimiters
+of the same style.  Thus if a comment starts with the comment-start
+sequence of style ``bn'', it will extend until the next matching
+comment-end sequence of style ``bn''.
 
-The appropriate comment syntax settings for C++ are as follows:
+The appropriate comment syntax settings for C++ can be as follows:
 
 @table @asis
 @item @samp{/}
-@samp{124b}
+@samp{124}
 @item @samp{*}
-@samp{23}
+@samp{23b}
 @item newline
-@samp{>b}
+@samp{>}
 @end table
 
 This defines four comment-delimiting sequences:
 
 @table @asis
 @item @samp{/*}
-This is a comment-start sequence for ``a'' style because the
-second character, @samp{*}, does not have the @samp{b} flag.
+This is a comment-start sequence for ``b'' style because the
+second character, @samp{*}, has the @samp{b} flag.
 
 @item @samp{//}
-This is a comment-start sequence for ``b'' style because the second
-character, @samp{/}, does have the @samp{b} flag.
+This is a comment-start sequence for ``a'' style because the second
+character, @samp{/}, does not have the @samp{b} flag.
 
 @item @samp{*/}
-This is a comment-end sequence for ``a'' style because the first
-character, @samp{*}, does not have the @samp{b} flag.
+This is a comment-end sequence for ``b'' style because the first
+character, @samp{*}, does have the @samp{b} flag.
 
 @item newline
-This is a comment-end sequence for ``b'' style, because the newline
-character has the @samp{b} flag.
+This is a comment-end sequence for ``a'' style, because the newline
+character does not have the @samp{b} flag.
 @end table
 
-@item
-@samp{n} on a comment delimiter character specifies
-that this kind of comment can be nested.  For a two-character
-comment delimiter, @samp{n} on either character makes it
-nestable.
-
 @item
 @c Emacs 19 feature
 @samp{p} identifies an additional ``prefix character'' for Lisp syntax.
@@ -418,12 +419,17 @@ not a syntax table.
 
 @deffn Command modify-syntax-entry char syntax-descriptor  &optional table
 This function sets the syntax entry for @var{char} according to
-@var{syntax-descriptor}.  The syntax is changed only for @var{table},
-which defaults to the current buffer's syntax table, and not in any
-other syntax table.  The argument @var{syntax-descriptor} specifies the
-desired syntax; this is a string beginning with a class designator
-character, and optionally containing a matching character and flags as
-well.  @xref{Syntax Descriptors}.
+@var{syntax-descriptor}.  @var{char} can be a character, or a cons
+cell of the form @code{(@var{min} . @var{max})}; in the latter case,
+the function sets the syntax entries for all characters in the range
+between @var{min} and @var{max}, inclusive.
+
+The syntax is changed only for @var{table}, which defaults to the
+current buffer's syntax table, and not in any other syntax table.  The
+argument @var{syntax-descriptor} specifies the desired syntax; this is
+a string beginning with a class designator character, and optionally
+containing a matching character and flags as well.  @xref{Syntax
+Descriptors}.
 
 This function always returns @code{nil}.  The old syntax information in
 the table for this character is discarded.
@@ -723,9 +729,12 @@ buffer is modified without obeying the hook, such as when using
 @code{inhibit-modification-hooks}.  For this reason, it is sometimes
 necessary to flush the cache manually.
 
-@defun syntax-ppss-flush-cache beg
-This function flushes the cache used by @code{syntax-ppss}, starting at
-position @var{beg}.
+@defun syntax-ppss-flush-cache beg &rest ignored-args
+This function flushes the cache used by @code{syntax-ppss}, starting
+at position @var{beg}.  The remaining arguments, @var{ignored-args},
+are ignored; this function accepts them so that it can be directly
+used on hooks such as @code{before-change-functions} (@pxref{Change
+Hooks}).
 @end defun
 
   Major modes can make @code{syntax-ppss} run faster by specifying
@@ -1163,12 +1172,15 @@ of the set.
 @end example
 @end defun
 
-@defun modify-category-entry character category &optional table reset
-This function modifies the category set of @var{character} in category
+@defun modify-category-entry char category &optional table reset
+This function modifies the category set of @var{char} in category
 table @var{table} (which defaults to the current buffer's category
-table).
+table).  @var{char} can be a character, or a cons cell of the form
+@code{(@var{min} . @var{max})}; in the latter case, the function
+modifies the category sets of all characters in the range between
+@var{min} and @var{max}, inclusive.
 
-Normally, it modifies the category set by adding @var{category} to it.
+Normally, it modifies a category set by adding @var{category} to it.
 But if @var{reset} is non-@code{nil}, then it deletes @var{category}
 instead.
 @end defun
@@ -1179,7 +1191,3 @@ category table.  It inserts the descriptions in a buffer, and then
 displays that buffer.  If @var{buffer-or-name} is non-@code{nil}, it
 describes the category table of that buffer instead.
 @end deffn
-
-@ignore
-   arch-tag: 4d914e96-0283-445c-9233-75d33662908c
-@end ignore