diff options
| author | Chong Yidong | 2012-09-08 22:23:01 +0800 |
|---|---|---|
| committer | Chong Yidong | 2012-09-08 22:23:01 +0800 |
| commit | 6dcef6eca79b118976211b05552880be2ddf014a (patch) | |
| tree | 9cc3ed07ef27e620c14afe91c2c8193787f82834 /doc/lispref | |
| parent | fa2bcf435d9774c0e8542ba36b11ef4722f9675c (diff) | |
| download | emacs-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/ChangeLog | 6 | ||||
| -rw-r--r-- | doc/lispref/syntax.texi | 61 |
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 @@ | |||
| 1 | 2012-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 | |||
| 1 | 2012-09-07 Chong Yidong <cyd@gnu.org> | 7 | 2012-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., | |||
| 130 | punctuation, matching character slot unused, first character of a | 130 | punctuation, matching character slot unused, first character of a |
| 131 | comment-starter, second character of a comment-ender). | 131 | comment-starter, second character of a comment-ender). |
| 132 | 132 | ||
| 133 | Emacs also defines @dfn{raw syntax descriptors}, which are used to | ||
| 134 | describe syntax classes at a lower level. @xref{Syntax Table | ||
| 135 | Internals}. | ||
| 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 | |||
| 531 | underlying text character. | 535 | underlying text character. |
| 532 | 536 | ||
| 533 | @item @code{(@var{syntax-code} . @var{matching-char})} | 537 | @item @code{(@var{syntax-code} . @var{matching-char})} |
| 534 | A cons cell of this format specifies the syntax for the underlying | 538 | A cons cell of this format is a raw syntax descriptor (@pxref{Syntax |
| 535 | text character. (@pxref{Syntax Table Internals}) | 539 | Table Internals}), which directly specifies a syntax class for the |
| 540 | underlying text character. | ||
| 536 | 541 | ||
| 537 | @item @code{nil} | 542 | @item @code{nil} |
| 538 | If the property is @code{nil}, the character's syntax is determined from | 543 | If 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 | |||
| 940 | as syntax properties (@pxref{Syntax Properties}). | 945 | as 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 |
| 945 | is an integer that encodes the syntax class and syntax flags, | 950 | cons cell of the form @code{(@var{syntax-code} |
| 946 | according to the table below. @var{matching-char}, if non-@code{nil}, | 951 | . @var{matching-char})}. @var{syntax-code} is an integer which |
| 947 | specifies a matching character (similar to the second character in a | 952 | encodes the syntax class and syntax flags, according to the table |
| 948 | syntax descriptor). | 953 | below. @var{matching-char}, if non-@code{nil}, specifies a matching |
| 954 | character (similar to the second character in a syntax descriptor). | ||
| 955 | |||
| 956 | Here are the syntax codes corresponding to the various syntax | ||
| 957 | classes: | ||
| 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 |
| 954 | 0 @tab whitespace @tab 8 @tab paired delimiter | 963 | 0 @tab whitespace @tab 8 @tab paired delimiter |
| 955 | @item | 964 | @item |
| @@ -970,7 +979,7 @@ syntax descriptor). | |||
| 970 | 979 | ||
| 971 | @noindent | 980 | @noindent |
| 972 | For example, in the standard syntax table, the entry for @samp{(} is | 981 | For 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 |
| 976 | the least significant bit. This table gives the power of two which | 985 | the 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} |
| 993 | Given a syntax descriptor @var{desc}, this function returns the | 1002 | Given a syntax descriptor @var{desc} (a string), this function returns |
| 994 | corresponding internal form, a cons cell @code{(@var{syntax-code} | 1003 | the 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 |
| 999 | This function returns the syntax code of the character in the buffer | 1007 | This function returns the raw syntax descriptor for the character in |
| 1000 | after position @var{pos}, taking account of syntax properties as well | 1008 | the buffer after position @var{pos}, taking account of syntax |
| 1001 | as the syntax table. If @var{pos} is outside the buffer's accessible | 1009 | properties as well as the syntax table. If @var{pos} is outside the |
| 1002 | portion (@pxref{Narrowing, accessible portion}), this function returns | 1010 | buffer's accessible portion (@pxref{Narrowing, accessible portion}), |
| 1003 | @code{nil}. | 1011 | the return value is @code{nil}. |
| 1004 | @end defun | 1012 | @end defun |
| 1005 | 1013 | ||
| 1006 | @defun syntax-class syntax | 1014 | @defun syntax-class syntax |
| 1007 | This function returns the syntax class of the syntax code | 1015 | This 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 |
| 1009 | encoded in the syntax descriptor.) If @var{syntax} is @code{nil}, it | 1017 | @var{syntax-code} component, masks off the high 16 bits which record |
| 1010 | returns @code{nil}; this is so evaluating the expression | 1018 | the syntax flags, and returns the resulting integer. |
| 1019 | |||
| 1020 | If @var{syntax} is @code{nil}, the return value is returns @code{nil}. | ||
| 1021 | This 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 |
| 1017 | where @code{pos} is outside the buffer's accessible portion, will | 1028 | evaluates to @code{nil} if @code{pos} is outside the buffer's |
| 1018 | yield @code{nil} without throwing errors or producing wrong syntax | 1029 | accessible portion, without throwing errors or returning an incorrect |
| 1019 | class codes. | 1030 | code. |
| 1020 | @end defun | 1031 | @end defun |
| 1021 | 1032 | ||
| 1022 | @node Categories | 1033 | @node Categories |