diff options
| author | Stefan Monnier | 2010-08-12 16:44:16 +0200 |
|---|---|---|
| committer | Stefan Monnier | 2010-08-12 16:44:16 +0200 |
| commit | c5683ceb2cf80b5b7475f92236271eaeba662798 (patch) | |
| tree | 89c5f1d7b7b3eb972df9cea5aeecdbacd3fc3a69 | |
| parent | 856a6b7709a7257722a4e5b14859ca6a422dad52 (diff) | |
| download | emacs-c5683ceb2cf80b5b7475f92236271eaeba662798.tar.gz emacs-c5683ceb2cf80b5b7475f92236271eaeba662798.zip | |
Introduce a new comment style "c" flag.
* src/syntax.c (SYNTAX_FLAGS_COMMENT_STYLEB)
(SYNTAX_FLAGS_COMMENT_STYLEC): New macros.
(SYNTAX_FLAGS_COMMENT_STYLE): Use them, add an argument.
(syntax_prefix_flag_p): New function.
(Fstring_to_syntax): Understand new "c" flag.
(Finternal_describe_syntax_value): Recognize new flag; use the
SYNTAX_FLAGS_* macros.
(scan_sexps_forward, Fparse_partial_sexp): Change representation of
comment style to accomodate the new styles.
(back_comment, forw_comment, Fforward_comment, scan_lists)
(scan_sexps_forward): Update code to obey the new comment style flag.
* src/syntax.h: Move SYNTAX_FLAGS_FOO() macros to syntax.c.
* src/casefiddle.c (casify_region): Use the new syntax_prefix_flag_p.
* lisp/progmodes/octave-mod.el (octave-mode-syntax-table): Use the new "c"
comment style.
* lisp/progmodes/scheme.el (scheme-mode-syntax-table):
* lisp/emacs-lisp/lisp-mode.el (lisp-mode-syntax-table): Remove spurious
"b" flag in "14b" syntax.
Fixes: debbugs:6834
| -rw-r--r-- | etc/NEWS | 1 | ||||
| -rw-r--r-- | lisp/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/emacs-lisp/lisp-mode.el | 2 | ||||
| -rw-r--r-- | lisp/progmodes/octave-mod.el | 9 | ||||
| -rw-r--r-- | lisp/progmodes/scheme.el | 2 | ||||
| -rw-r--r-- | src/ChangeLog | 37 | ||||
| -rw-r--r-- | src/casefiddle.c | 3 | ||||
| -rw-r--r-- | src/syntax.c | 238 | ||||
| -rw-r--r-- | src/syntax.h | 51 |
9 files changed, 213 insertions, 136 deletions
| @@ -424,6 +424,7 @@ has now been removed. | |||
| 424 | 424 | ||
| 425 | * Lisp changes in Emacs 24.1 | 425 | * Lisp changes in Emacs 24.1 |
| 426 | 426 | ||
| 427 | ** Syntax tables support a new "comment style c" additionally to style b. | ||
| 427 | ** frame-local variables cannot be let-bound any more. | 428 | ** frame-local variables cannot be let-bound any more. |
| 428 | ** prog-mode is a new major-mode meant to be the parent of programming mode. | 429 | ** prog-mode is a new major-mode meant to be the parent of programming mode. |
| 429 | ** define-minor-mode accepts a new keyword :variable. | 430 | ** define-minor-mode accepts a new keyword :variable. |
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 018da138dde..868d9822b85 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,11 @@ | |||
| 1 | 2010-08-12 Stefan Monnier <monnier@iro.umontreal.ca> | 1 | 2010-08-12 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 2 | ||
| 3 | * progmodes/octave-mod.el (octave-mode-syntax-table): Use the new "c" | ||
| 4 | comment style (bug#6834). | ||
| 5 | * progmodes/scheme.el (scheme-mode-syntax-table): | ||
| 6 | * emacs-lisp/lisp-mode.el (lisp-mode-syntax-table): Remove spurious | ||
| 7 | "b" flag in "' 14b" syntax. | ||
| 8 | |||
| 3 | * progmodes/octave-mod.el (octave-mode-map): Remove special bindings | 9 | * progmodes/octave-mod.el (octave-mode-map): Remove special bindings |
| 4 | for (un)commenting the region and performing completion. | 10 | for (un)commenting the region and performing completion. |
| 5 | (octave-mode-menu): Use standard commands for help and completion. | 11 | (octave-mode-menu): Use standard commands for help and completion. |
diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index 02477baf74f..21a9f80fa90 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el | |||
| @@ -85,7 +85,7 @@ | |||
| 85 | (let ((table (copy-syntax-table emacs-lisp-mode-syntax-table))) | 85 | (let ((table (copy-syntax-table emacs-lisp-mode-syntax-table))) |
| 86 | (modify-syntax-entry ?\[ "_ " table) | 86 | (modify-syntax-entry ?\[ "_ " table) |
| 87 | (modify-syntax-entry ?\] "_ " table) | 87 | (modify-syntax-entry ?\] "_ " table) |
| 88 | (modify-syntax-entry ?# "' 14b" table) | 88 | (modify-syntax-entry ?# "' 14" table) |
| 89 | (modify-syntax-entry ?| "\" 23bn" table) | 89 | (modify-syntax-entry ?| "\" 23bn" table) |
| 90 | table) | 90 | table) |
| 91 | "Syntax table used in `lisp-mode'.") | 91 | "Syntax table used in `lisp-mode'.") |
diff --git a/lisp/progmodes/octave-mod.el b/lisp/progmodes/octave-mod.el index e0f4a878a3e..5287eff1347 100644 --- a/lisp/progmodes/octave-mod.el +++ b/lisp/progmodes/octave-mod.el | |||
| @@ -294,17 +294,16 @@ parenthetical grouping.") | |||
| 294 | (modify-syntax-entry ?\" "\"" table) | 294 | (modify-syntax-entry ?\" "\"" table) |
| 295 | (modify-syntax-entry ?. "w" table) | 295 | (modify-syntax-entry ?. "w" table) |
| 296 | (modify-syntax-entry ?_ "w" table) | 296 | (modify-syntax-entry ?_ "w" table) |
| 297 | ;; FIXME: The "b" flag only applies to the second letter of the comstart | 297 | ;; The "b" flag only applies to the second letter of the comstart |
| 298 | ;; and the first letter of the comend, i.e. the "4b" below is ineffective. | 298 | ;; and the first letter of the comend, i.e. the "4b" below is ineffective. |
| 299 | ;; If we try to put `b' on the single-line comments, we get a similar | 299 | ;; If we try to put `b' on the single-line comments, we get a similar |
| 300 | ;; problem where the % and # chars appear as first chars of the 2-char | 300 | ;; problem where the % and # chars appear as first chars of the 2-char |
| 301 | ;; comend, so the multi-line ender is also turned into style-b. | 301 | ;; comend, so the multi-line ender is also turned into style-b. |
| 302 | ;; Really, we can't make it work without extending the syntax-tables, or | 302 | ;; So we need the new "c" comment style. |
| 303 | ;; via font-lock-syntactic-keywords. | ||
| 304 | (modify-syntax-entry ?\% "< 13" table) | 303 | (modify-syntax-entry ?\% "< 13" table) |
| 305 | (modify-syntax-entry ?\# "< 13" table) | 304 | (modify-syntax-entry ?\# "< 13" table) |
| 306 | (modify-syntax-entry ?\{ "(} 2b" table) | 305 | (modify-syntax-entry ?\{ "(} 2c" table) |
| 307 | (modify-syntax-entry ?\} "){ 4b" table) | 306 | (modify-syntax-entry ?\} "){ 4c" table) |
| 308 | (modify-syntax-entry ?\n ">" table) | 307 | (modify-syntax-entry ?\n ">" table) |
| 309 | table) | 308 | table) |
| 310 | "Syntax table in use in `octave-mode' buffers.") | 309 | "Syntax table in use in `octave-mode' buffers.") |
diff --git a/lisp/progmodes/scheme.el b/lisp/progmodes/scheme.el index ce8a34220e4..da143db5ffb 100644 --- a/lisp/progmodes/scheme.el +++ b/lisp/progmodes/scheme.el | |||
| @@ -107,7 +107,7 @@ | |||
| 107 | ;; Special characters | 107 | ;; Special characters |
| 108 | (modify-syntax-entry ?, "' " st) | 108 | (modify-syntax-entry ?, "' " st) |
| 109 | (modify-syntax-entry ?@ "' " st) | 109 | (modify-syntax-entry ?@ "' " st) |
| 110 | (modify-syntax-entry ?# "' 14b" st) | 110 | (modify-syntax-entry ?# "' 14" st) |
| 111 | (modify-syntax-entry ?\\ "\\ " st) | 111 | (modify-syntax-entry ?\\ "\\ " st) |
| 112 | st)) | 112 | st)) |
| 113 | 113 | ||
diff --git a/src/ChangeLog b/src/ChangeLog index 7e8959d4b61..14213e1c750 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,22 @@ | |||
| 1 | 2010-08-12 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | Introduce a new comment style "c" flag. | ||
| 4 | * syntax.c (SYNTAX_FLAGS_COMMENT_STYLEB) | ||
| 5 | (SYNTAX_FLAGS_COMMENT_STYLEC): New macros. | ||
| 6 | (SYNTAX_FLAGS_COMMENT_STYLE): Use them, add an argument. | ||
| 7 | (syntax_prefix_flag_p): New function. | ||
| 8 | (Fstring_to_syntax): Understand new "c" flag. | ||
| 9 | (Finternal_describe_syntax_value): Recognize new flag; use the | ||
| 10 | SYNTAX_FLAGS_* macros. | ||
| 11 | (scan_sexps_forward, Fparse_partial_sexp): Change representation of | ||
| 12 | comment style to accomodate the new styles. | ||
| 13 | (back_comment, forw_comment, Fforward_comment, scan_lists) | ||
| 14 | (scan_sexps_forward): Update code to obey the new comment style flag. | ||
| 15 | |||
| 16 | * syntax.h: Move SYNTAX_FLAGS_FOO() macros to syntax.c. | ||
| 17 | |||
| 18 | * casefiddle.c (casify_region): Use the new syntax_prefix_flag_p. | ||
| 19 | |||
| 1 | 2010-08-11 Jan Djärv <jan.h.d@swipnet.se> | 20 | 2010-08-11 Jan Djärv <jan.h.d@swipnet.se> |
| 2 | 21 | ||
| 3 | * xfns.c (x_defined_color): If USE_GTK, call xg_check_special_colors | 22 | * xfns.c (x_defined_color): If USE_GTK, call xg_check_special_colors |
| @@ -21,8 +40,8 @@ | |||
| 21 | 40 | ||
| 22 | * xselect.c (Fx_get_atom_name): Use char empty[] instead of literal "". | 41 | * xselect.c (Fx_get_atom_name): Use char empty[] instead of literal "". |
| 23 | 42 | ||
| 24 | * xrdb.c (get_system_app): Make path const and use char *p for non-const | 43 | * xrdb.c (get_system_app): Make path const and use char *p for |
| 25 | char. | 44 | non-const char. |
| 26 | 45 | ||
| 27 | * xmenu.c (Fx_popup_dialog): error_name is const char*. | 46 | * xmenu.c (Fx_popup_dialog): error_name is const char*. |
| 28 | (xmenu_show): error parameter is const char **. pane_string is const | 47 | (xmenu_show): error parameter is const char **. pane_string is const |
| @@ -80,9 +99,9 @@ | |||
| 80 | 2010-08-09 Dan Nicolaescu <dann@ics.uci.edu> | 99 | 2010-08-09 Dan Nicolaescu <dann@ics.uci.edu> |
| 81 | 100 | ||
| 82 | * font.h (font_parse_xlfd, font_parse_fcname, font_unparse_fcname) | 101 | * font.h (font_parse_xlfd, font_parse_fcname, font_unparse_fcname) |
| 83 | (font_parse_name): font_open_by_name): | 102 | (font_parse_name, font_open_by_name): |
| 84 | * font.c (font_parse_xlfd, font_parse_fcname, font_unparse_fcname) | 103 | * font.c (font_parse_xlfd, font_parse_fcname, font_unparse_fcname) |
| 85 | (font_parse_name): font_open_by_name): Remove const. | 104 | (font_parse_name, font_open_by_name): Remove const. |
| 86 | 105 | ||
| 87 | 2010-08-09 Andreas Schwab <schwab@linux-m68k.org> | 106 | 2010-08-09 Andreas Schwab <schwab@linux-m68k.org> |
| 88 | 107 | ||
| @@ -205,17 +224,17 @@ | |||
| 205 | 224 | ||
| 206 | * s/freebsd.h (DECLARE_GETPWUID_WITH_UID_T): Remove, unused. | 225 | * s/freebsd.h (DECLARE_GETPWUID_WITH_UID_T): Remove, unused. |
| 207 | 226 | ||
| 208 | * xrdb.c: Remove include guard. Remove | 227 | * xrdb.c: Remove include guard. |
| 209 | DECLARE_GETPWUID_WITH_UID_T conditional it had no effect. | 228 | Remove DECLARE_GETPWUID_WITH_UID_T conditional it had no effect. |
| 210 | Remove #if 0 code. Replace malloc->xmalloc, free->xfree, | 229 | Remove #if 0 code. Replace malloc->xmalloc, free->xfree, |
| 211 | realloc->xrealloc instead of using #defines. | 230 | realloc->xrealloc instead of using #defines. |
| 212 | 231 | ||
| 213 | 2010-08-08 Eli Zaretskii <eliz@gnu.org> | 232 | 2010-08-08 Eli Zaretskii <eliz@gnu.org> |
| 214 | 233 | ||
| 215 | * cmds.c (Fforward_line, Fbeginning_of_line, Fend_of_line): | 234 | * cmds.c (Fforward_line, Fbeginning_of_line, Fend_of_line): |
| 216 | * editfns.c (Fline_beginning_position, Fline_end_position): State | 235 | * editfns.c (Fline_beginning_position, Fline_end_position): |
| 217 | in the doc strings that start and end of line are in the logical | 236 | State in the doc strings that start and end of line are in the |
| 218 | order. | 237 | logical order. |
| 219 | 238 | ||
| 220 | * xdisp.c (display_line): Move the handling of overlay arrow after | 239 | * xdisp.c (display_line): Move the handling of overlay arrow after |
| 221 | the call to find_row_edges. (Bug#6699) | 240 | the call to find_row_edges. (Bug#6699) |
diff --git a/src/casefiddle.c b/src/casefiddle.c index 9545cf697a8..815f684e26a 100644 --- a/src/casefiddle.c +++ b/src/casefiddle.c | |||
| @@ -243,7 +243,8 @@ casify_region (enum case_action flag, Lisp_Object b, Lisp_Object e) | |||
| 243 | && (!inword || flag != CASE_CAPITALIZE_UP)) | 243 | && (!inword || flag != CASE_CAPITALIZE_UP)) |
| 244 | c = UPCASE1 (c); | 244 | c = UPCASE1 (c); |
| 245 | if ((int) flag >= (int) CASE_CAPITALIZE) | 245 | if ((int) flag >= (int) CASE_CAPITALIZE) |
| 246 | inword = ((SYNTAX (c) == Sword) && (inword || !SYNTAX_PREFIX (c))); | 246 | inword = ((SYNTAX (c) == Sword) |
| 247 | && (inword || !syntax_prefix_flag_p (c))); | ||
| 247 | if (c != c2) | 248 | if (c != c2) |
| 248 | { | 249 | { |
| 249 | last = start; | 250 | last = start; |
diff --git a/src/syntax.c b/src/syntax.c index 9b707c6c3b7..f0a7dca42dc 100644 --- a/src/syntax.c +++ b/src/syntax.c | |||
| @@ -34,6 +34,60 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 34 | 34 | ||
| 35 | #include "syntax.h" | 35 | #include "syntax.h" |
| 36 | #include "intervals.h" | 36 | #include "intervals.h" |
| 37 | #include "category.h" | ||
| 38 | |||
| 39 | /* Then there are seven single-bit flags that have the following meanings: | ||
| 40 | 1. This character is the first of a two-character comment-start sequence. | ||
| 41 | 2. This character is the second of a two-character comment-start sequence. | ||
| 42 | 3. This character is the first of a two-character comment-end sequence. | ||
| 43 | 4. This character is the second of a two-character comment-end sequence. | ||
| 44 | 5. This character is a prefix, for backward-prefix-chars. | ||
| 45 | 6. The char is part of a delimiter for comments of style "b". | ||
| 46 | 7. This character is part of a nestable comment sequence. | ||
| 47 | 8. The char is part of a delimiter for comments of style "c". | ||
| 48 | Note that any two-character sequence whose first character has flag 1 | ||
| 49 | and whose second character has flag 2 will be interpreted as a comment start. | ||
| 50 | |||
| 51 | bit 6 and 8 are used to discriminate between different comment styles. | ||
| 52 | Languages such as C++ allow two orthogonal syntax start/end pairs | ||
| 53 | and bit 6 is used to determine whether a comment-end or Scommentend | ||
| 54 | ends style a or b. Comment markers can start style a, b, c, or bc. | ||
| 55 | Style a is always the default. | ||
| 56 | For 2-char comment markers, the style b flag is only looked up on the second | ||
| 57 | char of the comment marker and on the first char of the comment ender. | ||
| 58 | For style c (like to for the nested flag), the flag can be placed on any | ||
| 59 | one of the chars. | ||
| 60 | */ | ||
| 61 | |||
| 62 | /* These macros extract specific flags from an integer | ||
| 63 | that holds the syntax code and the flags. */ | ||
| 64 | |||
| 65 | #define SYNTAX_FLAGS_COMSTART_FIRST(flags) (((flags) >> 16) & 1) | ||
| 66 | |||
| 67 | #define SYNTAX_FLAGS_COMSTART_SECOND(flags) (((flags) >> 17) & 1) | ||
| 68 | |||
| 69 | #define SYNTAX_FLAGS_COMEND_FIRST(flags) (((flags) >> 18) & 1) | ||
| 70 | |||
| 71 | #define SYNTAX_FLAGS_COMEND_SECOND(flags) (((flags) >> 19) & 1) | ||
| 72 | |||
| 73 | #define SYNTAX_FLAGS_PREFIX(flags) (((flags) >> 20) & 1) | ||
| 74 | |||
| 75 | #define SYNTAX_FLAGS_COMMENT_STYLEB(flags) (((flags) >> 21) & 1) | ||
| 76 | #define SYNTAX_FLAGS_COMMENT_STYLEC(flags) (((flags) >> 22) & 2) | ||
| 77 | /* FLAGS should be the flags of the main char of the comment marker, e.g. | ||
| 78 | the second for comstart and the first for comend. */ | ||
| 79 | #define SYNTAX_FLAGS_COMMENT_STYLE(flags, other_flags) \ | ||
| 80 | (SYNTAX_FLAGS_COMMENT_STYLEB (flags) \ | ||
| 81 | | SYNTAX_FLAGS_COMMENT_STYLEC (flags) \ | ||
| 82 | | SYNTAX_FLAGS_COMMENT_STYLEC (other_flags)) | ||
| 83 | |||
| 84 | #define SYNTAX_FLAGS_COMMENT_NESTED(flags) (((flags) >> 22) & 1) | ||
| 85 | |||
| 86 | /* These macros extract a particular flag for a given character. */ | ||
| 87 | |||
| 88 | #define SYNTAX_COMEND_FIRST(c) \ | ||
| 89 | (SYNTAX_FLAGS_COMEND_FIRST (SYNTAX_WITH_FLAGS (c))) | ||
| 90 | #define SYNTAX_PREFIX(c) (SYNTAX_FLAGS_PREFIX (SYNTAX_WITH_FLAGS (c))) | ||
| 37 | 91 | ||
| 38 | /* We use these constants in place for comment-style and | 92 | /* We use these constants in place for comment-style and |
| 39 | string-ender-char to distinguish comments/strings started by | 93 | string-ender-char to distinguish comments/strings started by |
| @@ -41,7 +95,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 41 | 95 | ||
| 42 | #define ST_COMMENT_STYLE (256 + 1) | 96 | #define ST_COMMENT_STYLE (256 + 1) |
| 43 | #define ST_STRING_STYLE (256 + 2) | 97 | #define ST_STRING_STYLE (256 + 2) |
| 44 | #include "category.h" | ||
| 45 | 98 | ||
| 46 | Lisp_Object Qsyntax_table_p, Qsyntax_table, Qscan_error; | 99 | Lisp_Object Qsyntax_table_p, Qsyntax_table, Qscan_error; |
| 47 | 100 | ||
| @@ -106,6 +159,11 @@ static void scan_sexps_forward (struct lisp_parse_state *, | |||
| 106 | int, Lisp_Object, int); | 159 | int, Lisp_Object, int); |
| 107 | static int in_classes (int, Lisp_Object); | 160 | static int in_classes (int, Lisp_Object); |
| 108 | 161 | ||
| 162 | /* Whether the syntax of the character C has the prefix flag set. */ | ||
| 163 | int syntax_prefix_flag_p (int c) | ||
| 164 | { | ||
| 165 | return SYNTAX_PREFIX (c); | ||
| 166 | } | ||
| 109 | 167 | ||
| 110 | struct gl_state_s gl_state; /* Global state of syntax parser. */ | 168 | struct gl_state_s gl_state; /* Global state of syntax parser. */ |
| 111 | 169 | ||
| @@ -514,7 +572,8 @@ back_comment (EMACS_INT from, EMACS_INT from_byte, EMACS_INT stop, int comnested | |||
| 514 | /* Check for 2-char comment markers. */ | 572 | /* Check for 2-char comment markers. */ |
| 515 | com2start = (SYNTAX_FLAGS_COMSTART_FIRST (syntax) | 573 | com2start = (SYNTAX_FLAGS_COMSTART_FIRST (syntax) |
| 516 | && SYNTAX_FLAGS_COMSTART_SECOND (prev_syntax) | 574 | && SYNTAX_FLAGS_COMSTART_SECOND (prev_syntax) |
| 517 | && comstyle == SYNTAX_FLAGS_COMMENT_STYLE (prev_syntax) | 575 | && (comstyle |
| 576 | == SYNTAX_FLAGS_COMMENT_STYLE (prev_syntax, syntax)) | ||
| 518 | && (SYNTAX_FLAGS_COMMENT_NESTED (prev_syntax) | 577 | && (SYNTAX_FLAGS_COMMENT_NESTED (prev_syntax) |
| 519 | || SYNTAX_FLAGS_COMMENT_NESTED (syntax)) == comnested); | 578 | || SYNTAX_FLAGS_COMMENT_NESTED (syntax)) == comnested); |
| 520 | com2end = (SYNTAX_FLAGS_COMEND_FIRST (syntax) | 579 | com2end = (SYNTAX_FLAGS_COMEND_FIRST (syntax) |
| @@ -543,7 +602,8 @@ back_comment (EMACS_INT from, EMACS_INT from_byte, EMACS_INT stop, int comnested | |||
| 543 | && SYNTAX_FLAGS_COMEND_FIRST (next_syntax)) | 602 | && SYNTAX_FLAGS_COMEND_FIRST (next_syntax)) |
| 544 | || ((com2end || comnested) | 603 | || ((com2end || comnested) |
| 545 | && SYNTAX_FLAGS_COMSTART_SECOND (syntax) | 604 | && SYNTAX_FLAGS_COMSTART_SECOND (syntax) |
| 546 | && comstyle == SYNTAX_FLAGS_COMMENT_STYLE (syntax) | 605 | && (comstyle |
| 606 | == SYNTAX_FLAGS_COMMENT_STYLE (syntax, prev_syntax)) | ||
| 547 | && SYNTAX_FLAGS_COMSTART_FIRST (next_syntax))) | 607 | && SYNTAX_FLAGS_COMSTART_FIRST (next_syntax))) |
| 548 | goto lossage; | 608 | goto lossage; |
| 549 | /* UPDATE_SYNTAX_TABLE_FORWARD (next + 1); */ | 609 | /* UPDATE_SYNTAX_TABLE_FORWARD (next + 1); */ |
| @@ -563,7 +623,7 @@ back_comment (EMACS_INT from, EMACS_INT from_byte, EMACS_INT stop, int comnested | |||
| 563 | code = Scomment; | 623 | code = Scomment; |
| 564 | /* Ignore comment starters of a different style. */ | 624 | /* Ignore comment starters of a different style. */ |
| 565 | else if (code == Scomment | 625 | else if (code == Scomment |
| 566 | && (comstyle != SYNTAX_FLAGS_COMMENT_STYLE (syntax) | 626 | && (comstyle != SYNTAX_FLAGS_COMMENT_STYLE (syntax, 0) |
| 567 | || SYNTAX_FLAGS_COMMENT_NESTED (syntax) != comnested)) | 627 | || SYNTAX_FLAGS_COMMENT_NESTED (syntax) != comnested)) |
| 568 | continue; | 628 | continue; |
| 569 | 629 | ||
| @@ -613,7 +673,7 @@ back_comment (EMACS_INT from, EMACS_INT from_byte, EMACS_INT stop, int comnested | |||
| 613 | break; | 673 | break; |
| 614 | 674 | ||
| 615 | case Sendcomment: | 675 | case Sendcomment: |
| 616 | if (SYNTAX_FLAGS_COMMENT_STYLE (syntax) == comstyle | 676 | if (SYNTAX_FLAGS_COMMENT_STYLE (syntax, 0) == comstyle |
| 617 | && ((com2end && SYNTAX_FLAGS_COMMENT_NESTED (prev_syntax)) | 677 | && ((com2end && SYNTAX_FLAGS_COMMENT_NESTED (prev_syntax)) |
| 618 | || SYNTAX_FLAGS_COMMENT_NESTED (syntax)) == comnested) | 678 | || SYNTAX_FLAGS_COMMENT_NESTED (syntax)) == comnested) |
| 619 | /* This is the same style of comment ender as ours. */ | 679 | /* This is the same style of comment ender as ours. */ |
| @@ -930,6 +990,10 @@ text property. */) | |||
| 930 | case 'n': | 990 | case 'n': |
| 931 | val |= 1 << 22; | 991 | val |= 1 << 22; |
| 932 | break; | 992 | break; |
| 993 | |||
| 994 | case 'c': | ||
| 995 | val |= 1 << 23; | ||
| 996 | break; | ||
| 933 | } | 997 | } |
| 934 | 998 | ||
| 935 | if (val < XVECTOR (Vsyntax_code_object)->size && NILP (match)) | 999 | if (val < XVECTOR (Vsyntax_code_object)->size && NILP (match)) |
| @@ -969,12 +1033,13 @@ Defined flags are the characters 1, 2, 3, 4, b, p, and n. | |||
| 969 | 3 means CHAR is the start of a two-char comment end sequence. | 1033 | 3 means CHAR is the start of a two-char comment end sequence. |
| 970 | 4 means CHAR is the second character of such a sequence. | 1034 | 4 means CHAR is the second character of such a sequence. |
| 971 | 1035 | ||
| 972 | There can be up to two orthogonal comment sequences. This is to support | 1036 | There can be several orthogonal comment sequences. This is to support |
| 973 | language modes such as C++. By default, all comment sequences are of style | 1037 | language modes such as C++. By default, all comment sequences are of style |
| 974 | a, but you can set the comment sequence style to b (on the second character | 1038 | a, but you can set the comment sequence style to b (on the second character |
| 975 | of a comment-start, or the first character of a comment-end sequence) using | 1039 | of a comment-start, and the first character of a comment-end sequence) and/or |
| 976 | this flag: | 1040 | c (on any of its chars) using this flag: |
| 977 | b means CHAR is part of comment sequence b. | 1041 | b means CHAR is part of comment sequence b. |
| 1042 | c means CHAR is part of comment sequence c. | ||
| 978 | n means CHAR is part of a nestable comment sequence. | 1043 | n means CHAR is part of a nestable comment sequence. |
| 979 | 1044 | ||
| 980 | p means CHAR is a prefix character for `backward-prefix-chars'; | 1045 | p means CHAR is a prefix character for `backward-prefix-chars'; |
| @@ -1017,7 +1082,9 @@ DEFUN ("internal-describe-syntax-value", Finternal_describe_syntax_value, | |||
| 1017 | (Lisp_Object syntax) | 1082 | (Lisp_Object syntax) |
| 1018 | { | 1083 | { |
| 1019 | register enum syntaxcode code; | 1084 | register enum syntaxcode code; |
| 1020 | char desc, start1, start2, end1, end2, prefix, comstyle, comnested; | 1085 | int syntax_code; |
| 1086 | char desc, start1, start2, end1, end2, prefix, | ||
| 1087 | comstyleb, comstylec, comnested; | ||
| 1021 | char str[2]; | 1088 | char str[2]; |
| 1022 | Lisp_Object first, match_lisp, value = syntax; | 1089 | Lisp_Object first, match_lisp, value = syntax; |
| 1023 | 1090 | ||
| @@ -1048,14 +1115,16 @@ DEFUN ("internal-describe-syntax-value", Finternal_describe_syntax_value, | |||
| 1048 | return syntax; | 1115 | return syntax; |
| 1049 | } | 1116 | } |
| 1050 | 1117 | ||
| 1051 | code = (enum syntaxcode) (XINT (first) & 0377); | 1118 | syntax_code = XINT (first); |
| 1052 | start1 = (XINT (first) >> 16) & 1; | 1119 | code = (enum syntaxcode) (syntax_code & 0377); |
| 1053 | start2 = (XINT (first) >> 17) & 1; | 1120 | start1 = SYNTAX_FLAGS_COMSTART_FIRST (syntax_code); |
| 1054 | end1 = (XINT (first) >> 18) & 1; | 1121 | start2 = SYNTAX_FLAGS_COMSTART_SECOND (syntax_code);; |
| 1055 | end2 = (XINT (first) >> 19) & 1; | 1122 | end1 = SYNTAX_FLAGS_COMEND_FIRST (syntax_code); |
| 1056 | prefix = (XINT (first) >> 20) & 1; | 1123 | end2 = SYNTAX_FLAGS_COMEND_SECOND (syntax_code); |
| 1057 | comstyle = (XINT (first) >> 21) & 1; | 1124 | prefix = SYNTAX_FLAGS_PREFIX (syntax_code); |
| 1058 | comnested = (XINT (first) >> 22) & 1; | 1125 | comstyleb = SYNTAX_FLAGS_COMMENT_STYLEB (syntax_code); |
| 1126 | comstylec = SYNTAX_FLAGS_COMMENT_STYLEC (syntax_code); | ||
| 1127 | comnested = SYNTAX_FLAGS_COMMENT_NESTED (syntax_code); | ||
| 1059 | 1128 | ||
| 1060 | if ((int) code < 0 || (int) code >= (int) Smax) | 1129 | if ((int) code < 0 || (int) code >= (int) Smax) |
| 1061 | { | 1130 | { |
| @@ -1084,8 +1153,10 @@ DEFUN ("internal-describe-syntax-value", Finternal_describe_syntax_value, | |||
| 1084 | 1153 | ||
| 1085 | if (prefix) | 1154 | if (prefix) |
| 1086 | insert ("p", 1); | 1155 | insert ("p", 1); |
| 1087 | if (comstyle) | 1156 | if (comstyleb) |
| 1088 | insert ("b", 1); | 1157 | insert ("b", 1); |
| 1158 | if (comstylec) | ||
| 1159 | insert ("c", 1); | ||
| 1089 | if (comnested) | 1160 | if (comnested) |
| 1090 | insert ("n", 1); | 1161 | insert ("n", 1); |
| 1091 | 1162 | ||
| @@ -1145,8 +1216,10 @@ DEFUN ("internal-describe-syntax-value", Finternal_describe_syntax_value, | |||
| 1145 | insert_string (",\n\t is the first character of a comment-end sequence"); | 1216 | insert_string (",\n\t is the first character of a comment-end sequence"); |
| 1146 | if (end2) | 1217 | if (end2) |
| 1147 | insert_string (",\n\t is the second character of a comment-end sequence"); | 1218 | insert_string (",\n\t is the second character of a comment-end sequence"); |
| 1148 | if (comstyle) | 1219 | if (comstyleb) |
| 1149 | insert_string (" (comment style b)"); | 1220 | insert_string (" (comment style b)"); |
| 1221 | if (comstylec) | ||
| 1222 | insert_string (" (comment style c)"); | ||
| 1150 | if (comnested) | 1223 | if (comnested) |
| 1151 | insert_string (" (nestable)"); | 1224 | insert_string (" (nestable)"); |
| 1152 | 1225 | ||
| @@ -2060,7 +2133,7 @@ in_classes (int c, Lisp_Object iso_classes) | |||
| 2060 | FROM_BYTE is the bytepos corresponding to FROM. | 2133 | FROM_BYTE is the bytepos corresponding to FROM. |
| 2061 | Do not move past STOP (a charpos). | 2134 | Do not move past STOP (a charpos). |
| 2062 | The comment over which we have to jump is of style STYLE | 2135 | The comment over which we have to jump is of style STYLE |
| 2063 | (either SYNTAX_COMMENT_STYLE(foo) or ST_COMMENT_STYLE). | 2136 | (either SYNTAX_FLAGS_COMMENT_STYLE(foo) or ST_COMMENT_STYLE). |
| 2064 | NESTING should be positive to indicate the nesting at the beginning | 2137 | NESTING should be positive to indicate the nesting at the beginning |
| 2065 | for nested comments and should be zero or negative else. | 2138 | for nested comments and should be zero or negative else. |
| 2066 | ST_COMMENT_STYLE cannot be nested. | 2139 | ST_COMMENT_STYLE cannot be nested. |
| @@ -2087,7 +2160,7 @@ forw_comment (EMACS_INT from, EMACS_INT from_byte, EMACS_INT stop, | |||
| 2087 | { | 2160 | { |
| 2088 | register int c, c1; | 2161 | register int c, c1; |
| 2089 | register enum syntaxcode code; | 2162 | register enum syntaxcode code; |
| 2090 | register int syntax; | 2163 | register int syntax, other_syntax; |
| 2091 | 2164 | ||
| 2092 | if (nesting <= 0) nesting = -1; | 2165 | if (nesting <= 0) nesting = -1; |
| 2093 | 2166 | ||
| @@ -2109,7 +2182,7 @@ forw_comment (EMACS_INT from, EMACS_INT from_byte, EMACS_INT stop, | |||
| 2109 | syntax = SYNTAX_WITH_FLAGS (c); | 2182 | syntax = SYNTAX_WITH_FLAGS (c); |
| 2110 | code = syntax & 0xff; | 2183 | code = syntax & 0xff; |
| 2111 | if (code == Sendcomment | 2184 | if (code == Sendcomment |
| 2112 | && SYNTAX_FLAGS_COMMENT_STYLE (syntax) == style | 2185 | && SYNTAX_FLAGS_COMMENT_STYLE (syntax, 0) == style |
| 2113 | && (SYNTAX_FLAGS_COMMENT_NESTED (syntax) ? | 2186 | && (SYNTAX_FLAGS_COMMENT_NESTED (syntax) ? |
| 2114 | (nesting > 0 && --nesting == 0) : nesting < 0)) | 2187 | (nesting > 0 && --nesting == 0) : nesting < 0)) |
| 2115 | /* we have encountered a comment end of the same style | 2188 | /* we have encountered a comment end of the same style |
| @@ -2125,7 +2198,7 @@ forw_comment (EMACS_INT from, EMACS_INT from_byte, EMACS_INT stop, | |||
| 2125 | if (nesting > 0 | 2198 | if (nesting > 0 |
| 2126 | && code == Scomment | 2199 | && code == Scomment |
| 2127 | && SYNTAX_FLAGS_COMMENT_NESTED (syntax) | 2200 | && SYNTAX_FLAGS_COMMENT_NESTED (syntax) |
| 2128 | && SYNTAX_FLAGS_COMMENT_STYLE (syntax) == style) | 2201 | && SYNTAX_FLAGS_COMMENT_STYLE (syntax, 0) == style) |
| 2129 | /* we have encountered a nested comment of the same style | 2202 | /* we have encountered a nested comment of the same style |
| 2130 | as the comment sequence which began this comment section */ | 2203 | as the comment sequence which began this comment section */ |
| 2131 | nesting++; | 2204 | nesting++; |
| @@ -2134,11 +2207,13 @@ forw_comment (EMACS_INT from, EMACS_INT from_byte, EMACS_INT stop, | |||
| 2134 | 2207 | ||
| 2135 | forw_incomment: | 2208 | forw_incomment: |
| 2136 | if (from < stop && SYNTAX_FLAGS_COMEND_FIRST (syntax) | 2209 | if (from < stop && SYNTAX_FLAGS_COMEND_FIRST (syntax) |
| 2137 | && SYNTAX_FLAGS_COMMENT_STYLE (syntax) == style | ||
| 2138 | && (c1 = FETCH_CHAR_AS_MULTIBYTE (from_byte), | 2210 | && (c1 = FETCH_CHAR_AS_MULTIBYTE (from_byte), |
| 2139 | SYNTAX_COMEND_SECOND (c1)) | 2211 | other_syntax = SYNTAX_WITH_FLAGS (c1), |
| 2212 | SYNTAX_FLAGS_COMEND_SECOND (other_syntax)) | ||
| 2213 | && SYNTAX_FLAGS_COMMENT_STYLE (syntax, other_syntax) == style | ||
| 2140 | && ((SYNTAX_FLAGS_COMMENT_NESTED (syntax) || | 2214 | && ((SYNTAX_FLAGS_COMMENT_NESTED (syntax) || |
| 2141 | SYNTAX_COMMENT_NESTED (c1)) ? nesting > 0 : nesting < 0)) | 2215 | SYNTAX_FLAGS_COMMENT_NESTED (other_syntax)) |
| 2216 | ? nesting > 0 : nesting < 0)) | ||
| 2142 | { | 2217 | { |
| 2143 | if (--nesting <= 0) | 2218 | if (--nesting <= 0) |
| 2144 | /* we have encountered a comment end of the same style | 2219 | /* we have encountered a comment end of the same style |
| @@ -2155,10 +2230,11 @@ forw_comment (EMACS_INT from, EMACS_INT from_byte, EMACS_INT stop, | |||
| 2155 | && from < stop | 2230 | && from < stop |
| 2156 | && SYNTAX_FLAGS_COMSTART_FIRST (syntax) | 2231 | && SYNTAX_FLAGS_COMSTART_FIRST (syntax) |
| 2157 | && (c1 = FETCH_CHAR_AS_MULTIBYTE (from_byte), | 2232 | && (c1 = FETCH_CHAR_AS_MULTIBYTE (from_byte), |
| 2158 | SYNTAX_COMMENT_STYLE (c1) == style | 2233 | other_syntax = SYNTAX_WITH_FLAGS (c1), |
| 2159 | && SYNTAX_COMSTART_SECOND (c1)) | 2234 | SYNTAX_FLAGS_COMMENT_STYLE (other_syntax, syntax) == style |
| 2235 | && SYNTAX_FLAGS_COMSTART_SECOND (other_syntax)) | ||
| 2160 | && (SYNTAX_FLAGS_COMMENT_NESTED (syntax) || | 2236 | && (SYNTAX_FLAGS_COMMENT_NESTED (syntax) || |
| 2161 | SYNTAX_COMMENT_NESTED (c1))) | 2237 | SYNTAX_FLAGS_COMMENT_NESTED (other_syntax))) |
| 2162 | /* we have encountered a nested comment of the same style | 2238 | /* we have encountered a nested comment of the same style |
| 2163 | as the comment sequence which began this comment | 2239 | as the comment sequence which began this comment |
| 2164 | section */ | 2240 | section */ |
| @@ -2209,7 +2285,7 @@ between them, return t; otherwise return nil. */) | |||
| 2209 | { | 2285 | { |
| 2210 | do | 2286 | do |
| 2211 | { | 2287 | { |
| 2212 | int comstart_first; | 2288 | int comstart_first, syntax, other_syntax; |
| 2213 | 2289 | ||
| 2214 | if (from == stop) | 2290 | if (from == stop) |
| 2215 | { | 2291 | { |
| @@ -2218,15 +2294,17 @@ between them, return t; otherwise return nil. */) | |||
| 2218 | return Qnil; | 2294 | return Qnil; |
| 2219 | } | 2295 | } |
| 2220 | c = FETCH_CHAR_AS_MULTIBYTE (from_byte); | 2296 | c = FETCH_CHAR_AS_MULTIBYTE (from_byte); |
| 2297 | syntax = SYNTAX_WITH_FLAGS (c); | ||
| 2221 | code = SYNTAX (c); | 2298 | code = SYNTAX (c); |
| 2222 | comstart_first = SYNTAX_COMSTART_FIRST (c); | 2299 | comstart_first = SYNTAX_FLAGS_COMSTART_FIRST (syntax); |
| 2223 | comnested = SYNTAX_COMMENT_NESTED (c); | 2300 | comnested = SYNTAX_FLAGS_COMMENT_NESTED (syntax); |
| 2224 | comstyle = SYNTAX_COMMENT_STYLE (c); | 2301 | comstyle = SYNTAX_FLAGS_COMMENT_STYLE (syntax, 0); |
| 2225 | INC_BOTH (from, from_byte); | 2302 | INC_BOTH (from, from_byte); |
| 2226 | UPDATE_SYNTAX_TABLE_FORWARD (from); | 2303 | UPDATE_SYNTAX_TABLE_FORWARD (from); |
| 2227 | if (from < stop && comstart_first | 2304 | if (from < stop && comstart_first |
| 2228 | && (c1 = FETCH_CHAR_AS_MULTIBYTE (from_byte), | 2305 | && (c1 = FETCH_CHAR_AS_MULTIBYTE (from_byte), |
| 2229 | SYNTAX_COMSTART_SECOND (c1))) | 2306 | other_syntax = SYNTAX_WITH_FLAGS (c1), |
| 2307 | SYNTAX_FLAGS_COMSTART_SECOND (other_syntax))) | ||
| 2230 | { | 2308 | { |
| 2231 | /* We have encountered a comment start sequence and we | 2309 | /* We have encountered a comment start sequence and we |
| 2232 | are ignoring all text inside comments. We must record | 2310 | are ignoring all text inside comments. We must record |
| @@ -2234,8 +2312,9 @@ between them, return t; otherwise return nil. */) | |||
| 2234 | only a comment end of the same style actually ends | 2312 | only a comment end of the same style actually ends |
| 2235 | the comment section. */ | 2313 | the comment section. */ |
| 2236 | code = Scomment; | 2314 | code = Scomment; |
| 2237 | comstyle = SYNTAX_COMMENT_STYLE (c1); | 2315 | comstyle = SYNTAX_FLAGS_COMMENT_STYLE (other_syntax, syntax); |
| 2238 | comnested = comnested || SYNTAX_COMMENT_NESTED (c1); | 2316 | comnested |
| 2317 | = comnested || SYNTAX_FLAGS_COMMENT_NESTED (other_syntax); | ||
| 2239 | INC_BOTH (from, from_byte); | 2318 | INC_BOTH (from, from_byte); |
| 2240 | UPDATE_SYNTAX_TABLE_FORWARD (from); | 2319 | UPDATE_SYNTAX_TABLE_FORWARD (from); |
| 2241 | } | 2320 | } |
| @@ -2271,7 +2350,7 @@ between them, return t; otherwise return nil. */) | |||
| 2271 | { | 2350 | { |
| 2272 | while (1) | 2351 | while (1) |
| 2273 | { | 2352 | { |
| 2274 | int quoted; | 2353 | int quoted, syntax; |
| 2275 | 2354 | ||
| 2276 | if (from <= stop) | 2355 | if (from <= stop) |
| 2277 | { | 2356 | { |
| @@ -2284,15 +2363,17 @@ between them, return t; otherwise return nil. */) | |||
| 2284 | /* char_quoted does UPDATE_SYNTAX_TABLE_BACKWARD (from). */ | 2363 | /* char_quoted does UPDATE_SYNTAX_TABLE_BACKWARD (from). */ |
| 2285 | quoted = char_quoted (from, from_byte); | 2364 | quoted = char_quoted (from, from_byte); |
| 2286 | c = FETCH_CHAR_AS_MULTIBYTE (from_byte); | 2365 | c = FETCH_CHAR_AS_MULTIBYTE (from_byte); |
| 2366 | syntax = SYNTAX_WITH_FLAGS (c); | ||
| 2287 | code = SYNTAX (c); | 2367 | code = SYNTAX (c); |
| 2288 | comstyle = 0; | 2368 | comstyle = 0; |
| 2289 | comnested = SYNTAX_COMMENT_NESTED (c); | 2369 | comnested = SYNTAX_FLAGS_COMMENT_NESTED (syntax); |
| 2290 | if (code == Sendcomment) | 2370 | if (code == Sendcomment) |
| 2291 | comstyle = SYNTAX_COMMENT_STYLE (c); | 2371 | comstyle = SYNTAX_FLAGS_COMMENT_STYLE (syntax, 0); |
| 2292 | if (from > stop && SYNTAX_COMEND_SECOND (c) | 2372 | if (from > stop && SYNTAX_FLAGS_COMEND_SECOND (syntax) |
| 2293 | && prev_char_comend_first (from, from_byte) | 2373 | && prev_char_comend_first (from, from_byte) |
| 2294 | && !char_quoted (from - 1, dec_bytepos (from_byte))) | 2374 | && !char_quoted (from - 1, dec_bytepos (from_byte))) |
| 2295 | { | 2375 | { |
| 2376 | int other_syntax; | ||
| 2296 | /* We must record the comment style encountered so that | 2377 | /* We must record the comment style encountered so that |
| 2297 | later, we can match only the proper comment begin | 2378 | later, we can match only the proper comment begin |
| 2298 | sequence of the same style. */ | 2379 | sequence of the same style. */ |
| @@ -2301,8 +2382,10 @@ between them, return t; otherwise return nil. */) | |||
| 2301 | /* Calling char_quoted, above, set up global syntax position | 2382 | /* Calling char_quoted, above, set up global syntax position |
| 2302 | at the new value of FROM. */ | 2383 | at the new value of FROM. */ |
| 2303 | c1 = FETCH_CHAR_AS_MULTIBYTE (from_byte); | 2384 | c1 = FETCH_CHAR_AS_MULTIBYTE (from_byte); |
| 2304 | comstyle = SYNTAX_COMMENT_STYLE (c1); | 2385 | other_syntax = SYNTAX_WITH_FLAGS (c1); |
| 2305 | comnested = comnested || SYNTAX_COMMENT_NESTED (c1); | 2386 | comstyle = SYNTAX_FLAGS_COMMENT_STYLE (other_syntax, syntax); |
| 2387 | comnested | ||
| 2388 | = comnested || SYNTAX_FLAGS_COMMENT_NESTED (other_syntax); | ||
| 2306 | } | 2389 | } |
| 2307 | 2390 | ||
| 2308 | if (code == Scomment_fence) | 2391 | if (code == Scomment_fence) |
| @@ -2349,7 +2432,7 @@ between them, return t; otherwise return nil. */) | |||
| 2349 | { | 2432 | { |
| 2350 | /* Failure: we should go back to the end of this | 2433 | /* Failure: we should go back to the end of this |
| 2351 | not-quite-endcomment. */ | 2434 | not-quite-endcomment. */ |
| 2352 | if (SYNTAX(c) != code) | 2435 | if (SYNTAX (c) != code) |
| 2353 | /* It was a two-char Sendcomment. */ | 2436 | /* It was a two-char Sendcomment. */ |
| 2354 | INC_BOTH (from, from_byte); | 2437 | INC_BOTH (from, from_byte); |
| 2355 | goto leave; | 2438 | goto leave; |
| @@ -2423,21 +2506,23 @@ scan_lists (register EMACS_INT from, EMACS_INT count, EMACS_INT depth, int sexpf | |||
| 2423 | { | 2506 | { |
| 2424 | while (from < stop) | 2507 | while (from < stop) |
| 2425 | { | 2508 | { |
| 2426 | int comstart_first, prefix; | 2509 | int comstart_first, prefix, syntax, other_syntax; |
| 2427 | UPDATE_SYNTAX_TABLE_FORWARD (from); | 2510 | UPDATE_SYNTAX_TABLE_FORWARD (from); |
| 2428 | c = FETCH_CHAR_AS_MULTIBYTE (from_byte); | 2511 | c = FETCH_CHAR_AS_MULTIBYTE (from_byte); |
| 2512 | syntax = SYNTAX_WITH_FLAGS (c); | ||
| 2429 | code = SYNTAX_WITH_MULTIBYTE_CHECK (c); | 2513 | code = SYNTAX_WITH_MULTIBYTE_CHECK (c); |
| 2430 | comstart_first = SYNTAX_COMSTART_FIRST (c); | 2514 | comstart_first = SYNTAX_FLAGS_COMSTART_FIRST (syntax); |
| 2431 | comnested = SYNTAX_COMMENT_NESTED (c); | 2515 | comnested = SYNTAX_FLAGS_COMMENT_NESTED (syntax); |
| 2432 | comstyle = SYNTAX_COMMENT_STYLE (c); | 2516 | comstyle = SYNTAX_FLAGS_COMMENT_STYLE (syntax, 0); |
| 2433 | prefix = SYNTAX_PREFIX (c); | 2517 | prefix = SYNTAX_FLAGS_PREFIX (syntax); |
| 2434 | if (depth == min_depth) | 2518 | if (depth == min_depth) |
| 2435 | last_good = from; | 2519 | last_good = from; |
| 2436 | INC_BOTH (from, from_byte); | 2520 | INC_BOTH (from, from_byte); |
| 2437 | UPDATE_SYNTAX_TABLE_FORWARD (from); | 2521 | UPDATE_SYNTAX_TABLE_FORWARD (from); |
| 2438 | if (from < stop && comstart_first | 2522 | if (from < stop && comstart_first |
| 2439 | && (c = FETCH_CHAR_AS_MULTIBYTE (from_byte), | 2523 | && (c = FETCH_CHAR_AS_MULTIBYTE (from_byte), |
| 2440 | SYNTAX_COMSTART_SECOND (c)) | 2524 | other_syntax = SYNTAX_WITH_FLAGS (c), |
| 2525 | SYNTAX_FLAGS_COMSTART_SECOND (other_syntax)) | ||
| 2441 | && parse_sexp_ignore_comments) | 2526 | && parse_sexp_ignore_comments) |
| 2442 | { | 2527 | { |
| 2443 | /* we have encountered a comment start sequence and we | 2528 | /* we have encountered a comment start sequence and we |
| @@ -2446,9 +2531,9 @@ scan_lists (register EMACS_INT from, EMACS_INT count, EMACS_INT depth, int sexpf | |||
| 2446 | only a comment end of the same style actually ends | 2531 | only a comment end of the same style actually ends |
| 2447 | the comment section */ | 2532 | the comment section */ |
| 2448 | code = Scomment; | 2533 | code = Scomment; |
| 2449 | c1 = FETCH_CHAR_AS_MULTIBYTE (from_byte); | 2534 | comstyle = SYNTAX_FLAGS_COMMENT_STYLE (other_syntax, syntax); |
| 2450 | comstyle = SYNTAX_COMMENT_STYLE (c1); | 2535 | comnested |
| 2451 | comnested = comnested || SYNTAX_COMMENT_NESTED (c1); | 2536 | = comnested || SYNTAX_FLAGS_COMMENT_NESTED (other_syntax); |
| 2452 | INC_BOTH (from, from_byte); | 2537 | INC_BOTH (from, from_byte); |
| 2453 | UPDATE_SYNTAX_TABLE_FORWARD (from); | 2538 | UPDATE_SYNTAX_TABLE_FORWARD (from); |
| 2454 | } | 2539 | } |
| @@ -2592,29 +2677,34 @@ scan_lists (register EMACS_INT from, EMACS_INT count, EMACS_INT depth, int sexpf | |||
| 2592 | { | 2677 | { |
| 2593 | while (from > stop) | 2678 | while (from > stop) |
| 2594 | { | 2679 | { |
| 2680 | int syntax; | ||
| 2595 | DEC_BOTH (from, from_byte); | 2681 | DEC_BOTH (from, from_byte); |
| 2596 | UPDATE_SYNTAX_TABLE_BACKWARD (from); | 2682 | UPDATE_SYNTAX_TABLE_BACKWARD (from); |
| 2597 | c = FETCH_CHAR_AS_MULTIBYTE (from_byte); | 2683 | c = FETCH_CHAR_AS_MULTIBYTE (from_byte); |
| 2684 | syntax= SYNTAX_WITH_FLAGS (c); | ||
| 2598 | code = SYNTAX_WITH_MULTIBYTE_CHECK (c); | 2685 | code = SYNTAX_WITH_MULTIBYTE_CHECK (c); |
| 2599 | if (depth == min_depth) | 2686 | if (depth == min_depth) |
| 2600 | last_good = from; | 2687 | last_good = from; |
| 2601 | comstyle = 0; | 2688 | comstyle = 0; |
| 2602 | comnested = SYNTAX_COMMENT_NESTED (c); | 2689 | comnested = SYNTAX_FLAGS_COMMENT_NESTED (syntax); |
| 2603 | if (code == Sendcomment) | 2690 | if (code == Sendcomment) |
| 2604 | comstyle = SYNTAX_COMMENT_STYLE (c); | 2691 | comstyle = SYNTAX_FLAGS_COMMENT_STYLE (syntax, 0); |
| 2605 | if (from > stop && SYNTAX_COMEND_SECOND (c) | 2692 | if (from > stop && SYNTAX_FLAGS_COMEND_SECOND (syntax) |
| 2606 | && prev_char_comend_first (from, from_byte) | 2693 | && prev_char_comend_first (from, from_byte) |
| 2607 | && parse_sexp_ignore_comments) | 2694 | && parse_sexp_ignore_comments) |
| 2608 | { | 2695 | { |
| 2609 | /* We must record the comment style encountered so that | 2696 | /* We must record the comment style encountered so that |
| 2610 | later, we can match only the proper comment begin | 2697 | later, we can match only the proper comment begin |
| 2611 | sequence of the same style. */ | 2698 | sequence of the same style. */ |
| 2699 | int c1, other_syntax; | ||
| 2612 | DEC_BOTH (from, from_byte); | 2700 | DEC_BOTH (from, from_byte); |
| 2613 | UPDATE_SYNTAX_TABLE_BACKWARD (from); | 2701 | UPDATE_SYNTAX_TABLE_BACKWARD (from); |
| 2614 | code = Sendcomment; | 2702 | code = Sendcomment; |
| 2615 | c1 = FETCH_CHAR_AS_MULTIBYTE (from_byte); | 2703 | c1 = FETCH_CHAR_AS_MULTIBYTE (from_byte); |
| 2616 | comstyle = SYNTAX_COMMENT_STYLE (c1); | 2704 | other_syntax = SYNTAX_WITH_FLAGS (c1); |
| 2617 | comnested = comnested || SYNTAX_COMMENT_NESTED (c1); | 2705 | comstyle = SYNTAX_FLAGS_COMMENT_STYLE (other_syntax, syntax); |
| 2706 | comnested | ||
| 2707 | = comnested || SYNTAX_FLAGS_COMMENT_NESTED (other_syntax); | ||
| 2618 | } | 2708 | } |
| 2619 | 2709 | ||
| 2620 | /* Quoting turns anything except a comment-ender | 2710 | /* Quoting turns anything except a comment-ender |
| @@ -2625,7 +2715,7 @@ scan_lists (register EMACS_INT from, EMACS_INT count, EMACS_INT depth, int sexpf | |||
| 2625 | DEC_BOTH (from, from_byte); | 2715 | DEC_BOTH (from, from_byte); |
| 2626 | code = Sword; | 2716 | code = Sword; |
| 2627 | } | 2717 | } |
| 2628 | else if (SYNTAX_PREFIX (c)) | 2718 | else if (SYNTAX_FLAGS_PREFIX (syntax)) |
| 2629 | continue; | 2719 | continue; |
| 2630 | 2720 | ||
| 2631 | switch (SWITCH_ENUM_CAST (code)) | 2721 | switch (SWITCH_ENUM_CAST (code)) |
| @@ -2949,8 +3039,11 @@ do { prev_from = from; \ | |||
| 2949 | oldstate = Fcdr (oldstate); | 3039 | oldstate = Fcdr (oldstate); |
| 2950 | oldstate = Fcdr (oldstate); | 3040 | oldstate = Fcdr (oldstate); |
| 2951 | tem = Fcar (oldstate); | 3041 | tem = Fcar (oldstate); |
| 2952 | state.comstyle = NILP (tem) ? 0 : (EQ (tem, Qsyntax_table) | 3042 | state.comstyle = (NILP (tem) |
| 2953 | ? ST_COMMENT_STYLE : 1); | 3043 | ? 0 |
| 3044 | : (EQ (tem, Qsyntax_table) | ||
| 3045 | ? ST_COMMENT_STYLE | ||
| 3046 | : INTEGERP (tem) ? XINT (tem) : 1)); | ||
| 2954 | 3047 | ||
| 2955 | oldstate = Fcdr (oldstate); | 3048 | oldstate = Fcdr (oldstate); |
| 2956 | tem = Fcar (oldstate); | 3049 | tem = Fcar (oldstate); |
| @@ -2995,22 +3088,25 @@ do { prev_from = from; \ | |||
| 2995 | 3088 | ||
| 2996 | while (from < end) | 3089 | while (from < end) |
| 2997 | { | 3090 | { |
| 3091 | int syntax; | ||
| 2998 | INC_FROM; | 3092 | INC_FROM; |
| 2999 | code = prev_from_syntax & 0xff; | 3093 | code = prev_from_syntax & 0xff; |
| 3000 | 3094 | ||
| 3001 | if (from < end | 3095 | if (from < end |
| 3002 | && SYNTAX_FLAGS_COMSTART_FIRST (prev_from_syntax) | 3096 | && SYNTAX_FLAGS_COMSTART_FIRST (prev_from_syntax) |
| 3003 | && (c1 = FETCH_CHAR (from_byte), | 3097 | && (c1 = FETCH_CHAR (from_byte), |
| 3004 | SYNTAX_COMSTART_SECOND (c1))) | 3098 | syntax = SYNTAX_WITH_FLAGS (c1), |
| 3099 | SYNTAX_FLAGS_COMSTART_SECOND (syntax))) | ||
| 3005 | /* Duplicate code to avoid a complex if-expression | 3100 | /* Duplicate code to avoid a complex if-expression |
| 3006 | which causes trouble for the SGI compiler. */ | 3101 | which causes trouble for the SGI compiler. */ |
| 3007 | { | 3102 | { |
| 3008 | /* Record the comment style we have entered so that only | 3103 | /* Record the comment style we have entered so that only |
| 3009 | the comment-end sequence of the same style actually | 3104 | the comment-end sequence of the same style actually |
| 3010 | terminates the comment section. */ | 3105 | terminates the comment section. */ |
| 3011 | state.comstyle = SYNTAX_COMMENT_STYLE (c1); | 3106 | state.comstyle |
| 3107 | = SYNTAX_FLAGS_COMMENT_STYLE (syntax, prev_from_syntax); | ||
| 3012 | comnested = SYNTAX_FLAGS_COMMENT_NESTED (prev_from_syntax); | 3108 | comnested = SYNTAX_FLAGS_COMMENT_NESTED (prev_from_syntax); |
| 3013 | comnested = comnested || SYNTAX_COMMENT_NESTED (c1); | 3109 | comnested = comnested || SYNTAX_FLAGS_COMMENT_NESTED (syntax); |
| 3014 | state.incomment = comnested ? 1 : -1; | 3110 | state.incomment = comnested ? 1 : -1; |
| 3015 | state.comstr_start = prev_from; | 3111 | state.comstr_start = prev_from; |
| 3016 | INC_FROM; | 3112 | INC_FROM; |
| @@ -3028,7 +3124,7 @@ do { prev_from = from; \ | |||
| 3028 | } | 3124 | } |
| 3029 | else if (code == Scomment) | 3125 | else if (code == Scomment) |
| 3030 | { | 3126 | { |
| 3031 | state.comstyle = SYNTAX_FLAGS_COMMENT_STYLE (prev_from_syntax); | 3127 | state.comstyle = SYNTAX_FLAGS_COMMENT_STYLE (prev_from_syntax, 0); |
| 3032 | state.incomment = (SYNTAX_FLAGS_COMMENT_NESTED (prev_from_syntax) ? | 3128 | state.incomment = (SYNTAX_FLAGS_COMMENT_NESTED (prev_from_syntax) ? |
| 3033 | 1 : -1); | 3129 | 1 : -1); |
| 3034 | state.comstr_start = prev_from; | 3130 | state.comstr_start = prev_from; |
| @@ -3221,8 +3317,7 @@ Value is a list of elements describing final state of parsing: | |||
| 3221 | else an integer (the current comment nesting). | 3317 | else an integer (the current comment nesting). |
| 3222 | 5. t if following a quote character. | 3318 | 5. t if following a quote character. |
| 3223 | 6. the minimum paren-depth encountered during this scan. | 3319 | 6. the minimum paren-depth encountered during this scan. |
| 3224 | 7. t if in a comment of style b; symbol `syntax-table' if the comment | 3320 | 7. style of comment, if any. |
| 3225 | should be terminated by a generic comment delimiter. | ||
| 3226 | 8. character address of start of comment or string; nil if not in one. | 3321 | 8. character address of start of comment or string; nil if not in one. |
| 3227 | 9. Intermediate data for continuation of parsing (subject to change). | 3322 | 9. Intermediate data for continuation of parsing (subject to change). |
| 3228 | If third arg TARGETDEPTH is non-nil, parsing stops if the depth | 3323 | If third arg TARGETDEPTH is non-nil, parsing stops if the depth |
| @@ -3258,8 +3353,10 @@ Sixth arg COMMENTSTOP non-nil means stop at the start of a comment. | |||
| 3258 | SET_PT (state.location); | 3353 | SET_PT (state.location); |
| 3259 | 3354 | ||
| 3260 | return Fcons (make_number (state.depth), | 3355 | return Fcons (make_number (state.depth), |
| 3261 | Fcons (state.prevlevelstart < 0 ? Qnil : make_number (state.prevlevelstart), | 3356 | Fcons (state.prevlevelstart < 0 |
| 3262 | Fcons (state.thislevelstart < 0 ? Qnil : make_number (state.thislevelstart), | 3357 | ? Qnil : make_number (state.prevlevelstart), |
| 3358 | Fcons (state.thislevelstart < 0 | ||
| 3359 | ? Qnil : make_number (state.thislevelstart), | ||
| 3263 | Fcons (state.instring >= 0 | 3360 | Fcons (state.instring >= 0 |
| 3264 | ? (state.instring == ST_STRING_STYLE | 3361 | ? (state.instring == ST_STRING_STYLE |
| 3265 | ? Qt : make_number (state.instring)) : Qnil, | 3362 | ? Qt : make_number (state.instring)) : Qnil, |
| @@ -3270,8 +3367,9 @@ Sixth arg COMMENTSTOP non-nil means stop at the start of a comment. | |||
| 3270 | Fcons (make_number (state.mindepth), | 3367 | Fcons (make_number (state.mindepth), |
| 3271 | Fcons ((state.comstyle | 3368 | Fcons ((state.comstyle |
| 3272 | ? (state.comstyle == ST_COMMENT_STYLE | 3369 | ? (state.comstyle == ST_COMMENT_STYLE |
| 3273 | ? Qsyntax_table : Qt) : | 3370 | ? Qsyntax_table |
| 3274 | Qnil), | 3371 | : make_number (state.comstyle)) |
| 3372 | : Qnil), | ||
| 3275 | Fcons (((state.incomment | 3373 | Fcons (((state.incomment |
| 3276 | || (state.instring >= 0)) | 3374 | || (state.instring >= 0)) |
| 3277 | ? make_number (state.comstr_start) | 3375 | ? make_number (state.comstr_start) |
diff --git a/src/syntax.h b/src/syntax.h index 9eaf553f2e5..48146572d19 100644 --- a/src/syntax.h +++ b/src/syntax.h | |||
| @@ -128,56 +128,9 @@ extern Lisp_Object syntax_temp; | |||
| 128 | : Qnil)) | 128 | : Qnil)) |
| 129 | #endif | 129 | #endif |
| 130 | 130 | ||
| 131 | /* Then there are seven single-bit flags that have the following meanings: | ||
| 132 | 1. This character is the first of a two-character comment-start sequence. | ||
| 133 | 2. This character is the second of a two-character comment-start sequence. | ||
| 134 | 3. This character is the first of a two-character comment-end sequence. | ||
| 135 | 4. This character is the second of a two-character comment-end sequence. | ||
| 136 | 5. This character is a prefix, for backward-prefix-chars. | ||
| 137 | 6. see below | ||
| 138 | 7. This character is part of a nestable comment sequence. | ||
| 139 | Note that any two-character sequence whose first character has flag 1 | ||
| 140 | and whose second character has flag 2 will be interpreted as a comment start. | ||
| 141 | 131 | ||
| 142 | bit 6 is used to discriminate between two different comment styles. | 132 | /* Whether the syntax of the character C has the prefix flag set. */ |
| 143 | Languages such as C++ allow two orthogonal syntax start/end pairs | 133 | extern int syntax_prefix_flag_p (int c); |
| 144 | and bit 6 is used to determine whether a comment-end or Scommentend | ||
| 145 | ends style a or b. Comment start sequences can start style a or b. | ||
| 146 | Style a is always the default. | ||
| 147 | */ | ||
| 148 | |||
| 149 | /* These macros extract a particular flag for a given character. */ | ||
| 150 | |||
| 151 | #define SYNTAX_COMSTART_FIRST(c) ((SYNTAX_WITH_FLAGS (c) >> 16) & 1) | ||
| 152 | |||
| 153 | #define SYNTAX_COMSTART_SECOND(c) ((SYNTAX_WITH_FLAGS (c) >> 17) & 1) | ||
| 154 | |||
| 155 | #define SYNTAX_COMEND_FIRST(c) ((SYNTAX_WITH_FLAGS (c) >> 18) & 1) | ||
| 156 | |||
| 157 | #define SYNTAX_COMEND_SECOND(c) ((SYNTAX_WITH_FLAGS (c) >> 19) & 1) | ||
| 158 | |||
| 159 | #define SYNTAX_PREFIX(c) ((SYNTAX_WITH_FLAGS (c) >> 20) & 1) | ||
| 160 | |||
| 161 | #define SYNTAX_COMMENT_STYLE(c) ((SYNTAX_WITH_FLAGS (c) >> 21) & 1) | ||
| 162 | |||
| 163 | #define SYNTAX_COMMENT_NESTED(c) ((SYNTAX_WITH_FLAGS (c) >> 22) & 1) | ||
| 164 | |||
| 165 | /* These macros extract specific flags from an integer | ||
| 166 | that holds the syntax code and the flags. */ | ||
| 167 | |||
| 168 | #define SYNTAX_FLAGS_COMSTART_FIRST(flags) (((flags) >> 16) & 1) | ||
| 169 | |||
| 170 | #define SYNTAX_FLAGS_COMSTART_SECOND(flags) (((flags) >> 17) & 1) | ||
| 171 | |||
| 172 | #define SYNTAX_FLAGS_COMEND_FIRST(flags) (((flags) >> 18) & 1) | ||
| 173 | |||
| 174 | #define SYNTAX_FLAGS_COMEND_SECOND(flags) (((flags) >> 19) & 1) | ||
| 175 | |||
| 176 | #define SYNTAX_FLAGS_PREFIX(flags) (((flags) >> 20) & 1) | ||
| 177 | |||
| 178 | #define SYNTAX_FLAGS_COMMENT_STYLE(flags) (((flags) >> 21) & 1) | ||
| 179 | |||
| 180 | #define SYNTAX_FLAGS_COMMENT_NESTED(flags) (((flags) >> 22) & 1) | ||
| 181 | 134 | ||
| 182 | /* This array, indexed by a character, contains the syntax code which that | 135 | /* This array, indexed by a character, contains the syntax code which that |
| 183 | character signifies (as a char). For example, | 136 | character signifies (as a char). For example, |