aboutsummaryrefslogtreecommitdiffstats
path: root/doc/lispref
diff options
context:
space:
mode:
authorChong Yidong2012-09-08 22:23:01 +0800
committerChong Yidong2012-09-08 22:23:01 +0800
commit6dcef6eca79b118976211b05552880be2ddf014a (patch)
tree9cc3ed07ef27e620c14afe91c2c8193787f82834 /doc/lispref
parentfa2bcf435d9774c0e8542ba36b11ef4722f9675c (diff)
downloademacs-6dcef6eca79b118976211b05552880be2ddf014a.tar.gz
emacs-6dcef6eca79b118976211b05552880be2ddf014a.zip
Introduce "raw syntax descriptor" terminology, and use it.
* syntax.texi (Syntax Table Internals): Define "raw syntax descriptor" terminology. (Syntax Descriptors): Mention raw syntax descriptors. * lisp/subr.el (syntax-after, syntax-class): Doc fix. * syntax.c (Fstring_to_syntax): Doc fix. Fixes: debbugs:12383
Diffstat (limited to 'doc/lispref')
-rw-r--r--doc/lispref/ChangeLog6
-rw-r--r--doc/lispref/syntax.texi61
2 files changed, 42 insertions, 25 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog
index 4bd7210d7d6..57ee374af49 100644
--- a/doc/lispref/ChangeLog
+++ b/doc/lispref/ChangeLog
@@ -1,3 +1,9 @@
12012-09-08 Chong Yidong <cyd@gnu.org>
2
3 * syntax.texi (Syntax Table Internals): Define "raw syntax
4 descriptor" terminology (Bug#12383).
5 (Syntax Descriptors): Mention raw syntax descriptors.
6
12012-09-07 Chong Yidong <cyd@gnu.org> 72012-09-07 Chong Yidong <cyd@gnu.org>
2 8
3 * variables.texi (Creating Buffer-Local): Fix description of 9 * variables.texi (Creating Buffer-Local): Fix description of
diff --git a/doc/lispref/syntax.texi b/doc/lispref/syntax.texi
index 91ae4359af7..624b5a92d6e 100644
--- a/doc/lispref/syntax.texi
+++ b/doc/lispref/syntax.texi
@@ -130,6 +130,10 @@ comment-ender), and the entry for @samp{/} is @samp{@w{. 14}} (i.e.,
130punctuation, matching character slot unused, first character of a 130punctuation, matching character slot unused, first character of a
131comment-starter, second character of a comment-ender). 131comment-starter, second character of a comment-ender).
132 132
133 Emacs also defines @dfn{raw syntax descriptors}, which are used to
134describe syntax classes at a lower level. @xref{Syntax Table
135Internals}.
136
133@menu 137@menu
134* Syntax Class Table:: Table of syntax classes. 138* Syntax Class Table:: Table of syntax classes.
135* Syntax Flags:: Additional flags each character can have. 139* Syntax Flags:: Additional flags each character can have.
@@ -531,8 +535,9 @@ the current buffer's syntax table to determine the syntax for the
531underlying text character. 535underlying text character.
532 536
533@item @code{(@var{syntax-code} . @var{matching-char})} 537@item @code{(@var{syntax-code} . @var{matching-char})}
534A cons cell of this format specifies the syntax for the underlying 538A cons cell of this format is a raw syntax descriptor (@pxref{Syntax
535text character. (@pxref{Syntax Table Internals}) 539Table Internals}), which directly specifies a syntax class for the
540underlying text character.
536 541
537@item @code{nil} 542@item @code{nil}
538If the property is @code{nil}, the character's syntax is determined from 543If the property is @code{nil}, the character's syntax is determined from
@@ -940,16 +945,20 @@ documented in this section. This internal format can also be assigned
940as syntax properties (@pxref{Syntax Properties}). 945as syntax properties (@pxref{Syntax Properties}).
941 946
942@cindex syntax code 947@cindex syntax code
943 Each entry in a syntax table is a cons cell of the form 948@cindex raw syntax descriptor
944@code{(@var{syntax-code} . @var{matching-char})}. @var{syntax-code} 949 Each entry in a syntax table is a @dfn{raw syntax descriptor}: a
945is an integer that encodes the syntax class and syntax flags, 950cons cell of the form @code{(@var{syntax-code}
946according to the table below. @var{matching-char}, if non-@code{nil}, 951. @var{matching-char})}. @var{syntax-code} is an integer which
947specifies a matching character (similar to the second character in a 952encodes the syntax class and syntax flags, according to the table
948syntax descriptor). 953below. @var{matching-char}, if non-@code{nil}, specifies a matching
954character (similar to the second character in a syntax descriptor).
955
956 Here are the syntax codes corresponding to the various syntax
957classes:
949 958
950@multitable @columnfractions .2 .3 .2 .3 959@multitable @columnfractions .2 .3 .2 .3
951@item 960@item
952@i{Syntax code} @tab @i{Class} @tab @i{Syntax code} @tab @i{Class} 961@i{Code} @tab @i{Class} @tab @i{Code} @tab @i{Class}
953@item 962@item
9540 @tab whitespace @tab 8 @tab paired delimiter 9630 @tab whitespace @tab 8 @tab paired delimiter
955@item 964@item
@@ -970,7 +979,7 @@ syntax descriptor).
970 979
971@noindent 980@noindent
972For example, in the standard syntax table, the entry for @samp{(} is 981For example, in the standard syntax table, the entry for @samp{(} is
973@code{(4 . 41)}. (41 is the character code for @samp{)}.) 982@code{(4 . 41)}. 41 is the character code for @samp{)}.
974 983
975 Syntax flags are encoded in higher order bits, starting 16 bits from 984 Syntax flags are encoded in higher order bits, starting 16 bits from
976the least significant bit. This table gives the power of two which 985the least significant bit. This table gives the power of two which
@@ -990,33 +999,35 @@ corresponds to each syntax flag.
990@end multitable 999@end multitable
991 1000
992@defun string-to-syntax @var{desc} 1001@defun string-to-syntax @var{desc}
993Given a syntax descriptor @var{desc}, this function returns the 1002Given a syntax descriptor @var{desc} (a string), this function returns
994corresponding internal form, a cons cell @code{(@var{syntax-code} 1003the corresponding raw syntax descriptor.
995. @var{matching-char})}.
996@end defun 1004@end defun
997 1005
998@defun syntax-after pos 1006@defun syntax-after pos
999This function returns the syntax code of the character in the buffer 1007This function returns the raw syntax descriptor for the character in
1000after position @var{pos}, taking account of syntax properties as well 1008the buffer after position @var{pos}, taking account of syntax
1001as the syntax table. If @var{pos} is outside the buffer's accessible 1009properties as well as the syntax table. If @var{pos} is outside the
1002portion (@pxref{Narrowing, accessible portion}), this function returns 1010buffer's accessible portion (@pxref{Narrowing, accessible portion}),
1003@code{nil}. 1011the return value is @code{nil}.
1004@end defun 1012@end defun
1005 1013
1006@defun syntax-class syntax 1014@defun syntax-class syntax
1007This function returns the syntax class of the syntax code 1015This function returns the syntax code for the raw syntax descriptor
1008@var{syntax}. (It masks off the high 16 bits that hold the flags 1016@var{syntax}. More precisely, it takes the raw syntax descriptor's
1009encoded in the syntax descriptor.) If @var{syntax} is @code{nil}, it 1017@var{syntax-code} component, masks off the high 16 bits which record
1010returns @code{nil}; this is so evaluating the expression 1018the syntax flags, and returns the resulting integer.
1019
1020If @var{syntax} is @code{nil}, the return value is returns @code{nil}.
1021This is so that the expression
1011 1022
1012@example 1023@example
1013(syntax-class (syntax-after pos)) 1024(syntax-class (syntax-after pos))
1014@end example 1025@end example
1015 1026
1016@noindent 1027@noindent
1017where @code{pos} is outside the buffer's accessible portion, will 1028evaluates to @code{nil} if @code{pos} is outside the buffer's
1018yield @code{nil} without throwing errors or producing wrong syntax 1029accessible portion, without throwing errors or returning an incorrect
1019class codes. 1030code.
1020@end defun 1031@end defun
1021 1032
1022@node Categories 1033@node Categories