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 | |
| 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
| -rw-r--r-- | doc/lispref/ChangeLog | 6 | ||||
| -rw-r--r-- | doc/lispref/syntax.texi | 61 | ||||
| -rw-r--r-- | lisp/ChangeLog | 4 | ||||
| -rw-r--r-- | lisp/subr.el | 9 | ||||
| -rw-r--r-- | src/ChangeLog | 4 | ||||
| -rw-r--r-- | src/syntax.c | 10 |
6 files changed, 62 insertions, 32 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 |
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index e10fe9166e7..4d6210a16b9 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,7 @@ | |||
| 1 | 2012-09-08 Chong Yidong <cyd@gnu.org> | ||
| 2 | |||
| 3 | * subr.el (syntax-after, syntax-class): Doc fix. | ||
| 4 | |||
| 1 | 2012-09-08 Martin Rudalics <rudalics@gmx.at> | 5 | 2012-09-08 Martin Rudalics <rudalics@gmx.at> |
| 2 | 6 | ||
| 3 | * window.el (display-buffer-in-previous-window): New buffer | 7 | * window.el (display-buffer-in-previous-window): New buffer |
diff --git a/lisp/subr.el b/lisp/subr.el index a3e0897e9fe..4f273a92a62 100644 --- a/lisp/subr.el +++ b/lisp/subr.el | |||
| @@ -3737,7 +3737,7 @@ from `standard-syntax-table' otherwise." | |||
| 3737 | table)) | 3737 | table)) |
| 3738 | 3738 | ||
| 3739 | (defun syntax-after (pos) | 3739 | (defun syntax-after (pos) |
| 3740 | "Return the raw syntax of the char after POS. | 3740 | "Return the raw syntax descriptor for the char after POS. |
| 3741 | If POS is outside the buffer's accessible portion, return nil." | 3741 | If POS is outside the buffer's accessible portion, return nil." |
| 3742 | (unless (or (< pos (point-min)) (>= pos (point-max))) | 3742 | (unless (or (< pos (point-min)) (>= pos (point-max))) |
| 3743 | (let ((st (if parse-sexp-lookup-properties | 3743 | (let ((st (if parse-sexp-lookup-properties |
| @@ -3746,7 +3746,12 @@ If POS is outside the buffer's accessible portion, return nil." | |||
| 3746 | (aref (or st (syntax-table)) (char-after pos)))))) | 3746 | (aref (or st (syntax-table)) (char-after pos)))))) |
| 3747 | 3747 | ||
| 3748 | (defun syntax-class (syntax) | 3748 | (defun syntax-class (syntax) |
| 3749 | "Return the syntax class part of the syntax descriptor SYNTAX. | 3749 | "Return the code for the syntax class described by SYNTAX. |
| 3750 | |||
| 3751 | SYNTAX should be a raw syntax descriptor; the return value is a | ||
| 3752 | integer which encodes the corresponding syntax class. See Info | ||
| 3753 | node `(elisp)Syntax Table Internals' for a list of codes. | ||
| 3754 | |||
| 3750 | If SYNTAX is nil, return nil." | 3755 | If SYNTAX is nil, return nil." |
| 3751 | (and syntax (logand (car syntax) 65535))) | 3756 | (and syntax (logand (car syntax) 65535))) |
| 3752 | 3757 | ||
diff --git a/src/ChangeLog b/src/ChangeLog index 40647d79589..ec6e39ad0b5 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,7 @@ | |||
| 1 | 2012-09-08 Chong Yidong <cyd@gnu.org> | ||
| 2 | |||
| 3 | * syntax.c (Fstring_to_syntax): Doc fix. | ||
| 4 | |||
| 1 | 2012-09-08 Jan Djärv <jan.h.d@swipnet.se> | 5 | 2012-09-08 Jan Djärv <jan.h.d@swipnet.se> |
| 2 | 6 | ||
| 3 | * nsterm.m (ns_clip_to_row): Remove code that deals with drawing fringe | 7 | * nsterm.m (ns_clip_to_row): Remove code that deals with drawing fringe |
diff --git a/src/syntax.c b/src/syntax.c index f995b8f2cac..fdd9353bb87 100644 --- a/src/syntax.c +++ b/src/syntax.c | |||
| @@ -921,11 +921,11 @@ DEFUN ("matching-paren", Fmatching_paren, Smatching_paren, 1, 1, 0, | |||
| 921 | } | 921 | } |
| 922 | 922 | ||
| 923 | DEFUN ("string-to-syntax", Fstring_to_syntax, Sstring_to_syntax, 1, 1, 0, | 923 | DEFUN ("string-to-syntax", Fstring_to_syntax, Sstring_to_syntax, 1, 1, 0, |
| 924 | doc: /* Convert a syntax specification STRING into syntax cell form. | 924 | doc: /* Convert a syntax descriptor STRING into a raw syntax descriptor. |
| 925 | STRING should be a string as it is allowed as argument of | 925 | STRING should be a string of the form allowed as argument of |
| 926 | `modify-syntax-entry'. Value is the equivalent cons cell | 926 | `modify-syntax-entry'. The return value is a raw syntax descriptor: a |
| 927 | \(CODE . MATCHING-CHAR) that can be used as value of a `syntax-table' | 927 | cons cell \(CODE . MATCHING-CHAR) which can be used, for example, as |
| 928 | text property. */) | 928 | the value of a `syntax-table' text property. */) |
| 929 | (Lisp_Object string) | 929 | (Lisp_Object string) |
| 930 | { | 930 | { |
| 931 | register const unsigned char *p; | 931 | register const unsigned char *p; |