Mercurial > emacs
annotate src/syntax.c @ 39656:4dd0be77b12e
*** empty log message ***
author | Miles Bader <miles@gnu.org> |
---|---|
date | Sun, 07 Oct 2001 17:14:34 +0000 |
parents | 004939041c32 |
children | 42b7a798ff79 |
rev | line source |
---|---|
163 | 1 /* GNU Emacs routines to deal with syntax tables; also word and list parsing. |
26060
6edf64bf5e22
(Fforward_word): Supply new ESCAPE_FROM_EDGE parameter
Gerd Moellmann <gerd@gnu.org>
parents:
25771
diff
changeset
|
2 Copyright (C) 1985, 87, 93, 94, 95, 97, 1998, 1999 Free Software Foundation, Inc. |
163 | 3 |
4 This file is part of GNU Emacs. | |
5 | |
6 GNU Emacs is free software; you can redistribute it and/or modify | |
7 it under the terms of the GNU General Public License as published by | |
726 | 8 the Free Software Foundation; either version 2, or (at your option) |
163 | 9 any later version. |
10 | |
11 GNU Emacs is distributed in the hope that it will be useful, | |
12 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 GNU General Public License for more details. | |
15 | |
16 You should have received a copy of the GNU General Public License | |
17 along with GNU Emacs; see the file COPYING. If not, write to | |
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
14087
diff
changeset
|
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
14087
diff
changeset
|
19 Boston, MA 02111-1307, USA. */ |
163 | 20 |
21 | |
4696
1fc792473491
Include <config.h> instead of "config.h".
Roland McGrath <roland@gnu.org>
parents:
4458
diff
changeset
|
22 #include <config.h> |
163 | 23 #include <ctype.h> |
24 #include "lisp.h" | |
25 #include "commands.h" | |
26 #include "buffer.h" | |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
27 #include "charset.h" |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
28 |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
29 /* Make syntax table lookup grant data in gl_state. */ |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
30 #define SYNTAX_ENTRY_VIA_PROPERTY |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
31 |
163 | 32 #include "syntax.h" |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
33 #include "intervals.h" |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
34 |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
35 /* We use these constants in place for comment-style and |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
36 string-ender-char to distinguish comments/strings started by |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
37 comment_fence and string_fence codes. */ |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
38 |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
39 #define ST_COMMENT_STYLE (256 + 1) |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
40 #define ST_STRING_STYLE (256 + 2) |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
41 #include "category.h" |
163 | 42 |
16992
ff7346c31184
(scan_lists): Signal errors using scan-error.
Richard M. Stallman <rms@gnu.org>
parents:
16039
diff
changeset
|
43 Lisp_Object Qsyntax_table_p, Qsyntax_table, Qscan_error; |
163 | 44 |
45 int words_include_escapes; | |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
46 int parse_sexp_lookup_properties; |
163 | 47 |
27812
e2216823484d
(multibyte_syntax_as_symbol): New variable.
Kenichi Handa <handa@m17n.org>
parents:
27719
diff
changeset
|
48 /* Nonzero means `scan-sexps' treat all multibyte characters as symbol. */ |
e2216823484d
(multibyte_syntax_as_symbol): New variable.
Kenichi Handa <handa@m17n.org>
parents:
27719
diff
changeset
|
49 int multibyte_syntax_as_symbol; |
e2216823484d
(multibyte_syntax_as_symbol): New variable.
Kenichi Handa <handa@m17n.org>
parents:
27719
diff
changeset
|
50 |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
51 /* Used as a temporary in SYNTAX_ENTRY and other macros in syntax.h, |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
52 if not compiled with GCC. No need to mark it, since it is used |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
53 only very temporarily. */ |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
54 Lisp_Object syntax_temp; |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
55 |
28302
27ffe1e3b06d
(open_paren_in_column_0_is_defun_start): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
56 /* Non-zero means an open parenthesis in column 0 is always considered |
27ffe1e3b06d
(open_paren_in_column_0_is_defun_start): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
57 to be the start of a defun. Zero means an open parenthesis in |
27ffe1e3b06d
(open_paren_in_column_0_is_defun_start): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
58 column 0 has no special meaning. */ |
27ffe1e3b06d
(open_paren_in_column_0_is_defun_start): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
59 |
27ffe1e3b06d
(open_paren_in_column_0_is_defun_start): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
60 int open_paren_in_column_0_is_defun_start; |
27ffe1e3b06d
(open_paren_in_column_0_is_defun_start): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
61 |
1085
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
62 /* This is the internal form of the parse state used in parse-partial-sexp. */ |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
63 |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
64 struct lisp_parse_state |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
65 { |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
66 int depth; /* Depth at end of parsing. */ |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
67 int instring; /* -1 if not within string, else desired terminator. */ |
25445
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
68 int incomment; /* -1 if in unnestable comment else comment nesting */ |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
69 int comstyle; /* comment style a=0, or b=1, or ST_COMMENT_STYLE. */ |
1085
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
70 int quoted; /* Nonzero if just after an escape char at end of parsing */ |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
71 int thislevelstart; /* Char number of most recent start-of-expression at current level */ |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
72 int prevlevelstart; /* Char number of start of containing expression */ |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
73 int location; /* Char number at which parsing stopped. */ |
1085
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
74 int mindepth; /* Minimum depth seen while scanning. */ |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
75 int comstr_start; /* Position just after last comment/string starter. */ |
22394
5e1f0caf1873
(struct lisp_parse_state): New field, levelstarts.
Richard M. Stallman <rms@gnu.org>
parents:
22370
diff
changeset
|
76 Lisp_Object levelstarts; /* Char numbers of starts-of-expression |
5e1f0caf1873
(struct lisp_parse_state): New field, levelstarts.
Richard M. Stallman <rms@gnu.org>
parents:
22370
diff
changeset
|
77 of levels (starting from outermost). */ |
1085
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
78 }; |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
79 |
1167
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
80 /* These variables are a cache for finding the start of a defun. |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
81 find_start_pos is the place for which the defun start was found. |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
82 find_start_value is the defun start position found for it. |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
83 find_start_value_byte is the corresponding byte position. |
1167
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
84 find_start_buffer is the buffer it was found in. |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
85 find_start_begv is the BEGV value when it was found. |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
86 find_start_modiff is the value of MODIFF when it was found. */ |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
87 |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
88 static int find_start_pos; |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
89 static int find_start_value; |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
90 static int find_start_value_byte; |
1167
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
91 static struct buffer *find_start_buffer; |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
92 static int find_start_begv; |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
93 static int find_start_modiff; |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
94 |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
95 |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
96 static int find_defun_start P_ ((int, int)); |
25445
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
97 static int back_comment P_ ((int, int, int, int, int, int *, int *)); |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
98 static int char_quoted P_ ((int, int)); |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
99 static Lisp_Object skip_chars P_ ((int, int, Lisp_Object, Lisp_Object)); |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
100 static Lisp_Object scan_lists P_ ((int, int, int, int)); |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
101 static void scan_sexps_forward P_ ((struct lisp_parse_state *, |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
102 int, int, int, int, |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
103 int, Lisp_Object, int)); |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
104 |
1167
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
105 |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
106 struct gl_state_s gl_state; /* Global state of syntax parser. */ |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
107 |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
108 INTERVAL interval_of (); |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
109 #define INTERVALS_AT_ONCE 10 /* 1 + max-number of intervals |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
110 to scan to property-change. */ |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
111 |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
112 /* Update gl_state to an appropriate interval which contains CHARPOS. The |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
113 sign of COUNT give the relative position of CHARPOS wrt the previously |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
114 valid interval. If INIT, only [be]_property fields of gl_state are |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
115 valid at start, the rest is filled basing on OBJECT. |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
116 |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
117 `gl_state.*_i' are the intervals, and CHARPOS is further in the search |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
118 direction than the intervals - or in an interval. We update the |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
119 current syntax-table basing on the property of this interval, and |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
120 update the interval to start further than CHARPOS - or be |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
121 NULL_INTERVAL. We also update lim_property to be the next value of |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
122 charpos to call this subroutine again - or be before/after the |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
123 start/end of OBJECT. */ |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
124 |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
125 void |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
126 update_syntax_table (charpos, count, init, object) |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
127 int charpos, count, init; |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
128 Lisp_Object object; |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
129 { |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
130 Lisp_Object tmp_table; |
25771
21925339c7d2
(update_syntax_table, find_defun_start, back_comment,
Gerd Moellmann <gerd@gnu.org>
parents:
25663
diff
changeset
|
131 int cnt = 0, invalidate = 1; |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
132 INTERVAL i, oldi; |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
133 |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
134 if (init) |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
135 { |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
136 gl_state.start = gl_state.b_property; |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
137 gl_state.stop = gl_state.e_property; |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
138 gl_state.forward_i = interval_of (charpos, object); |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
139 i = gl_state.backward_i = gl_state.forward_i; |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
140 gl_state.left_ok = gl_state.right_ok = 1; |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
141 invalidate = 0; |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
142 if (NULL_INTERVAL_P (i)) |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
143 return; |
22370
1f0dc0251be3
(scan_lists): Properly skip the comment-fence character
Richard M. Stallman <rms@gnu.org>
parents:
22130
diff
changeset
|
144 /* interval_of updates only ->position of the return value, so |
21011
ceb05db73a63
(update_syntax_table): Properly update `position' field of used intervals.
Richard M. Stallman <rms@gnu.org>
parents:
20956
diff
changeset
|
145 update the parents manually to speed up update_interval. */ |
ceb05db73a63
(update_syntax_table): Properly update `position' field of used intervals.
Richard M. Stallman <rms@gnu.org>
parents:
20956
diff
changeset
|
146 while (!NULL_PARENT (i)) |
ceb05db73a63
(update_syntax_table): Properly update `position' field of used intervals.
Richard M. Stallman <rms@gnu.org>
parents:
20956
diff
changeset
|
147 { |
ceb05db73a63
(update_syntax_table): Properly update `position' field of used intervals.
Richard M. Stallman <rms@gnu.org>
parents:
20956
diff
changeset
|
148 if (AM_RIGHT_CHILD (i)) |
28269
fd13be8ae190
Changes towards better type safety regarding intervals, primarily
Ken Raeburn <raeburn@raeburn.org>
parents:
27812
diff
changeset
|
149 INTERVAL_PARENT (i)->position = i->position |
21011
ceb05db73a63
(update_syntax_table): Properly update `position' field of used intervals.
Richard M. Stallman <rms@gnu.org>
parents:
20956
diff
changeset
|
150 - LEFT_TOTAL_LENGTH (i) + TOTAL_LENGTH (i) /* right end */ |
28269
fd13be8ae190
Changes towards better type safety regarding intervals, primarily
Ken Raeburn <raeburn@raeburn.org>
parents:
27812
diff
changeset
|
151 - TOTAL_LENGTH (INTERVAL_PARENT (i)) |
fd13be8ae190
Changes towards better type safety regarding intervals, primarily
Ken Raeburn <raeburn@raeburn.org>
parents:
27812
diff
changeset
|
152 + LEFT_TOTAL_LENGTH (INTERVAL_PARENT (i)); |
21011
ceb05db73a63
(update_syntax_table): Properly update `position' field of used intervals.
Richard M. Stallman <rms@gnu.org>
parents:
20956
diff
changeset
|
153 else |
28269
fd13be8ae190
Changes towards better type safety regarding intervals, primarily
Ken Raeburn <raeburn@raeburn.org>
parents:
27812
diff
changeset
|
154 INTERVAL_PARENT (i)->position = i->position - LEFT_TOTAL_LENGTH (i) |
21011
ceb05db73a63
(update_syntax_table): Properly update `position' field of used intervals.
Richard M. Stallman <rms@gnu.org>
parents:
20956
diff
changeset
|
155 + TOTAL_LENGTH (i); |
28269
fd13be8ae190
Changes towards better type safety regarding intervals, primarily
Ken Raeburn <raeburn@raeburn.org>
parents:
27812
diff
changeset
|
156 i = INTERVAL_PARENT (i); |
21011
ceb05db73a63
(update_syntax_table): Properly update `position' field of used intervals.
Richard M. Stallman <rms@gnu.org>
parents:
20956
diff
changeset
|
157 } |
ceb05db73a63
(update_syntax_table): Properly update `position' field of used intervals.
Richard M. Stallman <rms@gnu.org>
parents:
20956
diff
changeset
|
158 i = gl_state.forward_i; |
20956
15d1b7bf1cd7
(update_syntax_table): Fix calculations using offset.
Karl Heuer <kwzh@gnu.org>
parents:
20905
diff
changeset
|
159 gl_state.b_property = i->position - 1 - gl_state.offset; |
15d1b7bf1cd7
(update_syntax_table): Fix calculations using offset.
Karl Heuer <kwzh@gnu.org>
parents:
20905
diff
changeset
|
160 gl_state.e_property = INTERVAL_LAST_POS (i) - gl_state.offset; |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
161 goto update; |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
162 } |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
163 oldi = i = count > 0 ? gl_state.forward_i : gl_state.backward_i; |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
164 |
37532
f14973be41f5
(update_syntax_table): Check that oldi has the same
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
34398
diff
changeset
|
165 /* We are guaranteed to be called with CHARPOS either in i, |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
166 or further off. */ |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
167 if (NULL_INTERVAL_P (i)) |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
168 error ("Error in syntax_table logic for to-the-end intervals"); |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
169 else if (charpos < i->position) /* Move left. */ |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
170 { |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
171 if (count > 0) |
22370
1f0dc0251be3
(scan_lists): Properly skip the comment-fence character
Richard M. Stallman <rms@gnu.org>
parents:
22130
diff
changeset
|
172 error ("Error in syntax_table logic for intervals <-"); |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
173 /* Update the interval. */ |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
174 i = update_interval (i, charpos); |
37532
f14973be41f5
(update_syntax_table): Check that oldi has the same
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
34398
diff
changeset
|
175 if (!gl_state.left_ok || oldi->position != INTERVAL_LAST_POS (i)) |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
176 { |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
177 invalidate = 0; |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
178 gl_state.right_ok = 1; /* Invalidate the other end. */ |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
179 gl_state.forward_i = i; |
20956
15d1b7bf1cd7
(update_syntax_table): Fix calculations using offset.
Karl Heuer <kwzh@gnu.org>
parents:
20905
diff
changeset
|
180 gl_state.e_property = INTERVAL_LAST_POS (i) - gl_state.offset; |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
181 } |
37532
f14973be41f5
(update_syntax_table): Check that oldi has the same
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
34398
diff
changeset
|
182 } |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
183 else if (charpos >= INTERVAL_LAST_POS (i)) /* Move right. */ |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
184 { |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
185 if (count < 0) |
22370
1f0dc0251be3
(scan_lists): Properly skip the comment-fence character
Richard M. Stallman <rms@gnu.org>
parents:
22130
diff
changeset
|
186 error ("Error in syntax_table logic for intervals ->"); |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
187 /* Update the interval. */ |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
188 i = update_interval (i, charpos); |
37532
f14973be41f5
(update_syntax_table): Check that oldi has the same
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
34398
diff
changeset
|
189 if (!gl_state.right_ok || i->position != INTERVAL_LAST_POS (oldi)) |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
190 { |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
191 invalidate = 0; |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
192 gl_state.left_ok = 1; /* Invalidate the other end. */ |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
193 gl_state.backward_i = i; |
20956
15d1b7bf1cd7
(update_syntax_table): Fix calculations using offset.
Karl Heuer <kwzh@gnu.org>
parents:
20905
diff
changeset
|
194 gl_state.b_property = i->position - 1 - gl_state.offset; |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
195 } |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
196 } |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
197 else if (count > 0 ? gl_state.right_ok : gl_state.left_ok) |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
198 { |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
199 /* We do not need to recalculate tmp_table. */ |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
200 tmp_table = gl_state.old_prop; |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
201 } |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
202 |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
203 update: |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
204 tmp_table = textget (i->plist, Qsyntax_table); |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
205 |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
206 if (invalidate) |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
207 invalidate = !EQ (tmp_table, gl_state.old_prop); /* Need to invalidate? */ |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
208 |
37532
f14973be41f5
(update_syntax_table): Check that oldi has the same
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
34398
diff
changeset
|
209 if (invalidate) /* Did not get to adjacent interval. */ |
f14973be41f5
(update_syntax_table): Check that oldi has the same
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
34398
diff
changeset
|
210 { /* with the same table => */ |
f14973be41f5
(update_syntax_table): Check that oldi has the same
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
34398
diff
changeset
|
211 /* invalidate the old range. */ |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
212 if (count > 0) |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
213 { |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
214 gl_state.backward_i = i; |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
215 gl_state.left_ok = 1; /* Invalidate the other end. */ |
20956
15d1b7bf1cd7
(update_syntax_table): Fix calculations using offset.
Karl Heuer <kwzh@gnu.org>
parents:
20905
diff
changeset
|
216 gl_state.b_property = i->position - 1 - gl_state.offset; |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
217 } |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
218 else |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
219 { |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
220 gl_state.forward_i = i; |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
221 gl_state.right_ok = 1; /* Invalidate the other end. */ |
20956
15d1b7bf1cd7
(update_syntax_table): Fix calculations using offset.
Karl Heuer <kwzh@gnu.org>
parents:
20905
diff
changeset
|
222 gl_state.e_property = INTERVAL_LAST_POS (i) - gl_state.offset; |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
223 } |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
224 } |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
225 |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
226 gl_state.current_syntax_table = tmp_table; |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
227 gl_state.old_prop = tmp_table; |
18613
614b916ff5bf
Fix bugs with inappropriate mixing of Lisp_Object with int.
Richard M. Stallman <rms@gnu.org>
parents:
18491
diff
changeset
|
228 if (EQ (Fsyntax_table_p (tmp_table), Qt)) |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
229 { |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
230 gl_state.use_global = 0; |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
231 } |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
232 else if (CONSP (tmp_table)) |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
233 { |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
234 gl_state.use_global = 1; |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
235 gl_state.global_code = tmp_table; |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
236 } |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
237 else |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
238 { |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
239 gl_state.use_global = 0; |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
240 gl_state.current_syntax_table = current_buffer->syntax_table; |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
241 } |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
242 |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
243 while (!NULL_INTERVAL_P (i)) |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
244 { |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
245 if (cnt && !EQ (tmp_table, textget (i->plist, Qsyntax_table))) |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
246 { |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
247 if (count > 0) |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
248 gl_state.right_ok = 0; |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
249 else |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
250 gl_state.left_ok = 0; |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
251 break; |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
252 } |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
253 else if (cnt == INTERVALS_AT_ONCE) |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
254 { |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
255 if (count > 0) |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
256 gl_state.right_ok = 1; |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
257 else |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
258 gl_state.left_ok = 1; |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
259 break; |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
260 } |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
261 cnt++; |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
262 i = count > 0 ? next_interval (i) : previous_interval (i); |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
263 } |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
264 if (NULL_INTERVAL_P (i)) |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
265 { /* This property goes to the end. */ |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
266 if (count > 0) |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
267 gl_state.e_property = gl_state.stop; |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
268 else |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
269 gl_state.b_property = gl_state.start; |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
270 } |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
271 else |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
272 { |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
273 if (count > 0) |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
274 { |
20956
15d1b7bf1cd7
(update_syntax_table): Fix calculations using offset.
Karl Heuer <kwzh@gnu.org>
parents:
20905
diff
changeset
|
275 gl_state.e_property = i->position - gl_state.offset; |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
276 gl_state.forward_i = i; |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
277 } |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
278 else |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
279 { |
20956
15d1b7bf1cd7
(update_syntax_table): Fix calculations using offset.
Karl Heuer <kwzh@gnu.org>
parents:
20905
diff
changeset
|
280 gl_state.b_property = i->position + LENGTH (i) - 1 - gl_state.offset; |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
281 gl_state.backward_i = i; |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
282 } |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
283 } |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
284 } |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
285 |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
286 /* Returns TRUE if char at CHARPOS is quoted. |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
287 Global syntax-table data should be set up already to be good at CHARPOS |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
288 or after. On return global syntax data is good for lookup at CHARPOS. */ |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
289 |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
290 static int |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
291 char_quoted (charpos, bytepos) |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
292 register int charpos, bytepos; |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
293 { |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
294 register enum syntaxcode code; |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
295 register int beg = BEGV; |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
296 register int quoted = 0; |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
297 int orig = charpos; |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
298 |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
299 DEC_BOTH (charpos, bytepos); |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
300 |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
301 while (bytepos >= beg) |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
302 { |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
303 UPDATE_SYNTAX_TABLE_BACKWARD (charpos); |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
304 code = SYNTAX (FETCH_CHAR (bytepos)); |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
305 if (! (code == Scharquote || code == Sescape)) |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
306 break; |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
307 |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
308 DEC_BOTH (charpos, bytepos); |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
309 quoted = !quoted; |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
310 } |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
311 |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
312 UPDATE_SYNTAX_TABLE (orig); |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
313 return quoted; |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
314 } |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
315 |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
316 /* Return the bytepos one character after BYTEPOS. |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
317 We assume that BYTEPOS is not at the end of the buffer. */ |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
318 |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
319 INLINE int |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
320 inc_bytepos (bytepos) |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
321 int bytepos; |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
322 { |
20905
e646a6ae42cd
(skip_chars): Use INC_POS instead of INC_BOTH.
Richard M. Stallman <rms@gnu.org>
parents:
20766
diff
changeset
|
323 if (NILP (current_buffer->enable_multibyte_characters)) |
e646a6ae42cd
(skip_chars): Use INC_POS instead of INC_BOTH.
Richard M. Stallman <rms@gnu.org>
parents:
20766
diff
changeset
|
324 return bytepos + 1; |
e646a6ae42cd
(skip_chars): Use INC_POS instead of INC_BOTH.
Richard M. Stallman <rms@gnu.org>
parents:
20766
diff
changeset
|
325 |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
326 INC_POS (bytepos); |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
327 return bytepos; |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
328 } |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
329 |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
330 /* Return the bytepos one character before BYTEPOS. |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
331 We assume that BYTEPOS is not at the start of the buffer. */ |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
332 |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
333 INLINE int |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
334 dec_bytepos (bytepos) |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
335 int bytepos; |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
336 { |
20905
e646a6ae42cd
(skip_chars): Use INC_POS instead of INC_BOTH.
Richard M. Stallman <rms@gnu.org>
parents:
20766
diff
changeset
|
337 if (NILP (current_buffer->enable_multibyte_characters)) |
e646a6ae42cd
(skip_chars): Use INC_POS instead of INC_BOTH.
Richard M. Stallman <rms@gnu.org>
parents:
20766
diff
changeset
|
338 return bytepos - 1; |
e646a6ae42cd
(skip_chars): Use INC_POS instead of INC_BOTH.
Richard M. Stallman <rms@gnu.org>
parents:
20766
diff
changeset
|
339 |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
340 DEC_POS (bytepos); |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
341 return bytepos; |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
342 } |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
343 |
39195 | 344 /* Return a defun-start position before before POS and not too far before. |
345 It should be the last one before POS, or nearly the last. | |
346 | |
347 When open_paren_in_column_0_is_defun_start is nonzero, | |
348 the beginning of every line is treated as a defun-start. | |
349 | |
350 We record the information about where the scan started | |
351 and what its result was, so that another call in the same area | |
352 can return the same value very quickly. | |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
353 |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
354 There is no promise at which position the global syntax data is |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
355 valid on return from the subroutine, so the caller should explicitly |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
356 update the global data. */ |
1167
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
357 |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
358 static int |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
359 find_defun_start (pos, pos_byte) |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
360 int pos, pos_byte; |
1167
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
361 { |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
362 int opoint = PT, opoint_byte = PT_BYTE; |
1167
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
363 |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
364 /* Use previous finding, if it's valid and applies to this inquiry. */ |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
365 if (current_buffer == find_start_buffer |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
366 /* Reuse the defun-start even if POS is a little farther on. |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
367 POS might be in the next defun, but that's ok. |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
368 Our value may not be the best possible, but will still be usable. */ |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
369 && pos <= find_start_pos + 1000 |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
370 && pos >= find_start_value |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
371 && BEGV == find_start_begv |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
372 && MODIFF == find_start_modiff) |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
373 return find_start_value; |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
374 |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
375 /* Back up to start of line. */ |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
376 scan_newline (pos, pos_byte, BEGV, BEGV_BYTE, -1, 1); |
1167
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
377 |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
378 /* We optimize syntax-table lookup for rare updates. Thus we accept |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
379 only those `^\s(' which are good in global _and_ text-property |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
380 syntax-tables. */ |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
381 gl_state.current_syntax_table = current_buffer->syntax_table; |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
382 gl_state.use_global = 0; |
29293
d01408f0820d
(find_defun_start): Move test for
Gerd Moellmann <gerd@gnu.org>
parents:
29101
diff
changeset
|
383 if (open_paren_in_column_0_is_defun_start) |
1167
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
384 { |
29293
d01408f0820d
(find_defun_start): Move test for
Gerd Moellmann <gerd@gnu.org>
parents:
29101
diff
changeset
|
385 while (PT > BEGV) |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
386 { |
29293
d01408f0820d
(find_defun_start): Move test for
Gerd Moellmann <gerd@gnu.org>
parents:
29101
diff
changeset
|
387 /* Open-paren at start of line means we may have found our |
d01408f0820d
(find_defun_start): Move test for
Gerd Moellmann <gerd@gnu.org>
parents:
29101
diff
changeset
|
388 defun-start. */ |
d01408f0820d
(find_defun_start): Move test for
Gerd Moellmann <gerd@gnu.org>
parents:
29101
diff
changeset
|
389 if (SYNTAX (FETCH_CHAR (PT_BYTE)) == Sopen) |
d01408f0820d
(find_defun_start): Move test for
Gerd Moellmann <gerd@gnu.org>
parents:
29101
diff
changeset
|
390 { |
d01408f0820d
(find_defun_start): Move test for
Gerd Moellmann <gerd@gnu.org>
parents:
29101
diff
changeset
|
391 SETUP_SYNTAX_TABLE (PT + 1, -1); /* Try again... */ |
d01408f0820d
(find_defun_start): Move test for
Gerd Moellmann <gerd@gnu.org>
parents:
29101
diff
changeset
|
392 if (SYNTAX (FETCH_CHAR (PT_BYTE)) == Sopen) |
d01408f0820d
(find_defun_start): Move test for
Gerd Moellmann <gerd@gnu.org>
parents:
29101
diff
changeset
|
393 break; |
d01408f0820d
(find_defun_start): Move test for
Gerd Moellmann <gerd@gnu.org>
parents:
29101
diff
changeset
|
394 /* Now fallback to the default value. */ |
d01408f0820d
(find_defun_start): Move test for
Gerd Moellmann <gerd@gnu.org>
parents:
29101
diff
changeset
|
395 gl_state.current_syntax_table = current_buffer->syntax_table; |
d01408f0820d
(find_defun_start): Move test for
Gerd Moellmann <gerd@gnu.org>
parents:
29101
diff
changeset
|
396 gl_state.use_global = 0; |
d01408f0820d
(find_defun_start): Move test for
Gerd Moellmann <gerd@gnu.org>
parents:
29101
diff
changeset
|
397 } |
d01408f0820d
(find_defun_start): Move test for
Gerd Moellmann <gerd@gnu.org>
parents:
29101
diff
changeset
|
398 /* Move to beg of previous line. */ |
d01408f0820d
(find_defun_start): Move test for
Gerd Moellmann <gerd@gnu.org>
parents:
29101
diff
changeset
|
399 scan_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, -2, 1); |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
400 } |
1167
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
401 } |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
402 |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
403 /* Record what we found, for the next try. */ |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
404 find_start_value = PT; |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
405 find_start_value_byte = PT_BYTE; |
1167
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
406 find_start_buffer = current_buffer; |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
407 find_start_modiff = MODIFF; |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
408 find_start_begv = BEGV; |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
409 find_start_pos = pos; |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
410 |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
411 TEMP_SET_PT_BOTH (opoint, opoint_byte); |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
412 |
1167
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
413 return find_start_value; |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
414 } |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
415 |
22370
1f0dc0251be3
(scan_lists): Properly skip the comment-fence character
Richard M. Stallman <rms@gnu.org>
parents:
22130
diff
changeset
|
416 /* Return the SYNTAX_COMEND_FIRST of the character before POS, POS_BYTE. */ |
1f0dc0251be3
(scan_lists): Properly skip the comment-fence character
Richard M. Stallman <rms@gnu.org>
parents:
22130
diff
changeset
|
417 |
1f0dc0251be3
(scan_lists): Properly skip the comment-fence character
Richard M. Stallman <rms@gnu.org>
parents:
22130
diff
changeset
|
418 static int |
1f0dc0251be3
(scan_lists): Properly skip the comment-fence character
Richard M. Stallman <rms@gnu.org>
parents:
22130
diff
changeset
|
419 prev_char_comend_first (pos, pos_byte) |
1f0dc0251be3
(scan_lists): Properly skip the comment-fence character
Richard M. Stallman <rms@gnu.org>
parents:
22130
diff
changeset
|
420 int pos, pos_byte; |
1f0dc0251be3
(scan_lists): Properly skip the comment-fence character
Richard M. Stallman <rms@gnu.org>
parents:
22130
diff
changeset
|
421 { |
1f0dc0251be3
(scan_lists): Properly skip the comment-fence character
Richard M. Stallman <rms@gnu.org>
parents:
22130
diff
changeset
|
422 int c, val; |
1f0dc0251be3
(scan_lists): Properly skip the comment-fence character
Richard M. Stallman <rms@gnu.org>
parents:
22130
diff
changeset
|
423 |
1f0dc0251be3
(scan_lists): Properly skip the comment-fence character
Richard M. Stallman <rms@gnu.org>
parents:
22130
diff
changeset
|
424 DEC_BOTH (pos, pos_byte); |
1f0dc0251be3
(scan_lists): Properly skip the comment-fence character
Richard M. Stallman <rms@gnu.org>
parents:
22130
diff
changeset
|
425 UPDATE_SYNTAX_TABLE_BACKWARD (pos); |
1f0dc0251be3
(scan_lists): Properly skip the comment-fence character
Richard M. Stallman <rms@gnu.org>
parents:
22130
diff
changeset
|
426 c = FETCH_CHAR (pos_byte); |
1f0dc0251be3
(scan_lists): Properly skip the comment-fence character
Richard M. Stallman <rms@gnu.org>
parents:
22130
diff
changeset
|
427 val = SYNTAX_COMEND_FIRST (c); |
1f0dc0251be3
(scan_lists): Properly skip the comment-fence character
Richard M. Stallman <rms@gnu.org>
parents:
22130
diff
changeset
|
428 UPDATE_SYNTAX_TABLE_FORWARD (pos + 1); |
1f0dc0251be3
(scan_lists): Properly skip the comment-fence character
Richard M. Stallman <rms@gnu.org>
parents:
22130
diff
changeset
|
429 return val; |
1f0dc0251be3
(scan_lists): Properly skip the comment-fence character
Richard M. Stallman <rms@gnu.org>
parents:
22130
diff
changeset
|
430 } |
1f0dc0251be3
(scan_lists): Properly skip the comment-fence character
Richard M. Stallman <rms@gnu.org>
parents:
22130
diff
changeset
|
431 |
1f0dc0251be3
(scan_lists): Properly skip the comment-fence character
Richard M. Stallman <rms@gnu.org>
parents:
22130
diff
changeset
|
432 /* Return the SYNTAX_COMSTART_FIRST of the character before POS, POS_BYTE. */ |
1f0dc0251be3
(scan_lists): Properly skip the comment-fence character
Richard M. Stallman <rms@gnu.org>
parents:
22130
diff
changeset
|
433 |
32087
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
434 /* static int |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
435 * prev_char_comstart_first (pos, pos_byte) |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
436 * int pos, pos_byte; |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
437 * { |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
438 * int c, val; |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
439 * |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
440 * DEC_BOTH (pos, pos_byte); |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
441 * UPDATE_SYNTAX_TABLE_BACKWARD (pos); |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
442 * c = FETCH_CHAR (pos_byte); |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
443 * val = SYNTAX_COMSTART_FIRST (c); |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
444 * UPDATE_SYNTAX_TABLE_FORWARD (pos + 1); |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
445 * return val; |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
446 * } */ |
22370
1f0dc0251be3
(scan_lists): Properly skip the comment-fence character
Richard M. Stallman <rms@gnu.org>
parents:
22130
diff
changeset
|
447 |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
448 /* Checks whether charpos FROM is at the end of a comment. |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
449 FROM_BYTE is the bytepos corresponding to FROM. |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
450 Do not move back before STOP. |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
451 |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
452 Return a positive value if we find a comment ending at FROM/FROM_BYTE; |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
453 return -1 otherwise. |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
454 |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
455 If successful, store the charpos of the comment's beginning |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
456 into *CHARPOS_PTR, and the bytepos into *BYTEPOS_PTR. |
20330
f76b9c0ebc4b
(back_comment): Handle 2-char comment starts
Karl Heuer <kwzh@gnu.org>
parents:
20292
diff
changeset
|
457 |
f76b9c0ebc4b
(back_comment): Handle 2-char comment starts
Karl Heuer <kwzh@gnu.org>
parents:
20292
diff
changeset
|
458 Global syntax data remains valid for backward search starting at |
f76b9c0ebc4b
(back_comment): Handle 2-char comment starts
Karl Heuer <kwzh@gnu.org>
parents:
20292
diff
changeset
|
459 the returned value (or at FROM, if the search was not successful). */ |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
460 |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
461 static int |
25445
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
462 back_comment (from, from_byte, stop, comnested, comstyle, charpos_ptr, bytepos_ptr) |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
463 int from, from_byte, stop; |
25445
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
464 int comnested, comstyle; |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
465 int *charpos_ptr, *bytepos_ptr; |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
466 { |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
467 /* Look back, counting the parity of string-quotes, |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
468 and recording the comment-starters seen. |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
469 When we reach a safe place, assume that's not in a string; |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
470 then step the main scan to the earliest comment-starter seen |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
471 an even number of string quotes away from the safe place. |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
472 |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
473 OFROM[I] is position of the earliest comment-starter seen |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
474 which is I+2X quotes from the comment-end. |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
475 PARITY is current parity of quotes from the comment end. */ |
29835
5dec8ee96c0c
(back_comment): Simplify string-parity counting (with
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29823
diff
changeset
|
476 int string_style = -1; /* Presumed outside of any string. */ |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
477 int string_lossage = 0; |
31209
00943ea58fd1
(back_comment): Detect cases where a comment-starter is
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30626
diff
changeset
|
478 /* Not a real lossage: indicates that we have passed a matching comment |
00943ea58fd1
(back_comment): Detect cases where a comment-starter is
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30626
diff
changeset
|
479 starter plus an non-matching comment-ender, meaning that any matching |
00943ea58fd1
(back_comment): Detect cases where a comment-starter is
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30626
diff
changeset
|
480 comment-starter we might see later could be a false positive (hidden |
00943ea58fd1
(back_comment): Detect cases where a comment-starter is
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30626
diff
changeset
|
481 inside another comment). |
00943ea58fd1
(back_comment): Detect cases where a comment-starter is
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30626
diff
changeset
|
482 Test case: { a (* b } c (* d *) */ |
00943ea58fd1
(back_comment): Detect cases where a comment-starter is
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30626
diff
changeset
|
483 int comment_lossage = 0; |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
484 int comment_end = from; |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
485 int comment_end_byte = from_byte; |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
486 int comstart_pos = 0; |
20766
92c662c4ab0e
(back_comment): Move the find_defun_start call
Richard M. Stallman <rms@gnu.org>
parents:
20704
diff
changeset
|
487 int comstart_byte; |
92c662c4ab0e
(back_comment): Move the find_defun_start call
Richard M. Stallman <rms@gnu.org>
parents:
20704
diff
changeset
|
488 /* Place where the containing defun starts, |
92c662c4ab0e
(back_comment): Move the find_defun_start call
Richard M. Stallman <rms@gnu.org>
parents:
20704
diff
changeset
|
489 or 0 if we didn't come across it yet. */ |
92c662c4ab0e
(back_comment): Move the find_defun_start call
Richard M. Stallman <rms@gnu.org>
parents:
20704
diff
changeset
|
490 int defun_start = 0; |
92c662c4ab0e
(back_comment): Move the find_defun_start call
Richard M. Stallman <rms@gnu.org>
parents:
20704
diff
changeset
|
491 int defun_start_byte = 0; |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
492 register enum syntaxcode code; |
25445
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
493 int nesting = 1; /* current comment nesting */ |
18079
5fbb5aef5649
(back_comment): Detect 2-char comment starts properly.
Richard M. Stallman <rms@gnu.org>
parents:
17786
diff
changeset
|
494 int c; |
32087
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
495 int syntax = 0; |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
496 |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
497 /* FIXME: A }} comment-ender style leads to incorrect behavior |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
498 in the case of {{ c }}} because we ignore the last two chars which are |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
499 assumed to be comment-enders although they aren't. */ |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
500 |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
501 /* At beginning of range to scan, we're outside of strings; |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
502 that determines quote parity to the comment-end. */ |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
503 while (from != stop) |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
504 { |
32087
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
505 int temp_byte, prev_syntax; |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
506 int com2start, com2end; |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
507 |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
508 /* Move back and examine a character. */ |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
509 DEC_BOTH (from, from_byte); |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
510 UPDATE_SYNTAX_TABLE_BACKWARD (from); |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
511 |
32087
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
512 prev_syntax = syntax; |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
513 c = FETCH_CHAR (from_byte); |
32087
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
514 syntax = SYNTAX_WITH_FLAGS (c); |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
515 code = SYNTAX (c); |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
516 |
32087
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
517 /* Check for 2-char comment markers. */ |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
518 com2start = (SYNTAX_FLAGS_COMSTART_FIRST (syntax) |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
519 && SYNTAX_FLAGS_COMSTART_SECOND (prev_syntax) |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
520 && comstyle == SYNTAX_FLAGS_COMMENT_STYLE (prev_syntax) |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
521 && (SYNTAX_FLAGS_COMMENT_NESTED (prev_syntax) |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
522 || SYNTAX_FLAGS_COMMENT_NESTED (syntax)) == comnested); |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
523 com2end = (SYNTAX_FLAGS_COMEND_FIRST (syntax) |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
524 && SYNTAX_FLAGS_COMEND_SECOND (prev_syntax)); |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
525 |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
526 /* Nasty cases with overlapping 2-char comment markers: |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
527 - snmp-mode: -- c -- foo -- c -- |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
528 --- c -- |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
529 ------ c -- |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
530 - c-mode: *||* |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
531 |* *|* *| |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
532 |*| |* |*| |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
533 /// */ |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
534 |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
535 /* If a 2-char comment sequence partly overlaps with another, |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
536 we don't try to be clever. */ |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
537 if (from > stop && (com2end || com2start)) |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
538 { |
32087
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
539 int next = from, next_byte = from_byte, next_c, next_syntax; |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
540 DEC_BOTH (next, next_byte); |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
541 UPDATE_SYNTAX_TABLE_BACKWARD (next); |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
542 next_c = FETCH_CHAR (next_byte); |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
543 next_syntax = SYNTAX_WITH_FLAGS (next_c); |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
544 if (((com2start || comnested) |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
545 && SYNTAX_FLAGS_COMEND_SECOND (syntax) |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
546 && SYNTAX_FLAGS_COMEND_FIRST (next_syntax)) |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
547 || ((com2end || comnested) |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
548 && SYNTAX_FLAGS_COMSTART_SECOND (syntax) |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
549 && comstyle == SYNTAX_FLAGS_COMMENT_STYLE (syntax) |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
550 && SYNTAX_FLAGS_COMSTART_FIRST (next_syntax))) |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
551 goto lossage; |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
552 /* UPDATE_SYNTAX_TABLE_FORWARD (next + 1); */ |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
553 } |
32087
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
554 |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
555 if (com2start && comstart_pos == 0) |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
556 /* We're looking at a comment starter. But it might be a comment |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
557 ender as well (see snmp-mode). The first time we see one, we |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
558 need to consider it as a comment starter, |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
559 and the subsequent times as a comment ender. */ |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
560 com2end = 0; |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
561 |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
562 /* Turn a 2-char comment sequences into the appropriate syntax. */ |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
563 if (com2end) |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
564 code = Sendcomment; |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
565 else if (com2start) |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
566 code = Scomment; |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
567 /* Ignore comment starters of a different style. */ |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
568 else if (code == Scomment |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
569 && (comstyle != SYNTAX_FLAGS_COMMENT_STYLE (syntax) |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
570 || SYNTAX_FLAGS_COMMENT_NESTED (syntax) != comnested)) |
27698
9c61956399b2
(back_comment): Make sure we only consider comment-starters
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
27080
diff
changeset
|
571 continue; |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
572 |
20674
fa7d4c0ee36c
(skip_chars): Fix test for end of string, looking for `-'.
Karl Heuer <kwzh@gnu.org>
parents:
20626
diff
changeset
|
573 /* Ignore escaped characters, except comment-enders. */ |
fa7d4c0ee36c
(skip_chars): Fix test for end of string, looking for `-'.
Karl Heuer <kwzh@gnu.org>
parents:
20626
diff
changeset
|
574 if (code != Sendcomment && char_quoted (from, from_byte)) |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
575 continue; |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
576 |
29835
5dec8ee96c0c
(back_comment): Simplify string-parity counting (with
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29823
diff
changeset
|
577 switch (code) |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
578 { |
29835
5dec8ee96c0c
(back_comment): Simplify string-parity counting (with
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29823
diff
changeset
|
579 case Sstring_fence: |
5dec8ee96c0c
(back_comment): Simplify string-parity counting (with
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29823
diff
changeset
|
580 case Scomment_fence: |
5dec8ee96c0c
(back_comment): Simplify string-parity counting (with
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29823
diff
changeset
|
581 c = (code == Sstring_fence ? ST_STRING_STYLE : ST_COMMENT_STYLE); |
5dec8ee96c0c
(back_comment): Simplify string-parity counting (with
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29823
diff
changeset
|
582 case Sstring: |
5dec8ee96c0c
(back_comment): Simplify string-parity counting (with
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29823
diff
changeset
|
583 /* Track parity of quotes. */ |
5dec8ee96c0c
(back_comment): Simplify string-parity counting (with
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29823
diff
changeset
|
584 if (string_style == -1) |
5dec8ee96c0c
(back_comment): Simplify string-parity counting (with
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29823
diff
changeset
|
585 /* Entering a string. */ |
5dec8ee96c0c
(back_comment): Simplify string-parity counting (with
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29823
diff
changeset
|
586 string_style = c; |
5dec8ee96c0c
(back_comment): Simplify string-parity counting (with
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29823
diff
changeset
|
587 else if (string_style == c) |
5dec8ee96c0c
(back_comment): Simplify string-parity counting (with
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29823
diff
changeset
|
588 /* Leaving the string. */ |
5dec8ee96c0c
(back_comment): Simplify string-parity counting (with
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29823
diff
changeset
|
589 string_style = -1; |
5dec8ee96c0c
(back_comment): Simplify string-parity counting (with
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29823
diff
changeset
|
590 else |
5dec8ee96c0c
(back_comment): Simplify string-parity counting (with
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29823
diff
changeset
|
591 /* If we have two kinds of string delimiters. |
5dec8ee96c0c
(back_comment): Simplify string-parity counting (with
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29823
diff
changeset
|
592 There's no way to grok this scanning backwards. */ |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
593 string_lossage = 1; |
29835
5dec8ee96c0c
(back_comment): Simplify string-parity counting (with
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29823
diff
changeset
|
594 break; |
5dec8ee96c0c
(back_comment): Simplify string-parity counting (with
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29823
diff
changeset
|
595 |
5dec8ee96c0c
(back_comment): Simplify string-parity counting (with
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29823
diff
changeset
|
596 case Scomment: |
5dec8ee96c0c
(back_comment): Simplify string-parity counting (with
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29823
diff
changeset
|
597 /* We've already checked that it is the relevant comstyle. */ |
31209
00943ea58fd1
(back_comment): Detect cases where a comment-starter is
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30626
diff
changeset
|
598 if (string_style != -1 || comment_lossage || string_lossage) |
29835
5dec8ee96c0c
(back_comment): Simplify string-parity counting (with
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29823
diff
changeset
|
599 /* There are odd string quotes involved, so let's be careful. |
5dec8ee96c0c
(back_comment): Simplify string-parity counting (with
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29823
diff
changeset
|
600 Test case in Pascal: " { " a { " } */ |
5dec8ee96c0c
(back_comment): Simplify string-parity counting (with
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29823
diff
changeset
|
601 goto lossage; |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
602 |
31209
00943ea58fd1
(back_comment): Detect cases where a comment-starter is
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30626
diff
changeset
|
603 if (!comnested) |
00943ea58fd1
(back_comment): Detect cases where a comment-starter is
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30626
diff
changeset
|
604 { |
00943ea58fd1
(back_comment): Detect cases where a comment-starter is
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30626
diff
changeset
|
605 /* Record best comment-starter so far. */ |
00943ea58fd1
(back_comment): Detect cases where a comment-starter is
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30626
diff
changeset
|
606 comstart_pos = from; |
00943ea58fd1
(back_comment): Detect cases where a comment-starter is
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30626
diff
changeset
|
607 comstart_byte = from_byte; |
00943ea58fd1
(back_comment): Detect cases where a comment-starter is
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30626
diff
changeset
|
608 } |
00943ea58fd1
(back_comment): Detect cases where a comment-starter is
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30626
diff
changeset
|
609 else if (--nesting <= 0) |
25445
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
610 /* nested comments have to be balanced, so we don't need to |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
611 keep looking for earlier ones. We use here the same (slightly |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
612 incorrect) reasoning as below: since it is followed by uniform |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
613 paired string quotes, this comment-start has to be outside of |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
614 strings, else the comment-end itself would be inside a string. */ |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
615 goto done; |
29835
5dec8ee96c0c
(back_comment): Simplify string-parity counting (with
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29823
diff
changeset
|
616 break; |
5dec8ee96c0c
(back_comment): Simplify string-parity counting (with
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29823
diff
changeset
|
617 |
30156
f59021679260
(back_comment): Use one switch rather than a few `if's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29835
diff
changeset
|
618 case Sendcomment: |
32087
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
619 if (SYNTAX_FLAGS_COMMENT_STYLE (syntax) == comstyle |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
620 && (SYNTAX_FLAGS_COMMENT_NESTED (prev_syntax) |
83ecc6bc4bc2
(prev_char_comstart_first): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32086
diff
changeset
|
621 || SYNTAX_FLAGS_COMMENT_NESTED (syntax)) == comnested) |
30156
f59021679260
(back_comment): Use one switch rather than a few `if's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29835
diff
changeset
|
622 /* This is the same style of comment ender as ours. */ |
f59021679260
(back_comment): Use one switch rather than a few `if's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29835
diff
changeset
|
623 { |
f59021679260
(back_comment): Use one switch rather than a few `if's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29835
diff
changeset
|
624 if (comnested) |
f59021679260
(back_comment): Use one switch rather than a few `if's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29835
diff
changeset
|
625 nesting++; |
f59021679260
(back_comment): Use one switch rather than a few `if's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29835
diff
changeset
|
626 else |
f59021679260
(back_comment): Use one switch rather than a few `if's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29835
diff
changeset
|
627 /* Anything before that can't count because it would match |
f59021679260
(back_comment): Use one switch rather than a few `if's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29835
diff
changeset
|
628 this comment-ender rather than ours. */ |
f59021679260
(back_comment): Use one switch rather than a few `if's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29835
diff
changeset
|
629 from = stop; /* Break out of the loop. */ |
f59021679260
(back_comment): Use one switch rather than a few `if's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29835
diff
changeset
|
630 } |
31209
00943ea58fd1
(back_comment): Detect cases where a comment-starter is
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30626
diff
changeset
|
631 else if (comstart_pos != 0 || c != '\n') |
00943ea58fd1
(back_comment): Detect cases where a comment-starter is
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30626
diff
changeset
|
632 /* We're mixing comment styles here, so we'd better be careful. |
00943ea58fd1
(back_comment): Detect cases where a comment-starter is
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30626
diff
changeset
|
633 The (comstart_pos != 0 || c != '\n') check is not quite correct |
00943ea58fd1
(back_comment): Detect cases where a comment-starter is
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30626
diff
changeset
|
634 (we should just always set comment_lossage), but removing it |
00943ea58fd1
(back_comment): Detect cases where a comment-starter is
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30626
diff
changeset
|
635 would imply that any multiline comment in C would go through |
00943ea58fd1
(back_comment): Detect cases where a comment-starter is
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30626
diff
changeset
|
636 lossage, which seems overkill. |
00943ea58fd1
(back_comment): Detect cases where a comment-starter is
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30626
diff
changeset
|
637 The failure should only happen in the rare cases such as |
00943ea58fd1
(back_comment): Detect cases where a comment-starter is
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30626
diff
changeset
|
638 { (* } *) */ |
00943ea58fd1
(back_comment): Detect cases where a comment-starter is
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30626
diff
changeset
|
639 comment_lossage = 1; |
30156
f59021679260
(back_comment): Use one switch rather than a few `if's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29835
diff
changeset
|
640 break; |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
641 |
30156
f59021679260
(back_comment): Use one switch rather than a few `if's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29835
diff
changeset
|
642 case Sopen: |
f59021679260
(back_comment): Use one switch rather than a few `if's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29835
diff
changeset
|
643 /* Assume a defun-start point is outside of strings. */ |
f59021679260
(back_comment): Use one switch rather than a few `if's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29835
diff
changeset
|
644 if (open_paren_in_column_0_is_defun_start |
f59021679260
(back_comment): Use one switch rather than a few `if's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29835
diff
changeset
|
645 && (from == stop |
f59021679260
(back_comment): Use one switch rather than a few `if's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29835
diff
changeset
|
646 || (temp_byte = dec_bytepos (from_byte), |
f59021679260
(back_comment): Use one switch rather than a few `if's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29835
diff
changeset
|
647 FETCH_CHAR (temp_byte) == '\n'))) |
f59021679260
(back_comment): Use one switch rather than a few `if's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29835
diff
changeset
|
648 { |
f59021679260
(back_comment): Use one switch rather than a few `if's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29835
diff
changeset
|
649 defun_start = from; |
f59021679260
(back_comment): Use one switch rather than a few `if's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29835
diff
changeset
|
650 defun_start_byte = from_byte; |
f59021679260
(back_comment): Use one switch rather than a few `if's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29835
diff
changeset
|
651 from = stop; /* Break out of the loop. */ |
f59021679260
(back_comment): Use one switch rather than a few `if's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29835
diff
changeset
|
652 } |
f59021679260
(back_comment): Use one switch rather than a few `if's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29835
diff
changeset
|
653 break; |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
654 |
30156
f59021679260
(back_comment): Use one switch rather than a few `if's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29835
diff
changeset
|
655 default: |
31209
00943ea58fd1
(back_comment): Detect cases where a comment-starter is
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30626
diff
changeset
|
656 break; |
20766
92c662c4ab0e
(back_comment): Move the find_defun_start call
Richard M. Stallman <rms@gnu.org>
parents:
20704
diff
changeset
|
657 } |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
658 } |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
659 |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
660 if (comstart_pos == 0) |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
661 { |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
662 from = comment_end; |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
663 from_byte = comment_end_byte; |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
664 UPDATE_SYNTAX_TABLE_FORWARD (comment_end - 1); |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
665 } |
31209
00943ea58fd1
(back_comment): Detect cases where a comment-starter is
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30626
diff
changeset
|
666 /* If comstart_pos is set and we get here (ie. didn't jump to `lossage' |
00943ea58fd1
(back_comment): Detect cases where a comment-starter is
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30626
diff
changeset
|
667 or `done'), then we've found the beginning of the non-nested comment. */ |
00943ea58fd1
(back_comment): Detect cases where a comment-starter is
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30626
diff
changeset
|
668 else if (1) /* !comnested */ |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
669 { |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
670 from = comstart_pos; |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
671 from_byte = comstart_byte; |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
672 /* Globals are correct now. */ |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
673 } |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
674 else |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
675 { |
29835
5dec8ee96c0c
(back_comment): Simplify string-parity counting (with
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29823
diff
changeset
|
676 struct lisp_parse_state state; |
5dec8ee96c0c
(back_comment): Simplify string-parity counting (with
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29823
diff
changeset
|
677 lossage: |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
678 /* We had two kinds of string delimiters mixed up |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
679 together. Decode this going forwards. |
30156
f59021679260
(back_comment): Use one switch rather than a few `if's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29835
diff
changeset
|
680 Scan fwd from a known safe place (beginning-of-defun) |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
681 to the one in question; this records where we |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
682 last passed a comment starter. */ |
20766
92c662c4ab0e
(back_comment): Move the find_defun_start call
Richard M. Stallman <rms@gnu.org>
parents:
20704
diff
changeset
|
683 /* If we did not already find the defun start, find it now. */ |
92c662c4ab0e
(back_comment): Move the find_defun_start call
Richard M. Stallman <rms@gnu.org>
parents:
20704
diff
changeset
|
684 if (defun_start == 0) |
92c662c4ab0e
(back_comment): Move the find_defun_start call
Richard M. Stallman <rms@gnu.org>
parents:
20704
diff
changeset
|
685 { |
92c662c4ab0e
(back_comment): Move the find_defun_start call
Richard M. Stallman <rms@gnu.org>
parents:
20704
diff
changeset
|
686 defun_start = find_defun_start (comment_end, comment_end_byte); |
92c662c4ab0e
(back_comment): Move the find_defun_start call
Richard M. Stallman <rms@gnu.org>
parents:
20704
diff
changeset
|
687 defun_start_byte = find_start_value_byte; |
92c662c4ab0e
(back_comment): Move the find_defun_start call
Richard M. Stallman <rms@gnu.org>
parents:
20704
diff
changeset
|
688 } |
30156
f59021679260
(back_comment): Use one switch rather than a few `if's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29835
diff
changeset
|
689 do |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
690 { |
30156
f59021679260
(back_comment): Use one switch rather than a few `if's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29835
diff
changeset
|
691 scan_sexps_forward (&state, |
f59021679260
(back_comment): Use one switch rather than a few `if's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29835
diff
changeset
|
692 defun_start, defun_start_byte, |
f59021679260
(back_comment): Use one switch rather than a few `if's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29835
diff
changeset
|
693 comment_end, -10000, 0, Qnil, 0); |
f59021679260
(back_comment): Use one switch rather than a few `if's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29835
diff
changeset
|
694 defun_start = comment_end; |
f59021679260
(back_comment): Use one switch rather than a few `if's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29835
diff
changeset
|
695 if (state.incomment == (comnested ? 1 : -1) |
f59021679260
(back_comment): Use one switch rather than a few `if's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29835
diff
changeset
|
696 && state.comstyle == comstyle) |
f59021679260
(back_comment): Use one switch rather than a few `if's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29835
diff
changeset
|
697 from = state.comstr_start; |
f59021679260
(back_comment): Use one switch rather than a few `if's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29835
diff
changeset
|
698 else |
f59021679260
(back_comment): Use one switch rather than a few `if's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29835
diff
changeset
|
699 { |
f59021679260
(back_comment): Use one switch rather than a few `if's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29835
diff
changeset
|
700 from = comment_end; |
f59021679260
(back_comment): Use one switch rather than a few `if's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29835
diff
changeset
|
701 if (state.incomment) |
f59021679260
(back_comment): Use one switch rather than a few `if's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29835
diff
changeset
|
702 /* If comment_end is inside some other comment, maybe ours |
f59021679260
(back_comment): Use one switch rather than a few `if's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29835
diff
changeset
|
703 is nested, so we need to try again from within the |
f59021679260
(back_comment): Use one switch rather than a few `if's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29835
diff
changeset
|
704 surrounding comment. Example: { a (* " *) */ |
f59021679260
(back_comment): Use one switch rather than a few `if's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29835
diff
changeset
|
705 { |
f59021679260
(back_comment): Use one switch rather than a few `if's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29835
diff
changeset
|
706 /* FIXME: We should advance by one or two chars. */ |
f59021679260
(back_comment): Use one switch rather than a few `if's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29835
diff
changeset
|
707 defun_start = state.comstr_start + 2; |
f59021679260
(back_comment): Use one switch rather than a few `if's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29835
diff
changeset
|
708 defun_start_byte = CHAR_TO_BYTE (defun_start); |
f59021679260
(back_comment): Use one switch rather than a few `if's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29835
diff
changeset
|
709 } |
f59021679260
(back_comment): Use one switch rather than a few `if's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29835
diff
changeset
|
710 } |
f59021679260
(back_comment): Use one switch rather than a few `if's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29835
diff
changeset
|
711 } while (defun_start < comment_end); |
f59021679260
(back_comment): Use one switch rather than a few `if's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29835
diff
changeset
|
712 |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
713 from_byte = CHAR_TO_BYTE (from); |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
714 UPDATE_SYNTAX_TABLE_FORWARD (from - 1); |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
715 } |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
716 |
25445
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
717 done: |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
718 *charpos_ptr = from; |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
719 *bytepos_ptr = from_byte; |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
720 |
27698
9c61956399b2
(back_comment): Make sure we only consider comment-starters
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
27080
diff
changeset
|
721 return (from == comment_end) ? -1 : from; |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
722 } |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
723 |
163 | 724 DEFUN ("syntax-table-p", Fsyntax_table_p, Ssyntax_table_p, 1, 1, 0, |
14087
1709d9f11c66
(Fsyntax_table_p, Fchar_syntax, Fmatching_paren, Fmodify_syntax_entry):
Erik Naggum <erik@naggum.no>
parents:
13513
diff
changeset
|
725 "Return t if OBJECT is a syntax table.\n\ |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
726 Currently, any char-table counts as a syntax table.") |
14087
1709d9f11c66
(Fsyntax_table_p, Fchar_syntax, Fmatching_paren, Fmodify_syntax_entry):
Erik Naggum <erik@naggum.no>
parents:
13513
diff
changeset
|
727 (object) |
1709d9f11c66
(Fsyntax_table_p, Fchar_syntax, Fmatching_paren, Fmodify_syntax_entry):
Erik Naggum <erik@naggum.no>
parents:
13513
diff
changeset
|
728 Lisp_Object object; |
163 | 729 { |
14087
1709d9f11c66
(Fsyntax_table_p, Fchar_syntax, Fmatching_paren, Fmodify_syntax_entry):
Erik Naggum <erik@naggum.no>
parents:
13513
diff
changeset
|
730 if (CHAR_TABLE_P (object) |
18113
9f7fdb0f76f3
(Fsyntax_table_p, check_syntax_table): Use EQ.
Richard M. Stallman <rms@gnu.org>
parents:
18080
diff
changeset
|
731 && EQ (XCHAR_TABLE (object)->purpose, Qsyntax_table)) |
163 | 732 return Qt; |
733 return Qnil; | |
734 } | |
735 | |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
736 static void |
163 | 737 check_syntax_table (obj) |
738 Lisp_Object obj; | |
739 { | |
13513
907544cb2c7d
(check_syntax_table): Check the purpose slot.
Richard M. Stallman <rms@gnu.org>
parents:
13218
diff
changeset
|
740 if (!(CHAR_TABLE_P (obj) |
18113
9f7fdb0f76f3
(Fsyntax_table_p, check_syntax_table): Use EQ.
Richard M. Stallman <rms@gnu.org>
parents:
18080
diff
changeset
|
741 && EQ (XCHAR_TABLE (obj)->purpose, Qsyntax_table))) |
13513
907544cb2c7d
(check_syntax_table): Check the purpose slot.
Richard M. Stallman <rms@gnu.org>
parents:
13218
diff
changeset
|
742 wrong_type_argument (Qsyntax_table_p, obj); |
163 | 743 } |
744 | |
745 DEFUN ("syntax-table", Fsyntax_table, Ssyntax_table, 0, 0, 0, | |
746 "Return the current syntax table.\n\ | |
747 This is the one specified by the current buffer.") | |
748 () | |
749 { | |
750 return current_buffer->syntax_table; | |
751 } | |
752 | |
753 DEFUN ("standard-syntax-table", Fstandard_syntax_table, | |
754 Sstandard_syntax_table, 0, 0, 0, | |
755 "Return the standard syntax table.\n\ | |
756 This is the one used for new buffers.") | |
757 () | |
758 { | |
759 return Vstandard_syntax_table; | |
760 } | |
761 | |
762 DEFUN ("copy-syntax-table", Fcopy_syntax_table, Scopy_syntax_table, 0, 1, 0, | |
763 "Construct a new syntax table and return it.\n\ | |
764 It is a copy of the TABLE, which defaults to the standard syntax table.") | |
765 (table) | |
766 Lisp_Object table; | |
767 { | |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
768 Lisp_Object copy; |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
769 |
485 | 770 if (!NILP (table)) |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
771 check_syntax_table (table); |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
772 else |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
773 table = Vstandard_syntax_table; |
163 | 774 |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
775 copy = Fcopy_sequence (table); |
14661
46ba65e7976c
(Fcopy_syntax_table): Set default to nil.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
776 |
46ba65e7976c
(Fcopy_syntax_table): Set default to nil.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
777 /* Only the standard syntax table should have a default element. |
46ba65e7976c
(Fcopy_syntax_table): Set default to nil.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
778 Other syntax tables should inherit from parents instead. */ |
46ba65e7976c
(Fcopy_syntax_table): Set default to nil.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
779 XCHAR_TABLE (copy)->defalt = Qnil; |
46ba65e7976c
(Fcopy_syntax_table): Set default to nil.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
780 |
46ba65e7976c
(Fcopy_syntax_table): Set default to nil.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
781 /* Copied syntax tables should all have parents. |
46ba65e7976c
(Fcopy_syntax_table): Set default to nil.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
782 If we copied one with no parent, such as the standard syntax table, |
46ba65e7976c
(Fcopy_syntax_table): Set default to nil.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
783 use the standard syntax table as the copy's parent. */ |
46ba65e7976c
(Fcopy_syntax_table): Set default to nil.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
784 if (NILP (XCHAR_TABLE (copy)->parent)) |
46ba65e7976c
(Fcopy_syntax_table): Set default to nil.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
785 Fset_char_table_parent (copy, Vstandard_syntax_table); |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
786 return copy; |
163 | 787 } |
788 | |
789 DEFUN ("set-syntax-table", Fset_syntax_table, Sset_syntax_table, 1, 1, 0, | |
790 "Select a new syntax table for the current buffer.\n\ | |
791 One argument, a syntax table.") | |
792 (table) | |
793 Lisp_Object table; | |
794 { | |
28313
cdb964ab44c3
(Fset_syntax_table): Use new macros for per-buffer
Gerd Moellmann <gerd@gnu.org>
parents:
28302
diff
changeset
|
795 int idx; |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
796 check_syntax_table (table); |
163 | 797 current_buffer->syntax_table = table; |
798 /* Indicate that this buffer now has a specified syntax table. */ | |
28351 | 799 idx = PER_BUFFER_VAR_IDX (syntax_table); |
800 SET_PER_BUFFER_VALUE_P (current_buffer, idx, 1); | |
163 | 801 return table; |
802 } | |
803 | |
804 /* Convert a letter which signifies a syntax code | |
805 into the code it signifies. | |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
806 This is used by modify-syntax-entry, and other things. */ |
163 | 807 |
808 unsigned char syntax_spec_code[0400] = | |
809 { 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377, | |
810 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377, | |
811 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377, | |
812 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377, | |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
813 (char) Swhitespace, (char) Scomment_fence, (char) Sstring, 0377, |
163 | 814 (char) Smath, 0377, 0377, (char) Squote, |
815 (char) Sopen, (char) Sclose, 0377, 0377, | |
816 0377, (char) Swhitespace, (char) Spunct, (char) Scharquote, | |
817 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377, | |
818 0377, 0377, 0377, 0377, | |
819 (char) Scomment, 0377, (char) Sendcomment, 0377, | |
5442
8cbae747a768
(describe_syntax): Handle Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
5339
diff
changeset
|
820 (char) Sinherit, 0377, 0377, 0377, 0377, 0377, 0377, 0377, /* @, A ... */ |
163 | 821 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377, |
822 0377, 0377, 0377, 0377, 0377, 0377, 0377, (char) Sword, | |
823 0377, 0377, 0377, 0377, (char) Sescape, 0377, 0377, (char) Ssymbol, | |
824 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377, /* `, a, ... */ | |
825 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377, | |
826 0377, 0377, 0377, 0377, 0377, 0377, 0377, (char) Sword, | |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
827 0377, 0377, 0377, 0377, (char) Sstring_fence, 0377, 0377, 0377 |
163 | 828 }; |
829 | |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
830 /* Indexed by syntax code, give the letter that describes it. */ |
163 | 831 |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
832 char syntax_code_spec[16] = |
163 | 833 { |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
834 ' ', '.', 'w', '_', '(', ')', '\'', '\"', '$', '\\', '/', '<', '>', '@', |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
835 '!', '|' |
163 | 836 }; |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
837 |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
838 /* Indexed by syntax code, give the object (cons of syntax code and |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
839 nil) to be stored in syntax table. Since these objects can be |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
840 shared among syntax tables, we generate them in advance. By |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
841 sharing objects, the function `describe-syntax' can give a more |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
842 compact listing. */ |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
843 static Lisp_Object Vsyntax_code_object; |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
844 |
163 | 845 |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
846 /* Look up the value for CHARACTER in syntax table TABLE's parent |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
847 and its parents. SYNTAX_ENTRY calls this, when TABLE itself has nil |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
848 for CHARACTER. It's actually used only when not compiled with GCC. */ |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
849 |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
850 Lisp_Object |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
851 syntax_parent_lookup (table, character) |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
852 Lisp_Object table; |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
853 int character; |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
854 { |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
855 Lisp_Object value; |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
856 |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
857 while (1) |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
858 { |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
859 table = XCHAR_TABLE (table)->parent; |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
860 if (NILP (table)) |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
861 return Qnil; |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
862 |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
863 value = XCHAR_TABLE (table)->contents[character]; |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
864 if (!NILP (value)) |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
865 return value; |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
866 } |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
867 } |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
868 |
163 | 869 DEFUN ("char-syntax", Fchar_syntax, Schar_syntax, 1, 1, 0, |
14087
1709d9f11c66
(Fsyntax_table_p, Fchar_syntax, Fmatching_paren, Fmodify_syntax_entry):
Erik Naggum <erik@naggum.no>
parents:
13513
diff
changeset
|
870 "Return the syntax code of CHARACTER, described by a character.\n\ |
1709d9f11c66
(Fsyntax_table_p, Fchar_syntax, Fmatching_paren, Fmodify_syntax_entry):
Erik Naggum <erik@naggum.no>
parents:
13513
diff
changeset
|
871 For example, if CHARACTER is a word constituent,\n\ |
1709d9f11c66
(Fsyntax_table_p, Fchar_syntax, Fmatching_paren, Fmodify_syntax_entry):
Erik Naggum <erik@naggum.no>
parents:
13513
diff
changeset
|
872 the character `w' is returned.\n\ |
163 | 873 The characters that correspond to various syntax codes\n\ |
874 are listed in the documentation of `modify-syntax-entry'.") | |
14087
1709d9f11c66
(Fsyntax_table_p, Fchar_syntax, Fmatching_paren, Fmodify_syntax_entry):
Erik Naggum <erik@naggum.no>
parents:
13513
diff
changeset
|
875 (character) |
1709d9f11c66
(Fsyntax_table_p, Fchar_syntax, Fmatching_paren, Fmodify_syntax_entry):
Erik Naggum <erik@naggum.no>
parents:
13513
diff
changeset
|
876 Lisp_Object character; |
163 | 877 { |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
878 int char_int; |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
879 gl_state.current_syntax_table = current_buffer->syntax_table; |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
880 |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
881 gl_state.use_global = 0; |
14087
1709d9f11c66
(Fsyntax_table_p, Fchar_syntax, Fmatching_paren, Fmodify_syntax_entry):
Erik Naggum <erik@naggum.no>
parents:
13513
diff
changeset
|
882 CHECK_NUMBER (character, 0); |
1709d9f11c66
(Fsyntax_table_p, Fchar_syntax, Fmatching_paren, Fmodify_syntax_entry):
Erik Naggum <erik@naggum.no>
parents:
13513
diff
changeset
|
883 char_int = XINT (character); |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
884 return make_number (syntax_code_spec[(int) SYNTAX (char_int)]); |
7968
a6372621abd9
(Fmatching_paren): New function.
Richard M. Stallman <rms@gnu.org>
parents:
7924
diff
changeset
|
885 } |
a6372621abd9
(Fmatching_paren): New function.
Richard M. Stallman <rms@gnu.org>
parents:
7924
diff
changeset
|
886 |
a6372621abd9
(Fmatching_paren): New function.
Richard M. Stallman <rms@gnu.org>
parents:
7924
diff
changeset
|
887 DEFUN ("matching-paren", Fmatching_paren, Smatching_paren, 1, 1, 0, |
14087
1709d9f11c66
(Fsyntax_table_p, Fchar_syntax, Fmatching_paren, Fmodify_syntax_entry):
Erik Naggum <erik@naggum.no>
parents:
13513
diff
changeset
|
888 "Return the matching parenthesis of CHARACTER, or nil if none.") |
1709d9f11c66
(Fsyntax_table_p, Fchar_syntax, Fmatching_paren, Fmodify_syntax_entry):
Erik Naggum <erik@naggum.no>
parents:
13513
diff
changeset
|
889 (character) |
1709d9f11c66
(Fsyntax_table_p, Fchar_syntax, Fmatching_paren, Fmodify_syntax_entry):
Erik Naggum <erik@naggum.no>
parents:
13513
diff
changeset
|
890 Lisp_Object character; |
7968
a6372621abd9
(Fmatching_paren): New function.
Richard M. Stallman <rms@gnu.org>
parents:
7924
diff
changeset
|
891 { |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
892 int char_int, code; |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
893 gl_state.current_syntax_table = current_buffer->syntax_table; |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
894 gl_state.use_global = 0; |
14087
1709d9f11c66
(Fsyntax_table_p, Fchar_syntax, Fmatching_paren, Fmodify_syntax_entry):
Erik Naggum <erik@naggum.no>
parents:
13513
diff
changeset
|
895 CHECK_NUMBER (character, 0); |
1709d9f11c66
(Fsyntax_table_p, Fchar_syntax, Fmatching_paren, Fmodify_syntax_entry):
Erik Naggum <erik@naggum.no>
parents:
13513
diff
changeset
|
896 char_int = XINT (character); |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
897 code = SYNTAX (char_int); |
7975
49dc4ea976a0
(Fmatching_paren): Fix typo.
Richard M. Stallman <rms@gnu.org>
parents:
7968
diff
changeset
|
898 if (code == Sopen || code == Sclose) |
18613
614b916ff5bf
Fix bugs with inappropriate mixing of Lisp_Object with int.
Richard M. Stallman <rms@gnu.org>
parents:
18491
diff
changeset
|
899 return SYNTAX_MATCH (char_int); |
7968
a6372621abd9
(Fmatching_paren): New function.
Richard M. Stallman <rms@gnu.org>
parents:
7924
diff
changeset
|
900 return Qnil; |
163 | 901 } |
902 | |
32506
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
903 DEFUN ("string-to-syntax", Fstring_to_syntax, Sstring_to_syntax, 1, 1, 0, |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
904 "Convert a syntax specification STRING into syntax cell form.\n\ |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
905 STRING should be a string as it is allowed as argument of\n\ |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
906 `modify-syntax-entry'. Value is the equivalent cons cell\n\ |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
907 \(CODE . MATCHING-CHAR) that can be used as value of a `syntax-table'\n\ |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
908 text property.") |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
909 (string) |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
910 Lisp_Object string; |
163 | 911 { |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
912 register unsigned char *p; |
163 | 913 register enum syntaxcode code; |
9333
925795f1a594
(Fmodify_syntax_entry): Don't use XFASTINT as an lvalue.
Karl Heuer <kwzh@gnu.org>
parents:
9320
diff
changeset
|
914 int val; |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
915 Lisp_Object match; |
163 | 916 |
32506
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
917 CHECK_STRING (string, 0); |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
918 |
32506
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
919 p = XSTRING (string)->data; |
163 | 920 code = (enum syntaxcode) syntax_spec_code[*p++]; |
921 if (((int) code & 0377) == 0377) | |
18613
614b916ff5bf
Fix bugs with inappropriate mixing of Lisp_Object with int.
Richard M. Stallman <rms@gnu.org>
parents:
18491
diff
changeset
|
922 error ("invalid syntax description letter: %c", p[-1]); |
163 | 923 |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
924 if (code == Sinherit) |
32506
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
925 return Qnil; |
163 | 926 |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
927 if (*p) |
13513
907544cb2c7d
(check_syntax_table): Check the purpose slot.
Richard M. Stallman <rms@gnu.org>
parents:
13218
diff
changeset
|
928 { |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
929 int len; |
22547
1cf8123f4c67
(Fmodify_syntax_entry): Use macro STRING_BYTES to get
Kenichi Handa <handa@m17n.org>
parents:
22486
diff
changeset
|
930 int character = (STRING_CHAR_AND_LENGTH |
32506
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
931 (p, STRING_BYTES (XSTRING (string)) - 1, len)); |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
932 XSETINT (match, character); |
13513
907544cb2c7d
(check_syntax_table): Check the purpose slot.
Richard M. Stallman <rms@gnu.org>
parents:
13218
diff
changeset
|
933 if (XFASTINT (match) == ' ') |
907544cb2c7d
(check_syntax_table): Check the purpose slot.
Richard M. Stallman <rms@gnu.org>
parents:
13218
diff
changeset
|
934 match = Qnil; |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
935 p += len; |
13513
907544cb2c7d
(check_syntax_table): Check the purpose slot.
Richard M. Stallman <rms@gnu.org>
parents:
13218
diff
changeset
|
936 } |
907544cb2c7d
(check_syntax_table): Check the purpose slot.
Richard M. Stallman <rms@gnu.org>
parents:
13218
diff
changeset
|
937 else |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
938 match = Qnil; |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
939 |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
940 val = (int) code; |
163 | 941 while (*p) |
942 switch (*p++) | |
943 { | |
944 case '1': | |
9333
925795f1a594
(Fmodify_syntax_entry): Don't use XFASTINT as an lvalue.
Karl Heuer <kwzh@gnu.org>
parents:
9320
diff
changeset
|
945 val |= 1 << 16; |
163 | 946 break; |
947 | |
948 case '2': | |
9333
925795f1a594
(Fmodify_syntax_entry): Don't use XFASTINT as an lvalue.
Karl Heuer <kwzh@gnu.org>
parents:
9320
diff
changeset
|
949 val |= 1 << 17; |
163 | 950 break; |
951 | |
952 case '3': | |
9333
925795f1a594
(Fmodify_syntax_entry): Don't use XFASTINT as an lvalue.
Karl Heuer <kwzh@gnu.org>
parents:
9320
diff
changeset
|
953 val |= 1 << 18; |
163 | 954 break; |
955 | |
956 case '4': | |
9333
925795f1a594
(Fmodify_syntax_entry): Don't use XFASTINT as an lvalue.
Karl Heuer <kwzh@gnu.org>
parents:
9320
diff
changeset
|
957 val |= 1 << 19; |
163 | 958 break; |
959 | |
960 case 'p': | |
9333
925795f1a594
(Fmodify_syntax_entry): Don't use XFASTINT as an lvalue.
Karl Heuer <kwzh@gnu.org>
parents:
9320
diff
changeset
|
961 val |= 1 << 20; |
163 | 962 break; |
1085
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
963 |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
964 case 'b': |
9333
925795f1a594
(Fmodify_syntax_entry): Don't use XFASTINT as an lvalue.
Karl Heuer <kwzh@gnu.org>
parents:
9320
diff
changeset
|
965 val |= 1 << 21; |
1085
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
966 break; |
25445
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
967 |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
968 case 'n': |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
969 val |= 1 << 22; |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
970 break; |
163 | 971 } |
972 | |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
973 if (val < XVECTOR (Vsyntax_code_object)->size && NILP (match)) |
32506
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
974 return XVECTOR (Vsyntax_code_object)->contents[val]; |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
975 else |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
976 /* Since we can't use a shared object, let's make a new one. */ |
32506
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
977 return Fcons (make_number (val), match); |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
978 } |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
979 |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
980 /* This comment supplies the doc string for modify-syntax-entry, |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
981 for make-docfile to see. We cannot put this in the real DEFUN |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
982 due to limits in the Unix cpp. |
163 | 983 |
32506
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
984 DEFUN ("modify-syntax-entry", foo, bar, 2, 3, 0, |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
985 "Set syntax for character CHAR according to string S.\n\ |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
986 The syntax is changed only for table TABLE, which defaults to\n\ |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
987 the current buffer's syntax table.\n\ |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
988 The first character of S should be one of the following:\n\ |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
989 Space or - whitespace syntax. w word constituent.\n\ |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
990 _ symbol constituent. . punctuation.\n\ |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
991 ( open-parenthesis. ) close-parenthesis.\n\ |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
992 \" string quote. \\ escape.\n\ |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
993 $ paired delimiter. ' expression quote or prefix operator.\n\ |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
994 < comment starter. > comment ender.\n\ |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
995 / character-quote. @ inherit from `standard-syntax-table'.\n\ |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
996 | generic string fence. ! generic comment fence.\n\ |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
997 \n\ |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
998 Only single-character comment start and end sequences are represented thus.\n\ |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
999 Two-character sequences are represented as described below.\n\ |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
1000 The second character of S is the matching parenthesis,\n\ |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
1001 used only if the first character is `(' or `)'.\n\ |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
1002 Any additional characters are flags.\n\ |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
1003 Defined flags are the characters 1, 2, 3, 4, b, p, and n.\n\ |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
1004 1 means CHAR is the start of a two-char comment start sequence.\n\ |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
1005 2 means CHAR is the second character of such a sequence.\n\ |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
1006 3 means CHAR is the start of a two-char comment end sequence.\n\ |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
1007 4 means CHAR is the second character of such a sequence.\n\ |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
1008 \n\ |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
1009 There can be up to two orthogonal comment sequences. This is to support\n\ |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
1010 language modes such as C++. By default, all comment sequences are of style\n\ |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
1011 a, but you can set the comment sequence style to b (on the second character\n\ |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
1012 of a comment-start, or the first character of a comment-end sequence) using\n\ |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
1013 this flag:\n\ |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
1014 b means CHAR is part of comment sequence b.\n\ |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
1015 n means CHAR is part of a nestable comment sequence.\n\ |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
1016 \n\ |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
1017 p means CHAR is a prefix character for `backward-prefix-chars';\n\ |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
1018 such characters are treated as whitespace when they occur\n\ |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
1019 between expressions.") |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
1020 (char, s, table) |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
1021 */ |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
1022 |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
1023 DEFUN ("modify-syntax-entry", Fmodify_syntax_entry, Smodify_syntax_entry, 2, 3, |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
1024 /* I really don't know why this is interactive |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
1025 help-form should at least be made useful whilst reading the second arg |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
1026 */ |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
1027 "cSet syntax for character: \nsSet syntax for %s to: ", |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
1028 0 /* See immediately above */) |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
1029 (c, newentry, syntax_table) |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
1030 Lisp_Object c, newentry, syntax_table; |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
1031 { |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
1032 CHECK_NUMBER (c, 0); |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
1033 |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
1034 if (NILP (syntax_table)) |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
1035 syntax_table = current_buffer->syntax_table; |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
1036 else |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
1037 check_syntax_table (syntax_table); |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
1038 |
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
1039 SET_RAW_SYNTAX_ENTRY (syntax_table, XINT (c), Fstring_to_syntax (newentry)); |
163 | 1040 return Qnil; |
1041 } | |
1042 | |
1043 /* Dump syntax table to buffer in human-readable format */ | |
1044 | |
3720
408c7ee69be7
(scan_lists, Fforward_comment): Pass 0 as commentstop arg
Richard M. Stallman <rms@gnu.org>
parents:
3684
diff
changeset
|
1045 static void |
163 | 1046 describe_syntax (value) |
1047 Lisp_Object value; | |
1048 { | |
1049 register enum syntaxcode code; | |
29821
819dfcbd36c7
(describe_syntax): Recognize the `n'estable bit.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29757
diff
changeset
|
1050 char desc, start1, start2, end1, end2, prefix, comstyle, comnested; |
163 | 1051 char str[2]; |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
1052 Lisp_Object first, match_lisp; |
163 | 1053 |
1054 Findent_to (make_number (16), make_number (1)); | |
1055 | |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
1056 if (NILP (value)) |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
1057 { |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1058 insert_string ("default\n"); |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
1059 return; |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
1060 } |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
1061 |
17109
dfe4f98935c4
(describe_syntax): Handle the case that the argument
Kenichi Handa <handa@m17n.org>
parents:
17044
diff
changeset
|
1062 if (CHAR_TABLE_P (value)) |
dfe4f98935c4
(describe_syntax): Handle the case that the argument
Kenichi Handa <handa@m17n.org>
parents:
17044
diff
changeset
|
1063 { |
dfe4f98935c4
(describe_syntax): Handle the case that the argument
Kenichi Handa <handa@m17n.org>
parents:
17044
diff
changeset
|
1064 insert_string ("deeper char-table ...\n"); |
dfe4f98935c4
(describe_syntax): Handle the case that the argument
Kenichi Handa <handa@m17n.org>
parents:
17044
diff
changeset
|
1065 return; |
dfe4f98935c4
(describe_syntax): Handle the case that the argument
Kenichi Handa <handa@m17n.org>
parents:
17044
diff
changeset
|
1066 } |
dfe4f98935c4
(describe_syntax): Handle the case that the argument
Kenichi Handa <handa@m17n.org>
parents:
17044
diff
changeset
|
1067 |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
1068 if (!CONSP (value)) |
163 | 1069 { |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1070 insert_string ("invalid\n"); |
163 | 1071 return; |
1072 } | |
1073 | |
25663
a5eaace0fa01
Use XCAR and XCDR instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25659
diff
changeset
|
1074 first = XCAR (value); |
a5eaace0fa01
Use XCAR and XCDR instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25659
diff
changeset
|
1075 match_lisp = XCDR (value); |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
1076 |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
1077 if (!INTEGERP (first) || !(NILP (match_lisp) || INTEGERP (match_lisp))) |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
1078 { |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1079 insert_string ("invalid\n"); |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
1080 return; |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
1081 } |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
1082 |
18113
9f7fdb0f76f3
(Fsyntax_table_p, check_syntax_table): Use EQ.
Richard M. Stallman <rms@gnu.org>
parents:
18080
diff
changeset
|
1083 code = (enum syntaxcode) (XINT (first) & 0377); |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
1084 start1 = (XINT (first) >> 16) & 1; |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
1085 start2 = (XINT (first) >> 17) & 1; |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
1086 end1 = (XINT (first) >> 18) & 1; |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
1087 end2 = (XINT (first) >> 19) & 1; |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
1088 prefix = (XINT (first) >> 20) & 1; |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
1089 comstyle = (XINT (first) >> 21) & 1; |
29821
819dfcbd36c7
(describe_syntax): Recognize the `n'estable bit.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29757
diff
changeset
|
1090 comnested = (XINT (first) >> 22) & 1; |
163 | 1091 |
1092 if ((int) code < 0 || (int) code >= (int) Smax) | |
1093 { | |
1094 insert_string ("invalid"); | |
1095 return; | |
1096 } | |
1097 desc = syntax_code_spec[(int) code]; | |
1098 | |
1099 str[0] = desc, str[1] = 0; | |
1100 insert (str, 1); | |
1101 | |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1102 if (NILP (match_lisp)) |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1103 insert (" ", 1); |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1104 else |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1105 insert_char (XINT (match_lisp)); |
163 | 1106 |
1107 if (start1) | |
1108 insert ("1", 1); | |
1109 if (start2) | |
1110 insert ("2", 1); | |
1111 | |
1112 if (end1) | |
1113 insert ("3", 1); | |
1114 if (end2) | |
1115 insert ("4", 1); | |
1116 | |
1117 if (prefix) | |
1118 insert ("p", 1); | |
1085
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1119 if (comstyle) |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1120 insert ("b", 1); |
29821
819dfcbd36c7
(describe_syntax): Recognize the `n'estable bit.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29757
diff
changeset
|
1121 if (comnested) |
819dfcbd36c7
(describe_syntax): Recognize the `n'estable bit.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29757
diff
changeset
|
1122 insert ("n", 1); |
163 | 1123 |
1124 insert_string ("\twhich means: "); | |
1125 | |
10457
2ab3bd0288a9
Change all occurences of SWITCH_ENUM_BUG to use SWITCH_ENUM_CAST instead.
Karl Heuer <kwzh@gnu.org>
parents:
9863
diff
changeset
|
1126 switch (SWITCH_ENUM_CAST (code)) |
163 | 1127 { |
1128 case Swhitespace: | |
1129 insert_string ("whitespace"); break; | |
1130 case Spunct: | |
1131 insert_string ("punctuation"); break; | |
1132 case Sword: | |
1133 insert_string ("word"); break; | |
1134 case Ssymbol: | |
1135 insert_string ("symbol"); break; | |
1136 case Sopen: | |
1137 insert_string ("open"); break; | |
1138 case Sclose: | |
1139 insert_string ("close"); break; | |
1140 case Squote: | |
32508
d371f8c371bd
(describe_syntax): Add code for comment and string fences.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32506
diff
changeset
|
1141 insert_string ("prefix"); break; |
163 | 1142 case Sstring: |
1143 insert_string ("string"); break; | |
1144 case Smath: | |
1145 insert_string ("math"); break; | |
1146 case Sescape: | |
1147 insert_string ("escape"); break; | |
1148 case Scharquote: | |
1149 insert_string ("charquote"); break; | |
1150 case Scomment: | |
1151 insert_string ("comment"); break; | |
1152 case Sendcomment: | |
1153 insert_string ("endcomment"); break; | |
32508
d371f8c371bd
(describe_syntax): Add code for comment and string fences.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32506
diff
changeset
|
1154 case Sinherit: |
d371f8c371bd
(describe_syntax): Add code for comment and string fences.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32506
diff
changeset
|
1155 insert_string ("inherit"); break; |
d371f8c371bd
(describe_syntax): Add code for comment and string fences.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32506
diff
changeset
|
1156 case Scomment_fence: |
d371f8c371bd
(describe_syntax): Add code for comment and string fences.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32506
diff
changeset
|
1157 insert_string ("comment fence"); break; |
d371f8c371bd
(describe_syntax): Add code for comment and string fences.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32506
diff
changeset
|
1158 case Sstring_fence: |
d371f8c371bd
(describe_syntax): Add code for comment and string fences.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32506
diff
changeset
|
1159 insert_string ("string fence"); break; |
163 | 1160 default: |
1161 insert_string ("invalid"); | |
1162 return; | |
1163 } | |
1164 | |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
1165 if (!NILP (match_lisp)) |
163 | 1166 { |
1167 insert_string (", matches "); | |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
1168 insert_char (XINT (match_lisp)); |
163 | 1169 } |
1170 | |
1171 if (start1) | |
1172 insert_string (",\n\t is the first character of a comment-start sequence"); | |
1173 if (start2) | |
1174 insert_string (",\n\t is the second character of a comment-start sequence"); | |
1175 | |
1176 if (end1) | |
1177 insert_string (",\n\t is the first character of a comment-end sequence"); | |
1178 if (end2) | |
1179 insert_string (",\n\t is the second character of a comment-end sequence"); | |
1085
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1180 if (comstyle) |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1181 insert_string (" (comment style b)"); |
29821
819dfcbd36c7
(describe_syntax): Recognize the `n'estable bit.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29757
diff
changeset
|
1182 if (comnested) |
819dfcbd36c7
(describe_syntax): Recognize the `n'estable bit.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29757
diff
changeset
|
1183 insert_string (" (nestable)"); |
1085
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1184 |
163 | 1185 if (prefix) |
1186 insert_string (",\n\t is a prefix character for `backward-prefix-chars'"); | |
1187 | |
1188 insert_string ("\n"); | |
1189 } | |
1190 | |
3720
408c7ee69be7
(scan_lists, Fforward_comment): Pass 0 as commentstop arg
Richard M. Stallman <rms@gnu.org>
parents:
3684
diff
changeset
|
1191 static Lisp_Object |
163 | 1192 describe_syntax_1 (vector) |
1193 Lisp_Object vector; | |
1194 { | |
1195 struct buffer *old = current_buffer; | |
1196 set_buffer_internal (XBUFFER (Vstandard_output)); | |
17786
90d9682afa28
(describe_syntax_1): Pass new args to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
17585
diff
changeset
|
1197 describe_vector (vector, Qnil, describe_syntax, 0, Qnil, Qnil, (int *) 0, 0); |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1198 while (! NILP (XCHAR_TABLE (vector)->parent)) |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1199 { |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1200 vector = XCHAR_TABLE (vector)->parent; |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1201 insert_string ("\nThe parent syntax table is:"); |
17786
90d9682afa28
(describe_syntax_1): Pass new args to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
17585
diff
changeset
|
1202 describe_vector (vector, Qnil, describe_syntax, 0, Qnil, Qnil, |
90d9682afa28
(describe_syntax_1): Pass new args to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
17585
diff
changeset
|
1203 (int *) 0, 0); |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1204 } |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1205 |
9863
f918fd077a9f
(describe_syntax_1): Set help-mode in *Help* buffer.
Karl Heuer <kwzh@gnu.org>
parents:
9475
diff
changeset
|
1206 call0 (intern ("help-mode")); |
163 | 1207 set_buffer_internal (old); |
1208 return Qnil; | |
1209 } | |
1210 | |
1211 DEFUN ("describe-syntax", Fdescribe_syntax, Sdescribe_syntax, 0, 0, "", | |
1212 "Describe the syntax specifications in the syntax table.\n\ | |
1213 The descriptions are inserted in a buffer, which is then displayed.") | |
1214 () | |
1215 { | |
1216 internal_with_output_to_temp_buffer | |
1217 ("*Help*", describe_syntax_1, current_buffer->syntax_table); | |
1218 | |
1219 return Qnil; | |
1220 } | |
1221 | |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1222 int parse_sexp_ignore_comments; |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1223 |
163 | 1224 /* Return the position across COUNT words from FROM. |
1225 If that many words cannot be found before the end of the buffer, return 0. | |
1226 COUNT negative means scan backward and stop at word beginning. */ | |
1227 | |
21514 | 1228 int |
163 | 1229 scan_words (from, count) |
1230 register int from, count; | |
1231 { | |
1232 register int beg = BEGV; | |
1233 register int end = ZV; | |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
1234 register int from_byte = CHAR_TO_BYTE (from); |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1235 register enum syntaxcode code; |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1236 int ch0, ch1; |
163 | 1237 |
1238 immediate_quit = 1; | |
1239 QUIT; | |
1240 | |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1241 SETUP_SYNTAX_TABLE (from, count); |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1242 |
163 | 1243 while (count > 0) |
1244 { | |
1245 while (1) | |
1246 { | |
1247 if (from == end) | |
1248 { | |
1249 immediate_quit = 0; | |
1250 return 0; | |
1251 } | |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1252 UPDATE_SYNTAX_TABLE_FORWARD (from); |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
1253 ch0 = FETCH_CHAR (from_byte); |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1254 code = SYNTAX (ch0); |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
1255 INC_BOTH (from, from_byte); |
163 | 1256 if (words_include_escapes |
1257 && (code == Sescape || code == Scharquote)) | |
1258 break; | |
1259 if (code == Sword) | |
1260 break; | |
1261 } | |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1262 /* Now CH0 is a character which begins a word and FROM is the |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1263 position of the next character. */ |
163 | 1264 while (1) |
1265 { | |
1266 if (from == end) break; | |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1267 UPDATE_SYNTAX_TABLE_FORWARD (from); |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
1268 ch1 = FETCH_CHAR (from_byte); |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1269 code = SYNTAX (ch1); |
163 | 1270 if (!(words_include_escapes |
1271 && (code == Sescape || code == Scharquote))) | |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1272 if (code != Sword || WORD_BOUNDARY_P (ch0, ch1)) |
163 | 1273 break; |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
1274 INC_BOTH (from, from_byte); |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1275 ch0 = ch1; |
163 | 1276 } |
1277 count--; | |
1278 } | |
1279 while (count < 0) | |
1280 { | |
1281 while (1) | |
1282 { | |
1283 if (from == beg) | |
1284 { | |
1285 immediate_quit = 0; | |
1286 return 0; | |
1287 } | |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
1288 DEC_BOTH (from, from_byte); |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1289 UPDATE_SYNTAX_TABLE_BACKWARD (from); |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
1290 ch1 = FETCH_CHAR (from_byte); |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1291 code = SYNTAX (ch1); |
163 | 1292 if (words_include_escapes |
1293 && (code == Sescape || code == Scharquote)) | |
1294 break; | |
1295 if (code == Sword) | |
1296 break; | |
1297 } | |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1298 /* Now CH1 is a character which ends a word and FROM is the |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1299 position of it. */ |
163 | 1300 while (1) |
1301 { | |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
1302 int temp_byte; |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
1303 |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
1304 if (from == beg) |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
1305 break; |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
1306 temp_byte = dec_bytepos (from_byte); |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1307 UPDATE_SYNTAX_TABLE_BACKWARD (from); |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
1308 ch0 = FETCH_CHAR (temp_byte); |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1309 code = SYNTAX (ch0); |
163 | 1310 if (!(words_include_escapes |
1311 && (code == Sescape || code == Scharquote))) | |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1312 if (code != Sword || WORD_BOUNDARY_P (ch0, ch1)) |
163 | 1313 break; |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
1314 DEC_BOTH (from, from_byte); |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1315 ch1 = ch0; |
163 | 1316 } |
1317 count++; | |
1318 } | |
1319 | |
1320 immediate_quit = 0; | |
1321 | |
1322 return from; | |
1323 } | |
1324 | |
1325 DEFUN ("forward-word", Fforward_word, Sforward_word, 1, 1, "p", | |
1326 "Move point forward ARG words (backward if ARG is negative).\n\ | |
1327 Normally returns t.\n\ | |
26391
216416ad34fe
(Fforward_word): Handle fields even if would have hit
Richard M. Stallman <rms@gnu.org>
parents:
26272
diff
changeset
|
1328 If an edge of the buffer or a field boundary is reached, point is left there\n\ |
27079
638b309011d9
(Fforward_word): Notice field boundaries only if
Gerd Moellmann <gerd@gnu.org>
parents:
26526
diff
changeset
|
1329 and the function returns nil. Field boundaries are not noticed if\n\ |
638b309011d9
(Fforward_word): Notice field boundaries only if
Gerd Moellmann <gerd@gnu.org>
parents:
26526
diff
changeset
|
1330 `inhibit-field-text-motion' is non-nil.") |
163 | 1331 (count) |
1332 Lisp_Object count; | |
1333 { | |
26391
216416ad34fe
(Fforward_word): Handle fields even if would have hit
Richard M. Stallman <rms@gnu.org>
parents:
26272
diff
changeset
|
1334 int orig_val, val; |
163 | 1335 CHECK_NUMBER (count, 0); |
1336 | |
26391
216416ad34fe
(Fforward_word): Handle fields even if would have hit
Richard M. Stallman <rms@gnu.org>
parents:
26272
diff
changeset
|
1337 val = orig_val = scan_words (PT, XINT (count)); |
216416ad34fe
(Fforward_word): Handle fields even if would have hit
Richard M. Stallman <rms@gnu.org>
parents:
26272
diff
changeset
|
1338 if (! orig_val) |
216416ad34fe
(Fforward_word): Handle fields even if would have hit
Richard M. Stallman <rms@gnu.org>
parents:
26272
diff
changeset
|
1339 val = XINT (count) > 0 ? ZV : BEGV; |
25401
3f78f1fed4e0
(Fforward_word): If in a mini-buffer and moving
Gerd Moellmann <gerd@gnu.org>
parents:
25290
diff
changeset
|
1340 |
26060
6edf64bf5e22
(Fforward_word): Supply new ESCAPE_FROM_EDGE parameter
Gerd Moellmann <gerd@gnu.org>
parents:
25771
diff
changeset
|
1341 /* Avoid jumping out of an input field. */ |
27080
b1afaefff576
(Fforward_word): Undo previous change.
Gerd Moellmann <gerd@gnu.org>
parents:
27079
diff
changeset
|
1342 val = XFASTINT (Fconstrain_to_field (make_number (val), make_number (PT), |
30443
25425775cac4
(Fforward_word): Add last arg nil in call of
Gerd Moellmann <gerd@gnu.org>
parents:
30228
diff
changeset
|
1343 Qt, Qnil, Qnil)); |
27080
b1afaefff576
(Fforward_word): Undo previous change.
Gerd Moellmann <gerd@gnu.org>
parents:
27079
diff
changeset
|
1344 |
163 | 1345 SET_PT (val); |
27079
638b309011d9
(Fforward_word): Notice field boundaries only if
Gerd Moellmann <gerd@gnu.org>
parents:
26526
diff
changeset
|
1346 return val == orig_val ? Qt : Qnil; |
163 | 1347 } |
1348 | |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1349 Lisp_Object skip_chars (); |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1350 |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1351 DEFUN ("skip-chars-forward", Fskip_chars_forward, Sskip_chars_forward, 1, 2, 0, |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1352 "Move point forward, stopping before a char not in STRING, or at pos LIM.\n\ |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1353 STRING is like the inside of a `[...]' in a regular expression\n\ |
22052
74d69da256e4
(skip_chars): When fetching char after \,
Richard M. Stallman <rms@gnu.org>
parents:
22006
diff
changeset
|
1354 except that `]' is never special and `\\' quotes `^', `-' or `\\'\n\ |
74d69da256e4
(skip_chars): When fetching char after \,
Richard M. Stallman <rms@gnu.org>
parents:
22006
diff
changeset
|
1355 (but not as the end of a range; quoting is never needed there).\n\ |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1356 Thus, with arg \"a-zA-Z\", this skips letters stopping before first nonletter.\n\ |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1357 With arg \"^a-zA-Z\", skips nonletters stopping before first letter.\n\ |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1358 Returns the distance traveled, either zero or positive.") |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1359 (string, lim) |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1360 Lisp_Object string, lim; |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1361 { |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1362 return skip_chars (1, 0, string, lim); |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1363 } |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1364 |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1365 DEFUN ("skip-chars-backward", Fskip_chars_backward, Sskip_chars_backward, 1, 2, 0, |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1366 "Move point backward, stopping after a char not in STRING, or at pos LIM.\n\ |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1367 See `skip-chars-forward' for details.\n\ |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1368 Returns the distance traveled, either zero or negative.") |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1369 (string, lim) |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1370 Lisp_Object string, lim; |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1371 { |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1372 return skip_chars (0, 0, string, lim); |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1373 } |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1374 |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1375 DEFUN ("skip-syntax-forward", Fskip_syntax_forward, Sskip_syntax_forward, 1, 2, 0, |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1376 "Move point forward across chars in specified syntax classes.\n\ |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1377 SYNTAX is a string of syntax code characters.\n\ |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1378 Stop before a char whose syntax is not in SYNTAX, or at position LIM.\n\ |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1379 If SYNTAX starts with ^, skip characters whose syntax is NOT in SYNTAX.\n\ |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1380 This function returns the distance traveled, either zero or positive.") |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1381 (syntax, lim) |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1382 Lisp_Object syntax, lim; |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1383 { |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1384 return skip_chars (1, 1, syntax, lim); |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1385 } |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1386 |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1387 DEFUN ("skip-syntax-backward", Fskip_syntax_backward, Sskip_syntax_backward, 1, 2, 0, |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1388 "Move point backward across chars in specified syntax classes.\n\ |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1389 SYNTAX is a string of syntax code characters.\n\ |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1390 Stop on reaching a char whose syntax is not in SYNTAX, or at position LIM.\n\ |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1391 If SYNTAX starts with ^, skip characters whose syntax is NOT in SYNTAX.\n\ |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1392 This function returns the distance traveled, either zero or negative.") |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1393 (syntax, lim) |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1394 Lisp_Object syntax, lim; |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1395 { |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1396 return skip_chars (0, 1, syntax, lim); |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1397 } |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1398 |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
1399 static Lisp_Object |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1400 skip_chars (forwardp, syntaxp, string, lim) |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1401 int forwardp, syntaxp; |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1402 Lisp_Object string, lim; |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1403 { |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1404 register unsigned int c; |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1405 unsigned char fastmap[0400]; |
17564
050f15e0b948
(skip_chars): Merge mule changes back in.
Richard M. Stallman <rms@gnu.org>
parents:
17466
diff
changeset
|
1406 /* If SYNTAXP is 0, STRING may contain multi-byte form of characters |
31944
05763e780521
(skip_chars): Handle negation correctly.
Kenichi Handa <handa@m17n.org>
parents:
31209
diff
changeset
|
1407 of which codes don't fit in FASTMAP. In that case, set the |
05763e780521
(skip_chars): Handle negation correctly.
Kenichi Handa <handa@m17n.org>
parents:
31209
diff
changeset
|
1408 ranges of characters in CHAR_RANGES. */ |
20292
2befa7396e42
(skip_chars): Check type of `string' before using it.
Karl Heuer <kwzh@gnu.org>
parents:
18938
diff
changeset
|
1409 int *char_ranges; |
17564
050f15e0b948
(skip_chars): Merge mule changes back in.
Richard M. Stallman <rms@gnu.org>
parents:
17466
diff
changeset
|
1410 int n_char_ranges = 0; |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1411 int negate = 0; |
20626
a39bcf9c0e1e
(skip_chars): Handle multibyte and unibyte strings
Richard M. Stallman <rms@gnu.org>
parents:
20546
diff
changeset
|
1412 register int i, i_byte; |
17564
050f15e0b948
(skip_chars): Merge mule changes back in.
Richard M. Stallman <rms@gnu.org>
parents:
17466
diff
changeset
|
1413 int multibyte = !NILP (current_buffer->enable_multibyte_characters); |
22486
a28020246db1
(skip_chars): Don't examine STRING before verifying that it is a string.
Richard M. Stallman <rms@gnu.org>
parents:
22432
diff
changeset
|
1414 int string_multibyte; |
a28020246db1
(skip_chars): Don't examine STRING before verifying that it is a string.
Richard M. Stallman <rms@gnu.org>
parents:
22432
diff
changeset
|
1415 int size_byte; |
30596
48a9e9f4fd9d
(skip_chars): Fix handling of multibyte<->unibyte conversion.
Kenichi Handa <handa@m17n.org>
parents:
30594
diff
changeset
|
1416 unsigned char *str; |
48a9e9f4fd9d
(skip_chars): Fix handling of multibyte<->unibyte conversion.
Kenichi Handa <handa@m17n.org>
parents:
30594
diff
changeset
|
1417 int len; |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1418 |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1419 CHECK_STRING (string, 0); |
20292
2befa7396e42
(skip_chars): Check type of `string' before using it.
Karl Heuer <kwzh@gnu.org>
parents:
18938
diff
changeset
|
1420 char_ranges = (int *) alloca (XSTRING (string)->size * (sizeof (int)) * 2); |
22486
a28020246db1
(skip_chars): Don't examine STRING before verifying that it is a string.
Richard M. Stallman <rms@gnu.org>
parents:
22432
diff
changeset
|
1421 string_multibyte = STRING_MULTIBYTE (string); |
30596
48a9e9f4fd9d
(skip_chars): Fix handling of multibyte<->unibyte conversion.
Kenichi Handa <handa@m17n.org>
parents:
30594
diff
changeset
|
1422 str = XSTRING (string)->data; |
22486
a28020246db1
(skip_chars): Don't examine STRING before verifying that it is a string.
Richard M. Stallman <rms@gnu.org>
parents:
22432
diff
changeset
|
1423 size_byte = STRING_BYTES (XSTRING (string)); |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1424 |
30596
48a9e9f4fd9d
(skip_chars): Fix handling of multibyte<->unibyte conversion.
Kenichi Handa <handa@m17n.org>
parents:
30594
diff
changeset
|
1425 /* Adjust the multibyteness of the string to that of the buffer. */ |
48a9e9f4fd9d
(skip_chars): Fix handling of multibyte<->unibyte conversion.
Kenichi Handa <handa@m17n.org>
parents:
30594
diff
changeset
|
1426 if (multibyte != string_multibyte) |
48a9e9f4fd9d
(skip_chars): Fix handling of multibyte<->unibyte conversion.
Kenichi Handa <handa@m17n.org>
parents:
30594
diff
changeset
|
1427 { |
48a9e9f4fd9d
(skip_chars): Fix handling of multibyte<->unibyte conversion.
Kenichi Handa <handa@m17n.org>
parents:
30594
diff
changeset
|
1428 int nbytes; |
48a9e9f4fd9d
(skip_chars): Fix handling of multibyte<->unibyte conversion.
Kenichi Handa <handa@m17n.org>
parents:
30594
diff
changeset
|
1429 |
48a9e9f4fd9d
(skip_chars): Fix handling of multibyte<->unibyte conversion.
Kenichi Handa <handa@m17n.org>
parents:
30594
diff
changeset
|
1430 if (multibyte) |
48a9e9f4fd9d
(skip_chars): Fix handling of multibyte<->unibyte conversion.
Kenichi Handa <handa@m17n.org>
parents:
30594
diff
changeset
|
1431 nbytes = count_size_as_multibyte (XSTRING (string)->data, |
48a9e9f4fd9d
(skip_chars): Fix handling of multibyte<->unibyte conversion.
Kenichi Handa <handa@m17n.org>
parents:
30594
diff
changeset
|
1432 XSTRING (string)->size); |
48a9e9f4fd9d
(skip_chars): Fix handling of multibyte<->unibyte conversion.
Kenichi Handa <handa@m17n.org>
parents:
30594
diff
changeset
|
1433 else |
48a9e9f4fd9d
(skip_chars): Fix handling of multibyte<->unibyte conversion.
Kenichi Handa <handa@m17n.org>
parents:
30594
diff
changeset
|
1434 nbytes = XSTRING (string)->size; |
48a9e9f4fd9d
(skip_chars): Fix handling of multibyte<->unibyte conversion.
Kenichi Handa <handa@m17n.org>
parents:
30594
diff
changeset
|
1435 if (nbytes != size_byte) |
48a9e9f4fd9d
(skip_chars): Fix handling of multibyte<->unibyte conversion.
Kenichi Handa <handa@m17n.org>
parents:
30594
diff
changeset
|
1436 { |
48a9e9f4fd9d
(skip_chars): Fix handling of multibyte<->unibyte conversion.
Kenichi Handa <handa@m17n.org>
parents:
30594
diff
changeset
|
1437 str = (unsigned char *) alloca (nbytes); |
30626
9d47c133b357
* syntax.c (skip_chars): Fix previous change. Make the handling of
Kenichi Handa <handa@m17n.org>
parents:
30596
diff
changeset
|
1438 copy_text (XSTRING (string)->data, str, size_byte, |
30596
48a9e9f4fd9d
(skip_chars): Fix handling of multibyte<->unibyte conversion.
Kenichi Handa <handa@m17n.org>
parents:
30594
diff
changeset
|
1439 string_multibyte, multibyte); |
48a9e9f4fd9d
(skip_chars): Fix handling of multibyte<->unibyte conversion.
Kenichi Handa <handa@m17n.org>
parents:
30594
diff
changeset
|
1440 size_byte = nbytes; |
48a9e9f4fd9d
(skip_chars): Fix handling of multibyte<->unibyte conversion.
Kenichi Handa <handa@m17n.org>
parents:
30594
diff
changeset
|
1441 } |
48a9e9f4fd9d
(skip_chars): Fix handling of multibyte<->unibyte conversion.
Kenichi Handa <handa@m17n.org>
parents:
30594
diff
changeset
|
1442 } |
48a9e9f4fd9d
(skip_chars): Fix handling of multibyte<->unibyte conversion.
Kenichi Handa <handa@m17n.org>
parents:
30594
diff
changeset
|
1443 |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1444 if (NILP (lim)) |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1445 XSETINT (lim, forwardp ? ZV : BEGV); |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1446 else |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
1447 CHECK_NUMBER_COERCE_MARKER (lim, 0); |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1448 |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1449 /* In any case, don't allow scan outside bounds of buffer. */ |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1450 if (XINT (lim) > ZV) |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1451 XSETFASTINT (lim, ZV); |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1452 if (XINT (lim) < BEGV) |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1453 XSETFASTINT (lim, BEGV); |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1454 |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1455 bzero (fastmap, sizeof fastmap); |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1456 |
30596
48a9e9f4fd9d
(skip_chars): Fix handling of multibyte<->unibyte conversion.
Kenichi Handa <handa@m17n.org>
parents:
30594
diff
changeset
|
1457 i_byte = 0; |
20626
a39bcf9c0e1e
(skip_chars): Handle multibyte and unibyte strings
Richard M. Stallman <rms@gnu.org>
parents:
20546
diff
changeset
|
1458 |
22130
b25abff012fd
(skip_chars): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
22116
diff
changeset
|
1459 if (i_byte < size_byte |
20626
a39bcf9c0e1e
(skip_chars): Handle multibyte and unibyte strings
Richard M. Stallman <rms@gnu.org>
parents:
20546
diff
changeset
|
1460 && XSTRING (string)->data[0] == '^') |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1461 { |
30596
48a9e9f4fd9d
(skip_chars): Fix handling of multibyte<->unibyte conversion.
Kenichi Handa <handa@m17n.org>
parents:
30594
diff
changeset
|
1462 negate = 1; i_byte++; |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1463 } |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1464 |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1465 /* Find the characters specified and set their elements of fastmap. |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1466 If syntaxp, each character counts as itself. |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1467 Otherwise, handle backslashes and ranges specially. */ |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1468 |
22130
b25abff012fd
(skip_chars): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
22116
diff
changeset
|
1469 while (i_byte < size_byte) |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1470 { |
30596
48a9e9f4fd9d
(skip_chars): Fix handling of multibyte<->unibyte conversion.
Kenichi Handa <handa@m17n.org>
parents:
30594
diff
changeset
|
1471 c = STRING_CHAR_AND_LENGTH (str + i_byte, size_byte - i_byte, len); |
48a9e9f4fd9d
(skip_chars): Fix handling of multibyte<->unibyte conversion.
Kenichi Handa <handa@m17n.org>
parents:
30594
diff
changeset
|
1472 i_byte += len; |
20626
a39bcf9c0e1e
(skip_chars): Handle multibyte and unibyte strings
Richard M. Stallman <rms@gnu.org>
parents:
20546
diff
changeset
|
1473 |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1474 if (syntaxp) |
20626
a39bcf9c0e1e
(skip_chars): Handle multibyte and unibyte strings
Richard M. Stallman <rms@gnu.org>
parents:
20546
diff
changeset
|
1475 fastmap[syntax_spec_code[c & 0377]] = 1; |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1476 else |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1477 { |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1478 if (c == '\\') |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1479 { |
22130
b25abff012fd
(skip_chars): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
22116
diff
changeset
|
1480 if (i_byte == size_byte) |
20626
a39bcf9c0e1e
(skip_chars): Handle multibyte and unibyte strings
Richard M. Stallman <rms@gnu.org>
parents:
20546
diff
changeset
|
1481 break; |
a39bcf9c0e1e
(skip_chars): Handle multibyte and unibyte strings
Richard M. Stallman <rms@gnu.org>
parents:
20546
diff
changeset
|
1482 |
30596
48a9e9f4fd9d
(skip_chars): Fix handling of multibyte<->unibyte conversion.
Kenichi Handa <handa@m17n.org>
parents:
30594
diff
changeset
|
1483 c = STRING_CHAR_AND_LENGTH (str+i_byte, size_byte-i_byte, len); |
48a9e9f4fd9d
(skip_chars): Fix handling of multibyte<->unibyte conversion.
Kenichi Handa <handa@m17n.org>
parents:
30594
diff
changeset
|
1484 i_byte += len; |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1485 } |
22130
b25abff012fd
(skip_chars): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
22116
diff
changeset
|
1486 if (i_byte < size_byte |
30596
48a9e9f4fd9d
(skip_chars): Fix handling of multibyte<->unibyte conversion.
Kenichi Handa <handa@m17n.org>
parents:
30594
diff
changeset
|
1487 && str[i_byte] == '-') |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1488 { |
31944
05763e780521
(skip_chars): Handle negation correctly.
Kenichi Handa <handa@m17n.org>
parents:
31209
diff
changeset
|
1489 unsigned int c2; |
20626
a39bcf9c0e1e
(skip_chars): Handle multibyte and unibyte strings
Richard M. Stallman <rms@gnu.org>
parents:
20546
diff
changeset
|
1490 |
a39bcf9c0e1e
(skip_chars): Handle multibyte and unibyte strings
Richard M. Stallman <rms@gnu.org>
parents:
20546
diff
changeset
|
1491 /* Skip over the dash. */ |
30596
48a9e9f4fd9d
(skip_chars): Fix handling of multibyte<->unibyte conversion.
Kenichi Handa <handa@m17n.org>
parents:
30594
diff
changeset
|
1492 i_byte++; |
20626
a39bcf9c0e1e
(skip_chars): Handle multibyte and unibyte strings
Richard M. Stallman <rms@gnu.org>
parents:
20546
diff
changeset
|
1493 |
22130
b25abff012fd
(skip_chars): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
22116
diff
changeset
|
1494 if (i_byte == size_byte) |
20626
a39bcf9c0e1e
(skip_chars): Handle multibyte and unibyte strings
Richard M. Stallman <rms@gnu.org>
parents:
20546
diff
changeset
|
1495 break; |
17564
050f15e0b948
(skip_chars): Merge mule changes back in.
Richard M. Stallman <rms@gnu.org>
parents:
17466
diff
changeset
|
1496 |
20626
a39bcf9c0e1e
(skip_chars): Handle multibyte and unibyte strings
Richard M. Stallman <rms@gnu.org>
parents:
20546
diff
changeset
|
1497 /* Get the end of the range. */ |
30596
48a9e9f4fd9d
(skip_chars): Fix handling of multibyte<->unibyte conversion.
Kenichi Handa <handa@m17n.org>
parents:
30594
diff
changeset
|
1498 c2 =STRING_CHAR_AND_LENGTH (str+i_byte, size_byte-i_byte, len); |
48a9e9f4fd9d
(skip_chars): Fix handling of multibyte<->unibyte conversion.
Kenichi Handa <handa@m17n.org>
parents:
30594
diff
changeset
|
1499 i_byte += len; |
20626
a39bcf9c0e1e
(skip_chars): Handle multibyte and unibyte strings
Richard M. Stallman <rms@gnu.org>
parents:
20546
diff
changeset
|
1500 |
a39bcf9c0e1e
(skip_chars): Handle multibyte and unibyte strings
Richard M. Stallman <rms@gnu.org>
parents:
20546
diff
changeset
|
1501 if (SINGLE_BYTE_CHAR_P (c)) |
22116
09efd6a94b4b
(skip_chars): Fix bug in handling a range which
Kenichi Handa <handa@m17n.org>
parents:
22052
diff
changeset
|
1502 { |
09efd6a94b4b
(skip_chars): Fix bug in handling a range which
Kenichi Handa <handa@m17n.org>
parents:
22052
diff
changeset
|
1503 if (! SINGLE_BYTE_CHAR_P (c2)) |
30626
9d47c133b357
* syntax.c (skip_chars): Fix previous change. Make the handling of
Kenichi Handa <handa@m17n.org>
parents:
30596
diff
changeset
|
1504 { |
32794 | 1505 /* Handle a range starting with a character of |
1506 less than 256, and ending with a character of | |
1507 not less than 256. Split that into two | |
1508 ranges, the low one ending at 0377, and the | |
1509 high one starting at the smallest character | |
1510 in the charset of C2 and ending at C2. */ | |
30626
9d47c133b357
* syntax.c (skip_chars): Fix previous change. Make the handling of
Kenichi Handa <handa@m17n.org>
parents:
30596
diff
changeset
|
1511 int charset = CHAR_CHARSET (c2); |
9d47c133b357
* syntax.c (skip_chars): Fix previous change. Make the handling of
Kenichi Handa <handa@m17n.org>
parents:
30596
diff
changeset
|
1512 int c1 = MAKE_CHAR (charset, 0, 0); |
9d47c133b357
* syntax.c (skip_chars): Fix previous change. Make the handling of
Kenichi Handa <handa@m17n.org>
parents:
30596
diff
changeset
|
1513 |
9d47c133b357
* syntax.c (skip_chars): Fix previous change. Make the handling of
Kenichi Handa <handa@m17n.org>
parents:
30596
diff
changeset
|
1514 char_ranges[n_char_ranges++] = c1; |
9d47c133b357
* syntax.c (skip_chars): Fix previous change. Make the handling of
Kenichi Handa <handa@m17n.org>
parents:
30596
diff
changeset
|
1515 char_ranges[n_char_ranges++] = c2; |
32399
3819d0d851cb
(skip_chars): Change the way of handling a range from unibyte char to
Kenichi Handa <handa@m17n.org>
parents:
32087
diff
changeset
|
1516 c2 = 0377; |
30626
9d47c133b357
* syntax.c (skip_chars): Fix previous change. Make the handling of
Kenichi Handa <handa@m17n.org>
parents:
30596
diff
changeset
|
1517 } |
22116
09efd6a94b4b
(skip_chars): Fix bug in handling a range which
Kenichi Handa <handa@m17n.org>
parents:
22052
diff
changeset
|
1518 while (c <= c2) |
09efd6a94b4b
(skip_chars): Fix bug in handling a range which
Kenichi Handa <handa@m17n.org>
parents:
22052
diff
changeset
|
1519 { |
09efd6a94b4b
(skip_chars): Fix bug in handling a range which
Kenichi Handa <handa@m17n.org>
parents:
22052
diff
changeset
|
1520 fastmap[c] = 1; |
09efd6a94b4b
(skip_chars): Fix bug in handling a range which
Kenichi Handa <handa@m17n.org>
parents:
22052
diff
changeset
|
1521 c++; |
09efd6a94b4b
(skip_chars): Fix bug in handling a range which
Kenichi Handa <handa@m17n.org>
parents:
22052
diff
changeset
|
1522 } |
09efd6a94b4b
(skip_chars): Fix bug in handling a range which
Kenichi Handa <handa@m17n.org>
parents:
22052
diff
changeset
|
1523 } |
31944
05763e780521
(skip_chars): Handle negation correctly.
Kenichi Handa <handa@m17n.org>
parents:
31209
diff
changeset
|
1524 else if (c <= c2) /* Both C and C2 are multibyte char. */ |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1525 { |
31944
05763e780521
(skip_chars): Handle negation correctly.
Kenichi Handa <handa@m17n.org>
parents:
31209
diff
changeset
|
1526 char_ranges[n_char_ranges++] = c; |
05763e780521
(skip_chars): Handle negation correctly.
Kenichi Handa <handa@m17n.org>
parents:
31209
diff
changeset
|
1527 char_ranges[n_char_ranges++] = c2; |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1528 } |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1529 } |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1530 else |
17564
050f15e0b948
(skip_chars): Merge mule changes back in.
Richard M. Stallman <rms@gnu.org>
parents:
17466
diff
changeset
|
1531 { |
30626
9d47c133b357
* syntax.c (skip_chars): Fix previous change. Make the handling of
Kenichi Handa <handa@m17n.org>
parents:
30596
diff
changeset
|
1532 if (SINGLE_BYTE_CHAR_P (c)) |
9d47c133b357
* syntax.c (skip_chars): Fix previous change. Make the handling of
Kenichi Handa <handa@m17n.org>
parents:
30596
diff
changeset
|
1533 fastmap[c] = 1; |
9d47c133b357
* syntax.c (skip_chars): Fix previous change. Make the handling of
Kenichi Handa <handa@m17n.org>
parents:
30596
diff
changeset
|
1534 else |
17564
050f15e0b948
(skip_chars): Merge mule changes back in.
Richard M. Stallman <rms@gnu.org>
parents:
17466
diff
changeset
|
1535 { |
20626
a39bcf9c0e1e
(skip_chars): Handle multibyte and unibyte strings
Richard M. Stallman <rms@gnu.org>
parents:
20546
diff
changeset
|
1536 char_ranges[n_char_ranges++] = c; |
a39bcf9c0e1e
(skip_chars): Handle multibyte and unibyte strings
Richard M. Stallman <rms@gnu.org>
parents:
20546
diff
changeset
|
1537 char_ranges[n_char_ranges++] = c; |
17564
050f15e0b948
(skip_chars): Merge mule changes back in.
Richard M. Stallman <rms@gnu.org>
parents:
17466
diff
changeset
|
1538 } |
050f15e0b948
(skip_chars): Merge mule changes back in.
Richard M. Stallman <rms@gnu.org>
parents:
17466
diff
changeset
|
1539 } |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1540 } |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1541 } |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1542 |
31944
05763e780521
(skip_chars): Handle negation correctly.
Kenichi Handa <handa@m17n.org>
parents:
31209
diff
changeset
|
1543 /* If ^ was the first character, complement the fastmap. */ |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1544 if (negate) |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1545 for (i = 0; i < sizeof fastmap; i++) |
31944
05763e780521
(skip_chars): Handle negation correctly.
Kenichi Handa <handa@m17n.org>
parents:
31209
diff
changeset
|
1546 fastmap[i] ^= 1; |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1547 |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1548 { |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1549 int start_point = PT; |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1550 int pos = PT; |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
1551 int pos_byte = PT_BYTE; |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1552 |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1553 immediate_quit = 1; |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1554 if (syntaxp) |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1555 { |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1556 SETUP_SYNTAX_TABLE (pos, forwardp ? 1 : -1); |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1557 if (forwardp) |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1558 { |
17564
050f15e0b948
(skip_chars): Merge mule changes back in.
Richard M. Stallman <rms@gnu.org>
parents:
17466
diff
changeset
|
1559 if (multibyte) |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1560 { |
20956
15d1b7bf1cd7
(update_syntax_table): Fix calculations using offset.
Karl Heuer <kwzh@gnu.org>
parents:
20905
diff
changeset
|
1561 if (pos < XINT (lim)) |
15d1b7bf1cd7
(update_syntax_table): Fix calculations using offset.
Karl Heuer <kwzh@gnu.org>
parents:
20905
diff
changeset
|
1562 while (fastmap[(int) SYNTAX (FETCH_CHAR (pos_byte))]) |
15d1b7bf1cd7
(update_syntax_table): Fix calculations using offset.
Karl Heuer <kwzh@gnu.org>
parents:
20905
diff
changeset
|
1563 { |
15d1b7bf1cd7
(update_syntax_table): Fix calculations using offset.
Karl Heuer <kwzh@gnu.org>
parents:
20905
diff
changeset
|
1564 /* Since we already checked for multibyteness, |
15d1b7bf1cd7
(update_syntax_table): Fix calculations using offset.
Karl Heuer <kwzh@gnu.org>
parents:
20905
diff
changeset
|
1565 avoid using INC_BOTH which checks again. */ |
15d1b7bf1cd7
(update_syntax_table): Fix calculations using offset.
Karl Heuer <kwzh@gnu.org>
parents:
20905
diff
changeset
|
1566 INC_POS (pos_byte); |
15d1b7bf1cd7
(update_syntax_table): Fix calculations using offset.
Karl Heuer <kwzh@gnu.org>
parents:
20905
diff
changeset
|
1567 pos++; |
15d1b7bf1cd7
(update_syntax_table): Fix calculations using offset.
Karl Heuer <kwzh@gnu.org>
parents:
20905
diff
changeset
|
1568 if (pos >= XINT (lim)) |
15d1b7bf1cd7
(update_syntax_table): Fix calculations using offset.
Karl Heuer <kwzh@gnu.org>
parents:
20905
diff
changeset
|
1569 break; |
15d1b7bf1cd7
(update_syntax_table): Fix calculations using offset.
Karl Heuer <kwzh@gnu.org>
parents:
20905
diff
changeset
|
1570 UPDATE_SYNTAX_TABLE_FORWARD (pos); |
15d1b7bf1cd7
(update_syntax_table): Fix calculations using offset.
Karl Heuer <kwzh@gnu.org>
parents:
20905
diff
changeset
|
1571 } |
17564
050f15e0b948
(skip_chars): Merge mule changes back in.
Richard M. Stallman <rms@gnu.org>
parents:
17466
diff
changeset
|
1572 } |
050f15e0b948
(skip_chars): Merge mule changes back in.
Richard M. Stallman <rms@gnu.org>
parents:
17466
diff
changeset
|
1573 else |
050f15e0b948
(skip_chars): Merge mule changes back in.
Richard M. Stallman <rms@gnu.org>
parents:
17466
diff
changeset
|
1574 { |
050f15e0b948
(skip_chars): Merge mule changes back in.
Richard M. Stallman <rms@gnu.org>
parents:
17466
diff
changeset
|
1575 while (pos < XINT (lim) |
050f15e0b948
(skip_chars): Merge mule changes back in.
Richard M. Stallman <rms@gnu.org>
parents:
17466
diff
changeset
|
1576 && fastmap[(int) SYNTAX (FETCH_BYTE (pos))]) |
050f15e0b948
(skip_chars): Merge mule changes back in.
Richard M. Stallman <rms@gnu.org>
parents:
17466
diff
changeset
|
1577 { |
050f15e0b948
(skip_chars): Merge mule changes back in.
Richard M. Stallman <rms@gnu.org>
parents:
17466
diff
changeset
|
1578 pos++; |
050f15e0b948
(skip_chars): Merge mule changes back in.
Richard M. Stallman <rms@gnu.org>
parents:
17466
diff
changeset
|
1579 UPDATE_SYNTAX_TABLE_FORWARD (pos); |
050f15e0b948
(skip_chars): Merge mule changes back in.
Richard M. Stallman <rms@gnu.org>
parents:
17466
diff
changeset
|
1580 } |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1581 } |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1582 } |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1583 else |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1584 { |
17564
050f15e0b948
(skip_chars): Merge mule changes back in.
Richard M. Stallman <rms@gnu.org>
parents:
17466
diff
changeset
|
1585 if (multibyte) |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1586 { |
17564
050f15e0b948
(skip_chars): Merge mule changes back in.
Richard M. Stallman <rms@gnu.org>
parents:
17466
diff
changeset
|
1587 while (pos > XINT (lim)) |
050f15e0b948
(skip_chars): Merge mule changes back in.
Richard M. Stallman <rms@gnu.org>
parents:
17466
diff
changeset
|
1588 { |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
1589 int savepos = pos_byte; |
20905
e646a6ae42cd
(skip_chars): Use INC_POS instead of INC_BOTH.
Richard M. Stallman <rms@gnu.org>
parents:
20766
diff
changeset
|
1590 /* Since we already checked for multibyteness, |
e646a6ae42cd
(skip_chars): Use INC_POS instead of INC_BOTH.
Richard M. Stallman <rms@gnu.org>
parents:
20766
diff
changeset
|
1591 avoid using DEC_BOTH which checks again. */ |
e646a6ae42cd
(skip_chars): Use INC_POS instead of INC_BOTH.
Richard M. Stallman <rms@gnu.org>
parents:
20766
diff
changeset
|
1592 pos--; |
e646a6ae42cd
(skip_chars): Use INC_POS instead of INC_BOTH.
Richard M. Stallman <rms@gnu.org>
parents:
20766
diff
changeset
|
1593 DEC_POS (pos_byte); |
17585
aefc22e52046
(skip_chars): Fix previous change in syntax/backward case.
Richard M. Stallman <rms@gnu.org>
parents:
17564
diff
changeset
|
1594 UPDATE_SYNTAX_TABLE_BACKWARD (pos); |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
1595 if (!fastmap[(int) SYNTAX (FETCH_CHAR (pos_byte))]) |
17564
050f15e0b948
(skip_chars): Merge mule changes back in.
Richard M. Stallman <rms@gnu.org>
parents:
17466
diff
changeset
|
1596 { |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
1597 pos++; |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
1598 pos_byte = savepos; |
17564
050f15e0b948
(skip_chars): Merge mule changes back in.
Richard M. Stallman <rms@gnu.org>
parents:
17466
diff
changeset
|
1599 break; |
050f15e0b948
(skip_chars): Merge mule changes back in.
Richard M. Stallman <rms@gnu.org>
parents:
17466
diff
changeset
|
1600 } |
050f15e0b948
(skip_chars): Merge mule changes back in.
Richard M. Stallman <rms@gnu.org>
parents:
17466
diff
changeset
|
1601 } |
050f15e0b948
(skip_chars): Merge mule changes back in.
Richard M. Stallman <rms@gnu.org>
parents:
17466
diff
changeset
|
1602 } |
050f15e0b948
(skip_chars): Merge mule changes back in.
Richard M. Stallman <rms@gnu.org>
parents:
17466
diff
changeset
|
1603 else |
050f15e0b948
(skip_chars): Merge mule changes back in.
Richard M. Stallman <rms@gnu.org>
parents:
17466
diff
changeset
|
1604 { |
20956
15d1b7bf1cd7
(update_syntax_table): Fix calculations using offset.
Karl Heuer <kwzh@gnu.org>
parents:
20905
diff
changeset
|
1605 if (pos > XINT (lim)) |
15d1b7bf1cd7
(update_syntax_table): Fix calculations using offset.
Karl Heuer <kwzh@gnu.org>
parents:
20905
diff
changeset
|
1606 while (fastmap[(int) SYNTAX (FETCH_BYTE (pos - 1))]) |
15d1b7bf1cd7
(update_syntax_table): Fix calculations using offset.
Karl Heuer <kwzh@gnu.org>
parents:
20905
diff
changeset
|
1607 { |
15d1b7bf1cd7
(update_syntax_table): Fix calculations using offset.
Karl Heuer <kwzh@gnu.org>
parents:
20905
diff
changeset
|
1608 pos--; |
15d1b7bf1cd7
(update_syntax_table): Fix calculations using offset.
Karl Heuer <kwzh@gnu.org>
parents:
20905
diff
changeset
|
1609 if (pos <= XINT (lim)) |
17585
aefc22e52046
(skip_chars): Fix previous change in syntax/backward case.
Richard M. Stallman <rms@gnu.org>
parents:
17564
diff
changeset
|
1610 break; |
20956
15d1b7bf1cd7
(update_syntax_table): Fix calculations using offset.
Karl Heuer <kwzh@gnu.org>
parents:
20905
diff
changeset
|
1611 UPDATE_SYNTAX_TABLE_BACKWARD (pos - 1); |
15d1b7bf1cd7
(update_syntax_table): Fix calculations using offset.
Karl Heuer <kwzh@gnu.org>
parents:
20905
diff
changeset
|
1612 } |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1613 } |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1614 } |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1615 } |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1616 else |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1617 { |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1618 if (forwardp) |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1619 { |
17564
050f15e0b948
(skip_chars): Merge mule changes back in.
Richard M. Stallman <rms@gnu.org>
parents:
17466
diff
changeset
|
1620 if (multibyte) |
31944
05763e780521
(skip_chars): Handle negation correctly.
Kenichi Handa <handa@m17n.org>
parents:
31209
diff
changeset
|
1621 while (pos < XINT (lim)) |
17564
050f15e0b948
(skip_chars): Merge mule changes back in.
Richard M. Stallman <rms@gnu.org>
parents:
17466
diff
changeset
|
1622 { |
31944
05763e780521
(skip_chars): Handle negation correctly.
Kenichi Handa <handa@m17n.org>
parents:
31209
diff
changeset
|
1623 c = FETCH_MULTIBYTE_CHAR (pos_byte); |
05763e780521
(skip_chars): Handle negation correctly.
Kenichi Handa <handa@m17n.org>
parents:
31209
diff
changeset
|
1624 if (SINGLE_BYTE_CHAR_P (c)) |
17564
050f15e0b948
(skip_chars): Merge mule changes back in.
Richard M. Stallman <rms@gnu.org>
parents:
17466
diff
changeset
|
1625 { |
31944
05763e780521
(skip_chars): Handle negation correctly.
Kenichi Handa <handa@m17n.org>
parents:
31209
diff
changeset
|
1626 if (!fastmap[c]) |
05763e780521
(skip_chars): Handle negation correctly.
Kenichi Handa <handa@m17n.org>
parents:
31209
diff
changeset
|
1627 break; |
05763e780521
(skip_chars): Handle negation correctly.
Kenichi Handa <handa@m17n.org>
parents:
31209
diff
changeset
|
1628 } |
05763e780521
(skip_chars): Handle negation correctly.
Kenichi Handa <handa@m17n.org>
parents:
31209
diff
changeset
|
1629 else |
05763e780521
(skip_chars): Handle negation correctly.
Kenichi Handa <handa@m17n.org>
parents:
31209
diff
changeset
|
1630 { |
05763e780521
(skip_chars): Handle negation correctly.
Kenichi Handa <handa@m17n.org>
parents:
31209
diff
changeset
|
1631 /* If we are looking at a multibyte character, |
05763e780521
(skip_chars): Handle negation correctly.
Kenichi Handa <handa@m17n.org>
parents:
31209
diff
changeset
|
1632 we must look up the character in the table |
05763e780521
(skip_chars): Handle negation correctly.
Kenichi Handa <handa@m17n.org>
parents:
31209
diff
changeset
|
1633 CHAR_RANGES. If there's no data in the |
05763e780521
(skip_chars): Handle negation correctly.
Kenichi Handa <handa@m17n.org>
parents:
31209
diff
changeset
|
1634 table, that character is not what we want to |
05763e780521
(skip_chars): Handle negation correctly.
Kenichi Handa <handa@m17n.org>
parents:
31209
diff
changeset
|
1635 skip. */ |
05763e780521
(skip_chars): Handle negation correctly.
Kenichi Handa <handa@m17n.org>
parents:
31209
diff
changeset
|
1636 |
30626
9d47c133b357
* syntax.c (skip_chars): Fix previous change. Make the handling of
Kenichi Handa <handa@m17n.org>
parents:
30596
diff
changeset
|
1637 /* The following code do the right thing even if |
9d47c133b357
* syntax.c (skip_chars): Fix previous change. Make the handling of
Kenichi Handa <handa@m17n.org>
parents:
30596
diff
changeset
|
1638 n_char_ranges is zero (i.e. no data in |
9d47c133b357
* syntax.c (skip_chars): Fix previous change. Make the handling of
Kenichi Handa <handa@m17n.org>
parents:
30596
diff
changeset
|
1639 CHAR_RANGES). */ |
17564
050f15e0b948
(skip_chars): Merge mule changes back in.
Richard M. Stallman <rms@gnu.org>
parents:
17466
diff
changeset
|
1640 for (i = 0; i < n_char_ranges; i += 2) |
30626
9d47c133b357
* syntax.c (skip_chars): Fix previous change. Make the handling of
Kenichi Handa <handa@m17n.org>
parents:
30596
diff
changeset
|
1641 if (c >= char_ranges[i] && c <= char_ranges[i + 1]) |
17564
050f15e0b948
(skip_chars): Merge mule changes back in.
Richard M. Stallman <rms@gnu.org>
parents:
17466
diff
changeset
|
1642 break; |
050f15e0b948
(skip_chars): Merge mule changes back in.
Richard M. Stallman <rms@gnu.org>
parents:
17466
diff
changeset
|
1643 if (!(negate ^ (i < n_char_ranges))) |
050f15e0b948
(skip_chars): Merge mule changes back in.
Richard M. Stallman <rms@gnu.org>
parents:
17466
diff
changeset
|
1644 break; |
050f15e0b948
(skip_chars): Merge mule changes back in.
Richard M. Stallman <rms@gnu.org>
parents:
17466
diff
changeset
|
1645 } |
30626
9d47c133b357
* syntax.c (skip_chars): Fix previous change. Make the handling of
Kenichi Handa <handa@m17n.org>
parents:
30596
diff
changeset
|
1646 INC_BOTH (pos, pos_byte); |
17564
050f15e0b948
(skip_chars): Merge mule changes back in.
Richard M. Stallman <rms@gnu.org>
parents:
17466
diff
changeset
|
1647 } |
050f15e0b948
(skip_chars): Merge mule changes back in.
Richard M. Stallman <rms@gnu.org>
parents:
17466
diff
changeset
|
1648 else |
050f15e0b948
(skip_chars): Merge mule changes back in.
Richard M. Stallman <rms@gnu.org>
parents:
17466
diff
changeset
|
1649 while (pos < XINT (lim) && fastmap[FETCH_BYTE (pos)]) |
050f15e0b948
(skip_chars): Merge mule changes back in.
Richard M. Stallman <rms@gnu.org>
parents:
17466
diff
changeset
|
1650 pos++; |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1651 } |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1652 else |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1653 { |
17564
050f15e0b948
(skip_chars): Merge mule changes back in.
Richard M. Stallman <rms@gnu.org>
parents:
17466
diff
changeset
|
1654 if (multibyte) |
050f15e0b948
(skip_chars): Merge mule changes back in.
Richard M. Stallman <rms@gnu.org>
parents:
17466
diff
changeset
|
1655 while (pos > XINT (lim)) |
050f15e0b948
(skip_chars): Merge mule changes back in.
Richard M. Stallman <rms@gnu.org>
parents:
17466
diff
changeset
|
1656 { |
30626
9d47c133b357
* syntax.c (skip_chars): Fix previous change. Make the handling of
Kenichi Handa <handa@m17n.org>
parents:
30596
diff
changeset
|
1657 int prev_pos_byte = pos_byte; |
9d47c133b357
* syntax.c (skip_chars): Fix previous change. Make the handling of
Kenichi Handa <handa@m17n.org>
parents:
30596
diff
changeset
|
1658 |
9d47c133b357
* syntax.c (skip_chars): Fix previous change. Make the handling of
Kenichi Handa <handa@m17n.org>
parents:
30596
diff
changeset
|
1659 DEC_POS (prev_pos_byte); |
31944
05763e780521
(skip_chars): Handle negation correctly.
Kenichi Handa <handa@m17n.org>
parents:
31209
diff
changeset
|
1660 c = FETCH_MULTIBYTE_CHAR (prev_pos_byte); |
05763e780521
(skip_chars): Handle negation correctly.
Kenichi Handa <handa@m17n.org>
parents:
31209
diff
changeset
|
1661 if (SINGLE_BYTE_CHAR_P (c)) |
17564
050f15e0b948
(skip_chars): Merge mule changes back in.
Richard M. Stallman <rms@gnu.org>
parents:
17466
diff
changeset
|
1662 { |
31944
05763e780521
(skip_chars): Handle negation correctly.
Kenichi Handa <handa@m17n.org>
parents:
31209
diff
changeset
|
1663 if (!fastmap[c]) |
05763e780521
(skip_chars): Handle negation correctly.
Kenichi Handa <handa@m17n.org>
parents:
31209
diff
changeset
|
1664 break; |
05763e780521
(skip_chars): Handle negation correctly.
Kenichi Handa <handa@m17n.org>
parents:
31209
diff
changeset
|
1665 } |
05763e780521
(skip_chars): Handle negation correctly.
Kenichi Handa <handa@m17n.org>
parents:
31209
diff
changeset
|
1666 else |
05763e780521
(skip_chars): Handle negation correctly.
Kenichi Handa <handa@m17n.org>
parents:
31209
diff
changeset
|
1667 { |
05763e780521
(skip_chars): Handle negation correctly.
Kenichi Handa <handa@m17n.org>
parents:
31209
diff
changeset
|
1668 /* See the comment in the previous similar code. */ |
30626
9d47c133b357
* syntax.c (skip_chars): Fix previous change. Make the handling of
Kenichi Handa <handa@m17n.org>
parents:
30596
diff
changeset
|
1669 for (i = 0; i < n_char_ranges; i += 2) |
9d47c133b357
* syntax.c (skip_chars): Fix previous change. Make the handling of
Kenichi Handa <handa@m17n.org>
parents:
30596
diff
changeset
|
1670 if (c >= char_ranges[i] && c <= char_ranges[i + 1]) |
9d47c133b357
* syntax.c (skip_chars): Fix previous change. Make the handling of
Kenichi Handa <handa@m17n.org>
parents:
30596
diff
changeset
|
1671 break; |
9d47c133b357
* syntax.c (skip_chars): Fix previous change. Make the handling of
Kenichi Handa <handa@m17n.org>
parents:
30596
diff
changeset
|
1672 if (!(negate ^ (i < n_char_ranges))) |
9d47c133b357
* syntax.c (skip_chars): Fix previous change. Make the handling of
Kenichi Handa <handa@m17n.org>
parents:
30596
diff
changeset
|
1673 break; |
17564
050f15e0b948
(skip_chars): Merge mule changes back in.
Richard M. Stallman <rms@gnu.org>
parents:
17466
diff
changeset
|
1674 } |
30626
9d47c133b357
* syntax.c (skip_chars): Fix previous change. Make the handling of
Kenichi Handa <handa@m17n.org>
parents:
30596
diff
changeset
|
1675 pos--; |
9d47c133b357
* syntax.c (skip_chars): Fix previous change. Make the handling of
Kenichi Handa <handa@m17n.org>
parents:
30596
diff
changeset
|
1676 pos_byte = prev_pos_byte; |
17564
050f15e0b948
(skip_chars): Merge mule changes back in.
Richard M. Stallman <rms@gnu.org>
parents:
17466
diff
changeset
|
1677 } |
050f15e0b948
(skip_chars): Merge mule changes back in.
Richard M. Stallman <rms@gnu.org>
parents:
17466
diff
changeset
|
1678 else |
050f15e0b948
(skip_chars): Merge mule changes back in.
Richard M. Stallman <rms@gnu.org>
parents:
17466
diff
changeset
|
1679 while (pos > XINT (lim) && fastmap[FETCH_BYTE (pos - 1)]) |
050f15e0b948
(skip_chars): Merge mule changes back in.
Richard M. Stallman <rms@gnu.org>
parents:
17466
diff
changeset
|
1680 pos--; |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1681 } |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1682 } |
17564
050f15e0b948
(skip_chars): Merge mule changes back in.
Richard M. Stallman <rms@gnu.org>
parents:
17466
diff
changeset
|
1683 |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
1684 #if 0 /* Not needed now that a position in mid-character |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
1685 cannot be specified in Lisp. */ |
17564
050f15e0b948
(skip_chars): Merge mule changes back in.
Richard M. Stallman <rms@gnu.org>
parents:
17466
diff
changeset
|
1686 if (multibyte |
050f15e0b948
(skip_chars): Merge mule changes back in.
Richard M. Stallman <rms@gnu.org>
parents:
17466
diff
changeset
|
1687 /* INC_POS or DEC_POS might have moved POS over LIM. */ |
050f15e0b948
(skip_chars): Merge mule changes back in.
Richard M. Stallman <rms@gnu.org>
parents:
17466
diff
changeset
|
1688 && (forwardp ? (pos > XINT (lim)) : (pos < XINT (lim)))) |
050f15e0b948
(skip_chars): Merge mule changes back in.
Richard M. Stallman <rms@gnu.org>
parents:
17466
diff
changeset
|
1689 pos = XINT (lim); |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
1690 #endif |
17564
050f15e0b948
(skip_chars): Merge mule changes back in.
Richard M. Stallman <rms@gnu.org>
parents:
17466
diff
changeset
|
1691 |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
1692 if (! multibyte) |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
1693 pos_byte = pos; |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
1694 |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
1695 SET_PT_BOTH (pos, pos_byte); |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1696 immediate_quit = 0; |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1697 |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1698 return make_number (PT - start_point); |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1699 } |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1700 } |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1701 |
25445
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1702 /* Jump over a comment, assuming we are at the beginning of one. |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1703 FROM is the current position. |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1704 FROM_BYTE is the bytepos corresponding to FROM. |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1705 Do not move past STOP (a charpos). |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1706 The comment over which we have to jump is of style STYLE |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1707 (either SYNTAX_COMMENT_STYLE(foo) or ST_COMMENT_STYLE). |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1708 NESTING should be positive to indicate the nesting at the beginning |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1709 for nested comments and should be zero or negative else. |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1710 ST_COMMENT_STYLE cannot be nested. |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1711 PREV_SYNTAX is the SYNTAX_WITH_FLAGS of the previous character |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1712 (or 0 If the search cannot start in the middle of a two-character). |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1713 |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1714 If successful, return 1 and store the charpos of the comment's end |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1715 into *CHARPOS_PTR and the corresponding bytepos into *BYTEPOS_PTR. |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1716 Else, return 0 and store the charpos STOP into *CHARPOS_PTR, the |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1717 corresponding bytepos into *BYTEPOS_PTR and the current nesting |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1718 (as defined for state.incomment) in *INCOMMENT_PTR. |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1719 |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1720 The comment end is the last character of the comment rather than the |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1721 character just after the comment. |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1722 |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1723 Global syntax data is assumed to initially be valid for FROM and |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1724 remains valid for forward search starting at the returned position. */ |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1725 |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1726 static int |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1727 forw_comment (from, from_byte, stop, nesting, style, prev_syntax, |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1728 charpos_ptr, bytepos_ptr, incomment_ptr) |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1729 int from, from_byte, stop; |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1730 int nesting, style, prev_syntax; |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1731 int *charpos_ptr, *bytepos_ptr, *incomment_ptr; |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1732 { |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1733 register int c, c1; |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1734 register enum syntaxcode code; |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1735 register int syntax; |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1736 |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1737 if (nesting <= 0) nesting = -1; |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1738 |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1739 /* Enter the loop in the middle so that we find |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1740 a 2-char comment ender if we start in the middle of it. */ |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1741 syntax = prev_syntax; |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1742 if (syntax != 0) goto forw_incomment; |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1743 |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1744 while (1) |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1745 { |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1746 if (from == stop) |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1747 { |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1748 *incomment_ptr = nesting; |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1749 *charpos_ptr = from; |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1750 *bytepos_ptr = from_byte; |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1751 return 0; |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1752 } |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1753 c = FETCH_CHAR (from_byte); |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1754 syntax = SYNTAX_WITH_FLAGS (c); |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1755 code = syntax & 0xff; |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1756 if (code == Sendcomment |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1757 && SYNTAX_FLAGS_COMMENT_STYLE (syntax) == style |
32086
73d18e25e303
(forw_comment): Match nestedness of ender/starter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31944
diff
changeset
|
1758 && (SYNTAX_FLAGS_COMMENT_NESTED (syntax) ? |
73d18e25e303
(forw_comment): Match nestedness of ender/starter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31944
diff
changeset
|
1759 (nesting > 0 && --nesting == 0) : nesting < 0)) |
25445
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1760 /* we have encountered a comment end of the same style |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1761 as the comment sequence which began this comment |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1762 section */ |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1763 break; |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1764 if (code == Scomment_fence |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1765 && style == ST_COMMENT_STYLE) |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1766 /* we have encountered a comment end of the same style |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1767 as the comment sequence which began this comment |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1768 section. */ |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1769 break; |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1770 if (nesting > 0 |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1771 && code == Scomment |
32086
73d18e25e303
(forw_comment): Match nestedness of ender/starter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31944
diff
changeset
|
1772 && SYNTAX_FLAGS_COMMENT_NESTED (syntax) |
25445
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1773 && SYNTAX_FLAGS_COMMENT_STYLE (syntax) == style) |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1774 /* we have encountered a nested comment of the same style |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1775 as the comment sequence which began this comment section */ |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1776 nesting++; |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1777 INC_BOTH (from, from_byte); |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1778 UPDATE_SYNTAX_TABLE_FORWARD (from); |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1779 |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1780 forw_incomment: |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1781 if (from < stop && SYNTAX_FLAGS_COMEND_FIRST (syntax) |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1782 && SYNTAX_FLAGS_COMMENT_STYLE (syntax) == style |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1783 && (c1 = FETCH_CHAR (from_byte), |
32086
73d18e25e303
(forw_comment): Match nestedness of ender/starter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31944
diff
changeset
|
1784 SYNTAX_COMEND_SECOND (c1)) |
73d18e25e303
(forw_comment): Match nestedness of ender/starter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31944
diff
changeset
|
1785 && ((SYNTAX_FLAGS_COMMENT_NESTED (syntax) || |
73d18e25e303
(forw_comment): Match nestedness of ender/starter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31944
diff
changeset
|
1786 SYNTAX_COMMENT_NESTED (c1)) ? nesting > 0 : nesting < 0)) |
25771
21925339c7d2
(update_syntax_table, find_defun_start, back_comment,
Gerd Moellmann <gerd@gnu.org>
parents:
25663
diff
changeset
|
1787 { |
21925339c7d2
(update_syntax_table, find_defun_start, back_comment,
Gerd Moellmann <gerd@gnu.org>
parents:
25663
diff
changeset
|
1788 if (--nesting <= 0) |
21925339c7d2
(update_syntax_table, find_defun_start, back_comment,
Gerd Moellmann <gerd@gnu.org>
parents:
25663
diff
changeset
|
1789 /* we have encountered a comment end of the same style |
21925339c7d2
(update_syntax_table, find_defun_start, back_comment,
Gerd Moellmann <gerd@gnu.org>
parents:
25663
diff
changeset
|
1790 as the comment sequence which began this comment |
21925339c7d2
(update_syntax_table, find_defun_start, back_comment,
Gerd Moellmann <gerd@gnu.org>
parents:
25663
diff
changeset
|
1791 section */ |
21925339c7d2
(update_syntax_table, find_defun_start, back_comment,
Gerd Moellmann <gerd@gnu.org>
parents:
25663
diff
changeset
|
1792 break; |
21925339c7d2
(update_syntax_table, find_defun_start, back_comment,
Gerd Moellmann <gerd@gnu.org>
parents:
25663
diff
changeset
|
1793 else |
21925339c7d2
(update_syntax_table, find_defun_start, back_comment,
Gerd Moellmann <gerd@gnu.org>
parents:
25663
diff
changeset
|
1794 { |
21925339c7d2
(update_syntax_table, find_defun_start, back_comment,
Gerd Moellmann <gerd@gnu.org>
parents:
25663
diff
changeset
|
1795 INC_BOTH (from, from_byte); |
21925339c7d2
(update_syntax_table, find_defun_start, back_comment,
Gerd Moellmann <gerd@gnu.org>
parents:
25663
diff
changeset
|
1796 UPDATE_SYNTAX_TABLE_FORWARD (from); |
21925339c7d2
(update_syntax_table, find_defun_start, back_comment,
Gerd Moellmann <gerd@gnu.org>
parents:
25663
diff
changeset
|
1797 } |
21925339c7d2
(update_syntax_table, find_defun_start, back_comment,
Gerd Moellmann <gerd@gnu.org>
parents:
25663
diff
changeset
|
1798 } |
25445
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1799 if (nesting > 0 |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1800 && from < stop |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1801 && SYNTAX_FLAGS_COMSTART_FIRST (syntax) |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1802 && (c1 = FETCH_CHAR (from_byte), |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1803 SYNTAX_COMMENT_STYLE (c1) == style |
32086
73d18e25e303
(forw_comment): Match nestedness of ender/starter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31944
diff
changeset
|
1804 && SYNTAX_COMSTART_SECOND (c1)) |
73d18e25e303
(forw_comment): Match nestedness of ender/starter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31944
diff
changeset
|
1805 && (SYNTAX_FLAGS_COMMENT_NESTED (syntax) || |
73d18e25e303
(forw_comment): Match nestedness of ender/starter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31944
diff
changeset
|
1806 SYNTAX_COMMENT_NESTED (c1))) |
25445
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1807 /* we have encountered a nested comment of the same style |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1808 as the comment sequence which began this comment |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1809 section */ |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1810 { |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1811 INC_BOTH (from, from_byte); |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1812 UPDATE_SYNTAX_TABLE_FORWARD (from); |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1813 nesting++; |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1814 } |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1815 } |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1816 *charpos_ptr = from; |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1817 *bytepos_ptr = from_byte; |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1818 return 1; |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1819 } |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1820 |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
1821 DEFUN ("forward-comment", Fforward_comment, Sforward_comment, 1, 1, 0, |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
1822 "Move forward across up to N comments. If N is negative, move backward.\n\ |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
1823 Stop scanning if we find something other than a comment or whitespace.\n\ |
3568
3ee951a22a80
(Fforward_comment): Set point to where scan stops,
Richard M. Stallman <rms@gnu.org>
parents:
3095
diff
changeset
|
1824 Set point to where scanning stops.\n\ |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
1825 If N comments are found as expected, with nothing except whitespace\n\ |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
1826 between them, return t; otherwise return nil.") |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
1827 (count) |
3095
ef7d99920f81
(Fforward_comment): Arg is a Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
3087
diff
changeset
|
1828 Lisp_Object count; |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
1829 { |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
1830 register int from; |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
1831 int from_byte; |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
1832 register int stop; |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
1833 register int c, c1; |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
1834 register enum syntaxcode code; |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
1835 int comstyle = 0; /* style of comment encountered */ |
25445
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1836 int comnested = 0; /* whether the comment is nestable or not */ |
3087
ea0cb469490e
(Fforward_comment): Fix last change.
Richard M. Stallman <rms@gnu.org>
parents:
3086
diff
changeset
|
1837 int found; |
3095
ef7d99920f81
(Fforward_comment): Arg is a Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
3087
diff
changeset
|
1838 int count1; |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
1839 int out_charpos, out_bytepos; |
25445
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1840 int dummy; |
3095
ef7d99920f81
(Fforward_comment): Arg is a Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
3087
diff
changeset
|
1841 |
ef7d99920f81
(Fforward_comment): Arg is a Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
3087
diff
changeset
|
1842 CHECK_NUMBER (count, 0); |
ef7d99920f81
(Fforward_comment): Arg is a Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
3087
diff
changeset
|
1843 count1 = XINT (count); |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1844 stop = count1 > 0 ? ZV : BEGV; |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
1845 |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
1846 immediate_quit = 1; |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
1847 QUIT; |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
1848 |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
1849 from = PT; |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
1850 from_byte = PT_BYTE; |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
1851 |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1852 SETUP_SYNTAX_TABLE (from, count1); |
3095
ef7d99920f81
(Fforward_comment): Arg is a Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
3087
diff
changeset
|
1853 while (count1 > 0) |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
1854 { |
6142
2dbc79d01191
(Fforward_comment): Do the right thing at eob.
Karl Heuer <kwzh@gnu.org>
parents:
5755
diff
changeset
|
1855 do |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
1856 { |
22370
1f0dc0251be3
(scan_lists): Properly skip the comment-fence character
Richard M. Stallman <rms@gnu.org>
parents:
22130
diff
changeset
|
1857 int comstart_first; |
1f0dc0251be3
(scan_lists): Properly skip the comment-fence character
Richard M. Stallman <rms@gnu.org>
parents:
22130
diff
changeset
|
1858 |
6142
2dbc79d01191
(Fforward_comment): Do the right thing at eob.
Karl Heuer <kwzh@gnu.org>
parents:
5755
diff
changeset
|
1859 if (from == stop) |
2dbc79d01191
(Fforward_comment): Do the right thing at eob.
Karl Heuer <kwzh@gnu.org>
parents:
5755
diff
changeset
|
1860 { |
20905
e646a6ae42cd
(skip_chars): Use INC_POS instead of INC_BOTH.
Richard M. Stallman <rms@gnu.org>
parents:
20766
diff
changeset
|
1861 SET_PT_BOTH (from, from_byte); |
10947
e805ef6b931c
(Fforward_comment): Always clear immediate_quit for return.
Richard M. Stallman <rms@gnu.org>
parents:
10457
diff
changeset
|
1862 immediate_quit = 0; |
6142
2dbc79d01191
(Fforward_comment): Do the right thing at eob.
Karl Heuer <kwzh@gnu.org>
parents:
5755
diff
changeset
|
1863 return Qnil; |
2dbc79d01191
(Fforward_comment): Do the right thing at eob.
Karl Heuer <kwzh@gnu.org>
parents:
5755
diff
changeset
|
1864 } |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
1865 c = FETCH_CHAR (from_byte); |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
1866 code = SYNTAX (c); |
22370
1f0dc0251be3
(scan_lists): Properly skip the comment-fence character
Richard M. Stallman <rms@gnu.org>
parents:
22130
diff
changeset
|
1867 comstart_first = SYNTAX_COMSTART_FIRST (c); |
25445
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1868 comnested = SYNTAX_COMMENT_NESTED (c); |
29821
819dfcbd36c7
(describe_syntax): Recognize the `n'estable bit.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29757
diff
changeset
|
1869 comstyle = SYNTAX_COMMENT_STYLE (c); |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
1870 INC_BOTH (from, from_byte); |
22370
1f0dc0251be3
(scan_lists): Properly skip the comment-fence character
Richard M. Stallman <rms@gnu.org>
parents:
22130
diff
changeset
|
1871 UPDATE_SYNTAX_TABLE_FORWARD (from); |
1f0dc0251be3
(scan_lists): Properly skip the comment-fence character
Richard M. Stallman <rms@gnu.org>
parents:
22130
diff
changeset
|
1872 if (from < stop && comstart_first |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
1873 && (c1 = FETCH_CHAR (from_byte), |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
1874 SYNTAX_COMSTART_SECOND (c1))) |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
1875 { |
4953
7545290052bf
(Fforward_comment): On backward scan, exit inner loop
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
1876 /* We have encountered a comment start sequence and we |
7545290052bf
(Fforward_comment): On backward scan, exit inner loop
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
1877 are ignoring all text inside comments. We must record |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
1878 the comment style this sequence begins so that later, |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
1879 only a comment end of the same style actually ends |
4953
7545290052bf
(Fforward_comment): On backward scan, exit inner loop
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
1880 the comment section. */ |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
1881 code = Scomment; |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
1882 comstyle = SYNTAX_COMMENT_STYLE (c1); |
25445
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1883 comnested = comnested || SYNTAX_COMMENT_NESTED (c1); |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
1884 INC_BOTH (from, from_byte); |
25445
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1885 UPDATE_SYNTAX_TABLE_FORWARD (from); |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
1886 } |
6142
2dbc79d01191
(Fforward_comment): Do the right thing at eob.
Karl Heuer <kwzh@gnu.org>
parents:
5755
diff
changeset
|
1887 } |
32086
73d18e25e303
(forw_comment): Match nestedness of ender/starter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31944
diff
changeset
|
1888 while (code == Swhitespace || (code == Sendcomment && c == '\n')); |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
1889 |
25290
a80acb2a8273
(Fforward_comment): Set comstyle for Scomment_fence.
Karl Heuer <kwzh@gnu.org>
parents:
24728
diff
changeset
|
1890 if (code == Scomment_fence) |
a80acb2a8273
(Fforward_comment): Set comstyle for Scomment_fence.
Karl Heuer <kwzh@gnu.org>
parents:
24728
diff
changeset
|
1891 comstyle = ST_COMMENT_STYLE; |
a80acb2a8273
(Fforward_comment): Set comstyle for Scomment_fence.
Karl Heuer <kwzh@gnu.org>
parents:
24728
diff
changeset
|
1892 else if (code != Scomment) |
6142
2dbc79d01191
(Fforward_comment): Do the right thing at eob.
Karl Heuer <kwzh@gnu.org>
parents:
5755
diff
changeset
|
1893 { |
2dbc79d01191
(Fforward_comment): Do the right thing at eob.
Karl Heuer <kwzh@gnu.org>
parents:
5755
diff
changeset
|
1894 immediate_quit = 0; |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
1895 DEC_BOTH (from, from_byte); |
20905
e646a6ae42cd
(skip_chars): Use INC_POS instead of INC_BOTH.
Richard M. Stallman <rms@gnu.org>
parents:
20766
diff
changeset
|
1896 SET_PT_BOTH (from, from_byte); |
6142
2dbc79d01191
(Fforward_comment): Do the right thing at eob.
Karl Heuer <kwzh@gnu.org>
parents:
5755
diff
changeset
|
1897 return Qnil; |
2dbc79d01191
(Fforward_comment): Do the right thing at eob.
Karl Heuer <kwzh@gnu.org>
parents:
5755
diff
changeset
|
1898 } |
2dbc79d01191
(Fforward_comment): Do the right thing at eob.
Karl Heuer <kwzh@gnu.org>
parents:
5755
diff
changeset
|
1899 /* We're at the start of a comment. */ |
25445
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1900 found = forw_comment (from, from_byte, stop, comnested, comstyle, 0, |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1901 &out_charpos, &out_bytepos, &dummy); |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1902 from = out_charpos; from_byte = out_bytepos; |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1903 if (!found) |
6142
2dbc79d01191
(Fforward_comment): Do the right thing at eob.
Karl Heuer <kwzh@gnu.org>
parents:
5755
diff
changeset
|
1904 { |
25445
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1905 immediate_quit = 0; |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1906 SET_PT_BOTH (from, from_byte); |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1907 return Qnil; |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
1908 } |
25445
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1909 INC_BOTH (from, from_byte); |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1910 UPDATE_SYNTAX_TABLE_FORWARD (from); |
6142
2dbc79d01191
(Fforward_comment): Do the right thing at eob.
Karl Heuer <kwzh@gnu.org>
parents:
5755
diff
changeset
|
1911 /* We have skipped one comment. */ |
3095
ef7d99920f81
(Fforward_comment): Arg is a Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
3087
diff
changeset
|
1912 count1--; |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
1913 } |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
1914 |
3095
ef7d99920f81
(Fforward_comment): Arg is a Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
3087
diff
changeset
|
1915 while (count1 < 0) |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
1916 { |
18938
444939f3c18f
(Fforward_comment): When count1 is negative, return nil if FROM reaches STOP.
Richard M. Stallman <rms@gnu.org>
parents:
18738
diff
changeset
|
1917 while (1) |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
1918 { |
32506
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
1919 int quoted; |
22370
1f0dc0251be3
(scan_lists): Properly skip the comment-fence character
Richard M. Stallman <rms@gnu.org>
parents:
22130
diff
changeset
|
1920 |
18938
444939f3c18f
(Fforward_comment): When count1 is negative, return nil if FROM reaches STOP.
Richard M. Stallman <rms@gnu.org>
parents:
18738
diff
changeset
|
1921 if (from <= stop) |
444939f3c18f
(Fforward_comment): When count1 is negative, return nil if FROM reaches STOP.
Richard M. Stallman <rms@gnu.org>
parents:
18738
diff
changeset
|
1922 { |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
1923 SET_PT_BOTH (BEGV, BEGV_BYTE); |
18938
444939f3c18f
(Fforward_comment): When count1 is negative, return nil if FROM reaches STOP.
Richard M. Stallman <rms@gnu.org>
parents:
18738
diff
changeset
|
1924 immediate_quit = 0; |
444939f3c18f
(Fforward_comment): When count1 is negative, return nil if FROM reaches STOP.
Richard M. Stallman <rms@gnu.org>
parents:
18738
diff
changeset
|
1925 return Qnil; |
444939f3c18f
(Fforward_comment): When count1 is negative, return nil if FROM reaches STOP.
Richard M. Stallman <rms@gnu.org>
parents:
18738
diff
changeset
|
1926 } |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
1927 |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
1928 DEC_BOTH (from, from_byte); |
22370
1f0dc0251be3
(scan_lists): Properly skip the comment-fence character
Richard M. Stallman <rms@gnu.org>
parents:
22130
diff
changeset
|
1929 /* char_quoted does UPDATE_SYNTAX_TABLE_BACKWARD (from). */ |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
1930 quoted = char_quoted (from, from_byte); |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
1931 if (quoted) |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1932 { |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
1933 DEC_BOTH (from, from_byte); |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
1934 goto leave; |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1935 } |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
1936 c = FETCH_CHAR (from_byte); |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
1937 code = SYNTAX (c); |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
1938 comstyle = 0; |
25445
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1939 comnested = SYNTAX_COMMENT_NESTED (c); |
4953
7545290052bf
(Fforward_comment): On backward scan, exit inner loop
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
1940 if (code == Sendcomment) |
7545290052bf
(Fforward_comment): On backward scan, exit inner loop
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
1941 comstyle = SYNTAX_COMMENT_STYLE (c); |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
1942 if (from > stop && SYNTAX_COMEND_SECOND (c) |
22370
1f0dc0251be3
(scan_lists): Properly skip the comment-fence character
Richard M. Stallman <rms@gnu.org>
parents:
22130
diff
changeset
|
1943 && prev_char_comend_first (from, from_byte) |
22432
ac339ec4a12a
(Fforward_comment): Properly compute BYTEPOS arg to char_quoted.
Richard M. Stallman <rms@gnu.org>
parents:
22394
diff
changeset
|
1944 && !char_quoted (from - 1, dec_bytepos (from_byte))) |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
1945 { |
4953
7545290052bf
(Fforward_comment): On backward scan, exit inner loop
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
1946 /* We must record the comment style encountered so that |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
1947 later, we can match only the proper comment begin |
4953
7545290052bf
(Fforward_comment): On backward scan, exit inner loop
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
1948 sequence of the same style. */ |
22370
1f0dc0251be3
(scan_lists): Properly skip the comment-fence character
Richard M. Stallman <rms@gnu.org>
parents:
22130
diff
changeset
|
1949 DEC_BOTH (from, from_byte); |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
1950 code = Sendcomment; |
22370
1f0dc0251be3
(scan_lists): Properly skip the comment-fence character
Richard M. Stallman <rms@gnu.org>
parents:
22130
diff
changeset
|
1951 /* Calling char_quoted, above, set up global syntax position |
1f0dc0251be3
(scan_lists): Properly skip the comment-fence character
Richard M. Stallman <rms@gnu.org>
parents:
22130
diff
changeset
|
1952 at the new value of FROM. */ |
25445
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1953 c1 = FETCH_CHAR (from_byte); |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1954 comstyle = SYNTAX_COMMENT_STYLE (c1); |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1955 comnested = comnested || SYNTAX_COMMENT_NESTED (c1); |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
1956 } |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
1957 |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1958 if (code == Scomment_fence) |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1959 { |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1960 /* Skip until first preceding unquoted comment_fence. */ |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
1961 int found = 0, ini = from, ini_byte = from_byte; |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1962 |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
1963 while (1) |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1964 { |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
1965 DEC_BOTH (from, from_byte); |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
1966 if (from == stop) |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
1967 break; |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1968 UPDATE_SYNTAX_TABLE_BACKWARD (from); |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
1969 c = FETCH_CHAR (from_byte); |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
1970 if (SYNTAX (c) == Scomment_fence |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
1971 && !char_quoted (from, from_byte)) |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1972 { |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1973 found = 1; |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1974 break; |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1975 } |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1976 } |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1977 if (found == 0) |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1978 { |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1979 from = ini; /* Set point to ini + 1. */ |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
1980 from_byte = ini_byte; |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1981 goto leave; |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1982 } |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1983 } |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
1984 else if (code == Sendcomment) |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
1985 { |
25445
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
1986 found = back_comment (from, from_byte, stop, comnested, comstyle, |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
1987 &out_charpos, &out_bytepos); |
27698
9c61956399b2
(back_comment): Make sure we only consider comment-starters
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
27080
diff
changeset
|
1988 if (found == -1) |
9c61956399b2
(back_comment): Make sure we only consider comment-starters
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
27080
diff
changeset
|
1989 { |
32086
73d18e25e303
(forw_comment): Match nestedness of ender/starter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31944
diff
changeset
|
1990 if (c == '\n') |
73d18e25e303
(forw_comment): Match nestedness of ender/starter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31944
diff
changeset
|
1991 /* This end-of-line is not an end-of-comment. |
73d18e25e303
(forw_comment): Match nestedness of ender/starter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31944
diff
changeset
|
1992 Treat it like a whitespace. |
73d18e25e303
(forw_comment): Match nestedness of ender/starter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31944
diff
changeset
|
1993 CC-mode (and maybe others) relies on this behavior. */ |
73d18e25e303
(forw_comment): Match nestedness of ender/starter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31944
diff
changeset
|
1994 ; |
73d18e25e303
(forw_comment): Match nestedness of ender/starter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31944
diff
changeset
|
1995 else |
73d18e25e303
(forw_comment): Match nestedness of ender/starter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31944
diff
changeset
|
1996 { |
73d18e25e303
(forw_comment): Match nestedness of ender/starter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31944
diff
changeset
|
1997 /* Failure: we should go back to the end of this |
73d18e25e303
(forw_comment): Match nestedness of ender/starter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31944
diff
changeset
|
1998 not-quite-endcomment. */ |
73d18e25e303
(forw_comment): Match nestedness of ender/starter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31944
diff
changeset
|
1999 if (SYNTAX(c) != code) |
73d18e25e303
(forw_comment): Match nestedness of ender/starter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31944
diff
changeset
|
2000 /* It was a two-char Sendcomment. */ |
73d18e25e303
(forw_comment): Match nestedness of ender/starter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31944
diff
changeset
|
2001 INC_BOTH (from, from_byte); |
73d18e25e303
(forw_comment): Match nestedness of ender/starter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31944
diff
changeset
|
2002 goto leave; |
73d18e25e303
(forw_comment): Match nestedness of ender/starter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31944
diff
changeset
|
2003 } |
27698
9c61956399b2
(back_comment): Make sure we only consider comment-starters
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
27080
diff
changeset
|
2004 } |
27719
73926d5a4d9f
(Fforward_comment): Undo the previous change, since cc-mode
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
27698
diff
changeset
|
2005 else |
32086
73d18e25e303
(forw_comment): Match nestedness of ender/starter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31944
diff
changeset
|
2006 { |
73d18e25e303
(forw_comment): Match nestedness of ender/starter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31944
diff
changeset
|
2007 /* We have skipped one comment. */ |
73d18e25e303
(forw_comment): Match nestedness of ender/starter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31944
diff
changeset
|
2008 from = out_charpos, from_byte = out_bytepos; |
73d18e25e303
(forw_comment): Match nestedness of ender/starter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31944
diff
changeset
|
2009 break; |
73d18e25e303
(forw_comment): Match nestedness of ender/starter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31944
diff
changeset
|
2010 } |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
2011 } |
32086
73d18e25e303
(forw_comment): Match nestedness of ender/starter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31944
diff
changeset
|
2012 else if (code != Swhitespace) |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
2013 { |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
2014 leave: |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
2015 immediate_quit = 0; |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
2016 INC_BOTH (from, from_byte); |
20905
e646a6ae42cd
(skip_chars): Use INC_POS instead of INC_BOTH.
Richard M. Stallman <rms@gnu.org>
parents:
20766
diff
changeset
|
2017 SET_PT_BOTH (from, from_byte); |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
2018 return Qnil; |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
2019 } |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
2020 } |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
2021 |
3095
ef7d99920f81
(Fforward_comment): Arg is a Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
3087
diff
changeset
|
2022 count1++; |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
2023 } |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
2024 |
20905
e646a6ae42cd
(skip_chars): Use INC_POS instead of INC_BOTH.
Richard M. Stallman <rms@gnu.org>
parents:
20766
diff
changeset
|
2025 SET_PT_BOTH (from, from_byte); |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
2026 immediate_quit = 0; |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
2027 return Qt; |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
2028 } |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
2029 |
27812
e2216823484d
(multibyte_syntax_as_symbol): New variable.
Kenichi Handa <handa@m17n.org>
parents:
27719
diff
changeset
|
2030 /* Return syntax code of character C if C is a single byte character |
38047 | 2031 or `multibyte_symbol_p' is zero. Otherwise, return Ssymbol. */ |
27812
e2216823484d
(multibyte_syntax_as_symbol): New variable.
Kenichi Handa <handa@m17n.org>
parents:
27719
diff
changeset
|
2032 |
e2216823484d
(multibyte_syntax_as_symbol): New variable.
Kenichi Handa <handa@m17n.org>
parents:
27719
diff
changeset
|
2033 #define SYNTAX_WITH_MULTIBYTE_CHECK(c) \ |
e2216823484d
(multibyte_syntax_as_symbol): New variable.
Kenichi Handa <handa@m17n.org>
parents:
27719
diff
changeset
|
2034 ((SINGLE_BYTE_CHAR_P (c) || !multibyte_symbol_p) \ |
e2216823484d
(multibyte_syntax_as_symbol): New variable.
Kenichi Handa <handa@m17n.org>
parents:
27719
diff
changeset
|
2035 ? SYNTAX (c) : Ssymbol) |
e2216823484d
(multibyte_syntax_as_symbol): New variable.
Kenichi Handa <handa@m17n.org>
parents:
27719
diff
changeset
|
2036 |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
2037 static Lisp_Object |
163 | 2038 scan_lists (from, count, depth, sexpflag) |
2039 register int from; | |
2040 int count, depth, sexpflag; | |
2041 { | |
2042 Lisp_Object val; | |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
2043 register int stop = count > 0 ? ZV : BEGV; |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
2044 register int c, c1; |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
2045 int stringterm; |
163 | 2046 int quoted; |
2047 int mathexit = 0; | |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
2048 register enum syntaxcode code, temp_code; |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
2049 int min_depth = depth; /* Err out if depth gets less than this. */ |
1085
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
2050 int comstyle = 0; /* style of comment encountered */ |
25445
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
2051 int comnested = 0; /* whether the comment is nestable or not */ |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
2052 int temp_pos; |
16992
ff7346c31184
(scan_lists): Signal errors using scan-error.
Richard M. Stallman <rms@gnu.org>
parents:
16039
diff
changeset
|
2053 int last_good = from; |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
2054 int found; |
23404
529689c4a32c
(scan_lists): Bring FROM back into range BEGV...ZV.
Richard M. Stallman <rms@gnu.org>
parents:
22994
diff
changeset
|
2055 int from_byte; |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
2056 int out_bytepos, out_charpos; |
25445
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
2057 int temp, dummy; |
27812
e2216823484d
(multibyte_syntax_as_symbol): New variable.
Kenichi Handa <handa@m17n.org>
parents:
27719
diff
changeset
|
2058 int multibyte_symbol_p = sexpflag && multibyte_syntax_as_symbol; |
163 | 2059 |
2060 if (depth > 0) min_depth = 0; | |
2061 | |
23404
529689c4a32c
(scan_lists): Bring FROM back into range BEGV...ZV.
Richard M. Stallman <rms@gnu.org>
parents:
22994
diff
changeset
|
2062 if (from > ZV) from = ZV; |
529689c4a32c
(scan_lists): Bring FROM back into range BEGV...ZV.
Richard M. Stallman <rms@gnu.org>
parents:
22994
diff
changeset
|
2063 if (from < BEGV) from = BEGV; |
529689c4a32c
(scan_lists): Bring FROM back into range BEGV...ZV.
Richard M. Stallman <rms@gnu.org>
parents:
22994
diff
changeset
|
2064 |
529689c4a32c
(scan_lists): Bring FROM back into range BEGV...ZV.
Richard M. Stallman <rms@gnu.org>
parents:
22994
diff
changeset
|
2065 from_byte = CHAR_TO_BYTE (from); |
529689c4a32c
(scan_lists): Bring FROM back into range BEGV...ZV.
Richard M. Stallman <rms@gnu.org>
parents:
22994
diff
changeset
|
2066 |
163 | 2067 immediate_quit = 1; |
2068 QUIT; | |
2069 | |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
2070 SETUP_SYNTAX_TABLE (from, count); |
163 | 2071 while (count > 0) |
2072 { | |
2073 while (from < stop) | |
2074 { | |
22370
1f0dc0251be3
(scan_lists): Properly skip the comment-fence character
Richard M. Stallman <rms@gnu.org>
parents:
22130
diff
changeset
|
2075 int comstart_first, prefix; |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
2076 UPDATE_SYNTAX_TABLE_FORWARD (from); |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
2077 c = FETCH_CHAR (from_byte); |
27812
e2216823484d
(multibyte_syntax_as_symbol): New variable.
Kenichi Handa <handa@m17n.org>
parents:
27719
diff
changeset
|
2078 code = SYNTAX_WITH_MULTIBYTE_CHECK (c); |
22370
1f0dc0251be3
(scan_lists): Properly skip the comment-fence character
Richard M. Stallman <rms@gnu.org>
parents:
22130
diff
changeset
|
2079 comstart_first = SYNTAX_COMSTART_FIRST (c); |
25445
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
2080 comnested = SYNTAX_COMMENT_NESTED (c); |
29821
819dfcbd36c7
(describe_syntax): Recognize the `n'estable bit.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29757
diff
changeset
|
2081 comstyle = SYNTAX_COMMENT_STYLE (c); |
22370
1f0dc0251be3
(scan_lists): Properly skip the comment-fence character
Richard M. Stallman <rms@gnu.org>
parents:
22130
diff
changeset
|
2082 prefix = SYNTAX_PREFIX (c); |
16992
ff7346c31184
(scan_lists): Signal errors using scan-error.
Richard M. Stallman <rms@gnu.org>
parents:
16039
diff
changeset
|
2083 if (depth == min_depth) |
ff7346c31184
(scan_lists): Signal errors using scan-error.
Richard M. Stallman <rms@gnu.org>
parents:
16039
diff
changeset
|
2084 last_good = from; |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
2085 INC_BOTH (from, from_byte); |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
2086 UPDATE_SYNTAX_TABLE_FORWARD (from); |
22370
1f0dc0251be3
(scan_lists): Properly skip the comment-fence character
Richard M. Stallman <rms@gnu.org>
parents:
22130
diff
changeset
|
2087 if (from < stop && comstart_first |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
2088 && SYNTAX_COMSTART_SECOND (FETCH_CHAR (from_byte)) |
163 | 2089 && parse_sexp_ignore_comments) |
1085
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
2090 { |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
2091 /* we have encountered a comment start sequence and we |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
2092 are ignoring all text inside comments. We must record |
1085
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
2093 the comment style this sequence begins so that later, |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
2094 only a comment end of the same style actually ends |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
2095 the comment section */ |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
2096 code = Scomment; |
25445
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
2097 c1 = FETCH_CHAR (from_byte); |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
2098 comstyle = SYNTAX_COMMENT_STYLE (c1); |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
2099 comnested = comnested || SYNTAX_COMMENT_NESTED (c1); |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
2100 INC_BOTH (from, from_byte); |
22370
1f0dc0251be3
(scan_lists): Properly skip the comment-fence character
Richard M. Stallman <rms@gnu.org>
parents:
22130
diff
changeset
|
2101 UPDATE_SYNTAX_TABLE_FORWARD (from); |
1085
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
2102 } |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
2103 |
22370
1f0dc0251be3
(scan_lists): Properly skip the comment-fence character
Richard M. Stallman <rms@gnu.org>
parents:
22130
diff
changeset
|
2104 if (prefix) |
163 | 2105 continue; |
2106 | |
10457
2ab3bd0288a9
Change all occurences of SWITCH_ENUM_BUG to use SWITCH_ENUM_CAST instead.
Karl Heuer <kwzh@gnu.org>
parents:
9863
diff
changeset
|
2107 switch (SWITCH_ENUM_CAST (code)) |
163 | 2108 { |
2109 case Sescape: | |
2110 case Scharquote: | |
2111 if (from == stop) goto lose; | |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
2112 INC_BOTH (from, from_byte); |
163 | 2113 /* treat following character as a word constituent */ |
2114 case Sword: | |
2115 case Ssymbol: | |
2116 if (depth || !sexpflag) break; | |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
2117 /* This word counts as a sexp; return at end of it. */ |
163 | 2118 while (from < stop) |
2119 { | |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
2120 UPDATE_SYNTAX_TABLE_FORWARD (from); |
22006
31c39cdc9e11
(scan_lists, scan_sexps_forward): Move complex expressions
Richard M. Stallman <rms@gnu.org>
parents:
21514
diff
changeset
|
2121 |
31c39cdc9e11
(scan_lists, scan_sexps_forward): Move complex expressions
Richard M. Stallman <rms@gnu.org>
parents:
21514
diff
changeset
|
2122 /* Some compilers can't handle this inside the switch. */ |
27812
e2216823484d
(multibyte_syntax_as_symbol): New variable.
Kenichi Handa <handa@m17n.org>
parents:
27719
diff
changeset
|
2123 c = FETCH_CHAR (from_byte); |
e2216823484d
(multibyte_syntax_as_symbol): New variable.
Kenichi Handa <handa@m17n.org>
parents:
27719
diff
changeset
|
2124 temp = SYNTAX_WITH_MULTIBYTE_CHECK (c); |
22006
31c39cdc9e11
(scan_lists, scan_sexps_forward): Move complex expressions
Richard M. Stallman <rms@gnu.org>
parents:
21514
diff
changeset
|
2125 switch (temp) |
163 | 2126 { |
2127 case Scharquote: | |
2128 case Sescape: | |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
2129 INC_BOTH (from, from_byte); |
163 | 2130 if (from == stop) goto lose; |
2131 break; | |
2132 case Sword: | |
2133 case Ssymbol: | |
2134 case Squote: | |
2135 break; | |
2136 default: | |
2137 goto done; | |
2138 } | |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
2139 INC_BOTH (from, from_byte); |
163 | 2140 } |
2141 goto done; | |
2142 | |
25445
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
2143 case Scomment_fence: |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
2144 comstyle = ST_COMMENT_STYLE; |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
2145 /* FALLTHROUGH */ |
163 | 2146 case Scomment: |
2147 if (!parse_sexp_ignore_comments) break; | |
25445
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
2148 UPDATE_SYNTAX_TABLE_FORWARD (from); |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
2149 found = forw_comment (from, from_byte, stop, |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
2150 comnested, comstyle, 0, |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
2151 &out_charpos, &out_bytepos, &dummy); |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
2152 from = out_charpos, from_byte = out_bytepos; |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
2153 if (!found) |
163 | 2154 { |
25445
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
2155 if (depth == 0) |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
2156 goto done; |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
2157 goto lose; |
163 | 2158 } |
25445
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
2159 INC_BOTH (from, from_byte); |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
2160 UPDATE_SYNTAX_TABLE_FORWARD (from); |
163 | 2161 break; |
2162 | |
2163 case Smath: | |
2164 if (!sexpflag) | |
2165 break; | |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
2166 if (from != stop && c == FETCH_CHAR (from_byte)) |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
2167 { |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
2168 INC_BOTH (from, from_byte); |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
2169 } |
163 | 2170 if (mathexit) |
2171 { | |
2172 mathexit = 0; | |
2173 goto close1; | |
2174 } | |
2175 mathexit = 1; | |
2176 | |
2177 case Sopen: | |
2178 if (!++depth) goto done; | |
2179 break; | |
2180 | |
2181 case Sclose: | |
2182 close1: | |
2183 if (!--depth) goto done; | |
2184 if (depth < min_depth) | |
16992
ff7346c31184
(scan_lists): Signal errors using scan-error.
Richard M. Stallman <rms@gnu.org>
parents:
16039
diff
changeset
|
2185 Fsignal (Qscan_error, |
ff7346c31184
(scan_lists): Signal errors using scan-error.
Richard M. Stallman <rms@gnu.org>
parents:
16039
diff
changeset
|
2186 Fcons (build_string ("Containing expression ends prematurely"), |
ff7346c31184
(scan_lists): Signal errors using scan-error.
Richard M. Stallman <rms@gnu.org>
parents:
16039
diff
changeset
|
2187 Fcons (make_number (last_good), |
ff7346c31184
(scan_lists): Signal errors using scan-error.
Richard M. Stallman <rms@gnu.org>
parents:
16039
diff
changeset
|
2188 Fcons (make_number (from), Qnil)))); |
163 | 2189 break; |
2190 | |
2191 case Sstring: | |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
2192 case Sstring_fence: |
20905
e646a6ae42cd
(skip_chars): Use INC_POS instead of INC_BOTH.
Richard M. Stallman <rms@gnu.org>
parents:
20766
diff
changeset
|
2193 temp_pos = dec_bytepos (from_byte); |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
2194 stringterm = FETCH_CHAR (temp_pos); |
163 | 2195 while (1) |
2196 { | |
2197 if (from >= stop) goto lose; | |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
2198 UPDATE_SYNTAX_TABLE_FORWARD (from); |
27812
e2216823484d
(multibyte_syntax_as_symbol): New variable.
Kenichi Handa <handa@m17n.org>
parents:
27719
diff
changeset
|
2199 c = FETCH_CHAR (from_byte); |
34398
945b3e6bf3e7
(scan_lists): Check that the right quote char has the
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32794
diff
changeset
|
2200 if (code == Sstring |
945b3e6bf3e7
(scan_lists): Check that the right quote char has the
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32794
diff
changeset
|
2201 ? (c == stringterm |
945b3e6bf3e7
(scan_lists): Check that the right quote char has the
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32794
diff
changeset
|
2202 && SYNTAX_WITH_MULTIBYTE_CHECK (c) == Sstring) |
27812
e2216823484d
(multibyte_syntax_as_symbol): New variable.
Kenichi Handa <handa@m17n.org>
parents:
27719
diff
changeset
|
2203 : SYNTAX_WITH_MULTIBYTE_CHECK (c) == Sstring_fence) |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
2204 break; |
22006
31c39cdc9e11
(scan_lists, scan_sexps_forward): Move complex expressions
Richard M. Stallman <rms@gnu.org>
parents:
21514
diff
changeset
|
2205 |
31c39cdc9e11
(scan_lists, scan_sexps_forward): Move complex expressions
Richard M. Stallman <rms@gnu.org>
parents:
21514
diff
changeset
|
2206 /* Some compilers can't handle this inside the switch. */ |
27812
e2216823484d
(multibyte_syntax_as_symbol): New variable.
Kenichi Handa <handa@m17n.org>
parents:
27719
diff
changeset
|
2207 temp = SYNTAX_WITH_MULTIBYTE_CHECK (c); |
22006
31c39cdc9e11
(scan_lists, scan_sexps_forward): Move complex expressions
Richard M. Stallman <rms@gnu.org>
parents:
21514
diff
changeset
|
2208 switch (temp) |
163 | 2209 { |
2210 case Scharquote: | |
2211 case Sescape: | |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
2212 INC_BOTH (from, from_byte); |
163 | 2213 } |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
2214 INC_BOTH (from, from_byte); |
163 | 2215 } |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
2216 INC_BOTH (from, from_byte); |
163 | 2217 if (!depth && sexpflag) goto done; |
2218 break; | |
2219 } | |
2220 } | |
2221 | |
2222 /* Reached end of buffer. Error if within object, return nil if between */ | |
2223 if (depth) goto lose; | |
2224 | |
2225 immediate_quit = 0; | |
2226 return Qnil; | |
2227 | |
2228 /* End of object reached */ | |
2229 done: | |
2230 count--; | |
2231 } | |
2232 | |
2233 while (count < 0) | |
2234 { | |
2235 while (from > stop) | |
2236 { | |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
2237 DEC_BOTH (from, from_byte); |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
2238 UPDATE_SYNTAX_TABLE_BACKWARD (from); |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
2239 c = FETCH_CHAR (from_byte); |
27812
e2216823484d
(multibyte_syntax_as_symbol): New variable.
Kenichi Handa <handa@m17n.org>
parents:
27719
diff
changeset
|
2240 code = SYNTAX_WITH_MULTIBYTE_CHECK (c); |
16992
ff7346c31184
(scan_lists): Signal errors using scan-error.
Richard M. Stallman <rms@gnu.org>
parents:
16039
diff
changeset
|
2241 if (depth == min_depth) |
ff7346c31184
(scan_lists): Signal errors using scan-error.
Richard M. Stallman <rms@gnu.org>
parents:
16039
diff
changeset
|
2242 last_good = from; |
4953
7545290052bf
(Fforward_comment): On backward scan, exit inner loop
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
2243 comstyle = 0; |
25445
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
2244 comnested = SYNTAX_COMMENT_NESTED (c); |
4953
7545290052bf
(Fforward_comment): On backward scan, exit inner loop
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
2245 if (code == Sendcomment) |
7545290052bf
(Fforward_comment): On backward scan, exit inner loop
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
2246 comstyle = SYNTAX_COMMENT_STYLE (c); |
163 | 2247 if (from > stop && SYNTAX_COMEND_SECOND (c) |
22486
a28020246db1
(skip_chars): Don't examine STRING before verifying that it is a string.
Richard M. Stallman <rms@gnu.org>
parents:
22432
diff
changeset
|
2248 && prev_char_comend_first (from, from_byte) |
163 | 2249 && parse_sexp_ignore_comments) |
1085
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
2250 { |
22370
1f0dc0251be3
(scan_lists): Properly skip the comment-fence character
Richard M. Stallman <rms@gnu.org>
parents:
22130
diff
changeset
|
2251 /* We must record the comment style encountered so that |
1085
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
2252 later, we can match only the proper comment begin |
22370
1f0dc0251be3
(scan_lists): Properly skip the comment-fence character
Richard M. Stallman <rms@gnu.org>
parents:
22130
diff
changeset
|
2253 sequence of the same style. */ |
1f0dc0251be3
(scan_lists): Properly skip the comment-fence character
Richard M. Stallman <rms@gnu.org>
parents:
22130
diff
changeset
|
2254 DEC_BOTH (from, from_byte); |
1f0dc0251be3
(scan_lists): Properly skip the comment-fence character
Richard M. Stallman <rms@gnu.org>
parents:
22130
diff
changeset
|
2255 UPDATE_SYNTAX_TABLE_BACKWARD (from); |
1085
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
2256 code = Sendcomment; |
25445
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
2257 c1 = FETCH_CHAR (from_byte); |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
2258 comstyle = SYNTAX_COMMENT_STYLE (c1); |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
2259 comnested = comnested || SYNTAX_COMMENT_NESTED (c1); |
1085
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
2260 } |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
2261 |
20674
fa7d4c0ee36c
(skip_chars): Fix test for end of string, looking for `-'.
Karl Heuer <kwzh@gnu.org>
parents:
20626
diff
changeset
|
2262 /* Quoting turns anything except a comment-ender |
29821
819dfcbd36c7
(describe_syntax): Recognize the `n'estable bit.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29757
diff
changeset
|
2263 into a word character. Note that this cannot be true |
22370
1f0dc0251be3
(scan_lists): Properly skip the comment-fence character
Richard M. Stallman <rms@gnu.org>
parents:
22130
diff
changeset
|
2264 if we decremented FROM in the if-statement above. */ |
20674
fa7d4c0ee36c
(skip_chars): Fix test for end of string, looking for `-'.
Karl Heuer <kwzh@gnu.org>
parents:
20626
diff
changeset
|
2265 if (code != Sendcomment && char_quoted (from, from_byte)) |
fa7d4c0ee36c
(skip_chars): Fix test for end of string, looking for `-'.
Karl Heuer <kwzh@gnu.org>
parents:
20626
diff
changeset
|
2266 code = Sword; |
fa7d4c0ee36c
(skip_chars): Fix test for end of string, looking for `-'.
Karl Heuer <kwzh@gnu.org>
parents:
20626
diff
changeset
|
2267 else if (SYNTAX_PREFIX (c)) |
163 | 2268 continue; |
2269 | |
20674
fa7d4c0ee36c
(skip_chars): Fix test for end of string, looking for `-'.
Karl Heuer <kwzh@gnu.org>
parents:
20626
diff
changeset
|
2270 switch (SWITCH_ENUM_CAST (code)) |
163 | 2271 { |
2272 case Sword: | |
2273 case Ssymbol: | |
20674
fa7d4c0ee36c
(skip_chars): Fix test for end of string, looking for `-'.
Karl Heuer <kwzh@gnu.org>
parents:
20626
diff
changeset
|
2274 case Sescape: |
fa7d4c0ee36c
(skip_chars): Fix test for end of string, looking for `-'.
Karl Heuer <kwzh@gnu.org>
parents:
20626
diff
changeset
|
2275 case Scharquote: |
163 | 2276 if (depth || !sexpflag) break; |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
2277 /* This word counts as a sexp; count object finished |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
2278 after passing it. */ |
163 | 2279 while (from > stop) |
2280 { | |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
2281 temp_pos = from_byte; |
20905
e646a6ae42cd
(skip_chars): Use INC_POS instead of INC_BOTH.
Richard M. Stallman <rms@gnu.org>
parents:
20766
diff
changeset
|
2282 if (! NILP (current_buffer->enable_multibyte_characters)) |
e646a6ae42cd
(skip_chars): Use INC_POS instead of INC_BOTH.
Richard M. Stallman <rms@gnu.org>
parents:
20766
diff
changeset
|
2283 DEC_POS (temp_pos); |
e646a6ae42cd
(skip_chars): Use INC_POS instead of INC_BOTH.
Richard M. Stallman <rms@gnu.org>
parents:
20766
diff
changeset
|
2284 else |
e646a6ae42cd
(skip_chars): Use INC_POS instead of INC_BOTH.
Richard M. Stallman <rms@gnu.org>
parents:
20766
diff
changeset
|
2285 temp_pos--; |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
2286 UPDATE_SYNTAX_TABLE_BACKWARD (from - 1); |
20674
fa7d4c0ee36c
(skip_chars): Fix test for end of string, looking for `-'.
Karl Heuer <kwzh@gnu.org>
parents:
20626
diff
changeset
|
2287 c1 = FETCH_CHAR (temp_pos); |
27812
e2216823484d
(multibyte_syntax_as_symbol): New variable.
Kenichi Handa <handa@m17n.org>
parents:
27719
diff
changeset
|
2288 temp_code = SYNTAX_WITH_MULTIBYTE_CHECK (c1); |
20674
fa7d4c0ee36c
(skip_chars): Fix test for end of string, looking for `-'.
Karl Heuer <kwzh@gnu.org>
parents:
20626
diff
changeset
|
2289 /* Don't allow comment-end to be quoted. */ |
fa7d4c0ee36c
(skip_chars): Fix test for end of string, looking for `-'.
Karl Heuer <kwzh@gnu.org>
parents:
20626
diff
changeset
|
2290 if (temp_code == Sendcomment) |
fa7d4c0ee36c
(skip_chars): Fix test for end of string, looking for `-'.
Karl Heuer <kwzh@gnu.org>
parents:
20626
diff
changeset
|
2291 goto done2; |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
2292 quoted = char_quoted (from - 1, temp_pos); |
163 | 2293 if (quoted) |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
2294 { |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
2295 DEC_BOTH (from, from_byte); |
20905
e646a6ae42cd
(skip_chars): Use INC_POS instead of INC_BOTH.
Richard M. Stallman <rms@gnu.org>
parents:
20766
diff
changeset
|
2296 temp_pos = dec_bytepos (temp_pos); |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
2297 UPDATE_SYNTAX_TABLE_BACKWARD (from - 1); |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
2298 } |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
2299 c1 = FETCH_CHAR (temp_pos); |
27812
e2216823484d
(multibyte_syntax_as_symbol): New variable.
Kenichi Handa <handa@m17n.org>
parents:
27719
diff
changeset
|
2300 temp_code = SYNTAX_WITH_MULTIBYTE_CHECK (c1); |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
2301 if (! (quoted || temp_code == Sword |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
2302 || temp_code == Ssymbol |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
2303 || temp_code == Squote)) |
163 | 2304 goto done2; |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
2305 DEC_BOTH (from, from_byte); |
163 | 2306 } |
2307 goto done2; | |
2308 | |
2309 case Smath: | |
2310 if (!sexpflag) | |
2311 break; | |
20905
e646a6ae42cd
(skip_chars): Use INC_POS instead of INC_BOTH.
Richard M. Stallman <rms@gnu.org>
parents:
20766
diff
changeset
|
2312 temp_pos = dec_bytepos (from_byte); |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
2313 UPDATE_SYNTAX_TABLE_BACKWARD (from - 1); |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
2314 if (from != stop && c == FETCH_CHAR (temp_pos)) |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
2315 DEC_BOTH (from, from_byte); |
163 | 2316 if (mathexit) |
2317 { | |
2318 mathexit = 0; | |
2319 goto open2; | |
2320 } | |
2321 mathexit = 1; | |
2322 | |
2323 case Sclose: | |
2324 if (!++depth) goto done2; | |
2325 break; | |
2326 | |
2327 case Sopen: | |
2328 open2: | |
2329 if (!--depth) goto done2; | |
2330 if (depth < min_depth) | |
16992
ff7346c31184
(scan_lists): Signal errors using scan-error.
Richard M. Stallman <rms@gnu.org>
parents:
16039
diff
changeset
|
2331 Fsignal (Qscan_error, |
ff7346c31184
(scan_lists): Signal errors using scan-error.
Richard M. Stallman <rms@gnu.org>
parents:
16039
diff
changeset
|
2332 Fcons (build_string ("Containing expression ends prematurely"), |
ff7346c31184
(scan_lists): Signal errors using scan-error.
Richard M. Stallman <rms@gnu.org>
parents:
16039
diff
changeset
|
2333 Fcons (make_number (last_good), |
ff7346c31184
(scan_lists): Signal errors using scan-error.
Richard M. Stallman <rms@gnu.org>
parents:
16039
diff
changeset
|
2334 Fcons (make_number (from), Qnil)))); |
163 | 2335 break; |
2336 | |
2337 case Sendcomment: | |
2338 if (!parse_sexp_ignore_comments) | |
2339 break; | |
25445
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
2340 found = back_comment (from, from_byte, stop, comnested, comstyle, |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
2341 &out_charpos, &out_bytepos); |
27698
9c61956399b2
(back_comment): Make sure we only consider comment-starters
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
27080
diff
changeset
|
2342 /* FIXME: if found == -1, then it really wasn't a comment-end. |
9c61956399b2
(back_comment): Make sure we only consider comment-starters
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
27080
diff
changeset
|
2343 For single-char Sendcomment, we can't do much about it apart |
9c61956399b2
(back_comment): Make sure we only consider comment-starters
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
27080
diff
changeset
|
2344 from skipping the char. |
9c61956399b2
(back_comment): Make sure we only consider comment-starters
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
27080
diff
changeset
|
2345 For 2-char endcomments, we could try again, taking both |
9c61956399b2
(back_comment): Make sure we only consider comment-starters
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
27080
diff
changeset
|
2346 chars as separate entities, but it's a lot of trouble |
9c61956399b2
(back_comment): Make sure we only consider comment-starters
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
27080
diff
changeset
|
2347 for very little gain, so we don't bother either. -sm */ |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
2348 if (found != -1) |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
2349 from = out_charpos, from_byte = out_bytepos; |
163 | 2350 break; |
2351 | |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
2352 case Scomment_fence: |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
2353 case Sstring_fence: |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
2354 while (1) |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
2355 { |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
2356 DEC_BOTH (from, from_byte); |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
2357 if (from == stop) goto lose; |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
2358 UPDATE_SYNTAX_TABLE_BACKWARD (from); |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
2359 if (!char_quoted (from, from_byte) |
27812
e2216823484d
(multibyte_syntax_as_symbol): New variable.
Kenichi Handa <handa@m17n.org>
parents:
27719
diff
changeset
|
2360 && (c = FETCH_CHAR (from_byte), |
e2216823484d
(multibyte_syntax_as_symbol): New variable.
Kenichi Handa <handa@m17n.org>
parents:
27719
diff
changeset
|
2361 SYNTAX_WITH_MULTIBYTE_CHECK (c) == code)) |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
2362 break; |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
2363 } |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
2364 if (code == Sstring_fence && !depth && sexpflag) goto done2; |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
2365 break; |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
2366 |
163 | 2367 case Sstring: |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
2368 stringterm = FETCH_CHAR (from_byte); |
163 | 2369 while (1) |
2370 { | |
2371 if (from == stop) goto lose; | |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
2372 temp_pos = from_byte; |
20905
e646a6ae42cd
(skip_chars): Use INC_POS instead of INC_BOTH.
Richard M. Stallman <rms@gnu.org>
parents:
20766
diff
changeset
|
2373 if (! NILP (current_buffer->enable_multibyte_characters)) |
e646a6ae42cd
(skip_chars): Use INC_POS instead of INC_BOTH.
Richard M. Stallman <rms@gnu.org>
parents:
20766
diff
changeset
|
2374 DEC_POS (temp_pos); |
e646a6ae42cd
(skip_chars): Use INC_POS instead of INC_BOTH.
Richard M. Stallman <rms@gnu.org>
parents:
20766
diff
changeset
|
2375 else |
e646a6ae42cd
(skip_chars): Use INC_POS instead of INC_BOTH.
Richard M. Stallman <rms@gnu.org>
parents:
20766
diff
changeset
|
2376 temp_pos--; |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
2377 UPDATE_SYNTAX_TABLE_BACKWARD (from - 1); |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
2378 if (!char_quoted (from - 1, temp_pos) |
34398
945b3e6bf3e7
(scan_lists): Check that the right quote char has the
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32794
diff
changeset
|
2379 && stringterm == (c = FETCH_CHAR (temp_pos)) |
945b3e6bf3e7
(scan_lists): Check that the right quote char has the
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32794
diff
changeset
|
2380 && SYNTAX_WITH_MULTIBYTE_CHECK (c) == Sstring) |
163 | 2381 break; |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
2382 DEC_BOTH (from, from_byte); |
163 | 2383 } |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
2384 DEC_BOTH (from, from_byte); |
163 | 2385 if (!depth && sexpflag) goto done2; |
2386 break; | |
2387 } | |
2388 } | |
2389 | |
2390 /* Reached start of buffer. Error if within object, return nil if between */ | |
2391 if (depth) goto lose; | |
2392 | |
2393 immediate_quit = 0; | |
2394 return Qnil; | |
2395 | |
2396 done2: | |
2397 count++; | |
2398 } | |
2399 | |
2400 | |
2401 immediate_quit = 0; | |
9320
4be3f8f9f090
(Fcopy_syntax_table, Fmodify_syntax_entry, scan_lists, init_syntax_once):
Karl Heuer <kwzh@gnu.org>
parents:
9111
diff
changeset
|
2402 XSETFASTINT (val, from); |
163 | 2403 return val; |
2404 | |
2405 lose: | |
16992
ff7346c31184
(scan_lists): Signal errors using scan-error.
Richard M. Stallman <rms@gnu.org>
parents:
16039
diff
changeset
|
2406 Fsignal (Qscan_error, |
ff7346c31184
(scan_lists): Signal errors using scan-error.
Richard M. Stallman <rms@gnu.org>
parents:
16039
diff
changeset
|
2407 Fcons (build_string ("Unbalanced parentheses"), |
ff7346c31184
(scan_lists): Signal errors using scan-error.
Richard M. Stallman <rms@gnu.org>
parents:
16039
diff
changeset
|
2408 Fcons (make_number (last_good), |
ff7346c31184
(scan_lists): Signal errors using scan-error.
Richard M. Stallman <rms@gnu.org>
parents:
16039
diff
changeset
|
2409 Fcons (make_number (from), Qnil)))); |
ff7346c31184
(scan_lists): Signal errors using scan-error.
Richard M. Stallman <rms@gnu.org>
parents:
16039
diff
changeset
|
2410 |
163 | 2411 /* NOTREACHED */ |
2412 } | |
2413 | |
2414 DEFUN ("scan-lists", Fscan_lists, Sscan_lists, 3, 3, 0, | |
2415 "Scan from character number FROM by COUNT lists.\n\ | |
2416 Returns the character number of the position thus found.\n\ | |
2417 \n\ | |
2418 If DEPTH is nonzero, paren depth begins counting from that value,\n\ | |
2419 only places where the depth in parentheses becomes zero\n\ | |
2420 are candidates for stopping; COUNT such places are counted.\n\ | |
2421 Thus, a positive value for DEPTH means go out levels.\n\ | |
2422 \n\ | |
2423 Comments are ignored if `parse-sexp-ignore-comments' is non-nil.\n\ | |
2424 \n\ | |
2425 If the beginning or end of (the accessible part of) the buffer is reached\n\ | |
2426 and the depth is wrong, an error is signaled.\n\ | |
2427 If the depth is right but the count is not used up, nil is returned.") | |
2428 (from, count, depth) | |
2429 Lisp_Object from, count, depth; | |
2430 { | |
2431 CHECK_NUMBER (from, 0); | |
2432 CHECK_NUMBER (count, 1); | |
2433 CHECK_NUMBER (depth, 2); | |
2434 | |
2435 return scan_lists (XINT (from), XINT (count), XINT (depth), 0); | |
2436 } | |
2437 | |
2438 DEFUN ("scan-sexps", Fscan_sexps, Sscan_sexps, 2, 2, 0, | |
2439 "Scan from character number FROM by COUNT balanced expressions.\n\ | |
2440 If COUNT is negative, scan backwards.\n\ | |
2441 Returns the character number of the position thus found.\n\ | |
2442 \n\ | |
2443 Comments are ignored if `parse-sexp-ignore-comments' is non-nil.\n\ | |
2444 \n\ | |
2445 If the beginning or end of (the accessible part of) the buffer is reached\n\ | |
2446 in the middle of a parenthetical grouping, an error is signaled.\n\ | |
2447 If the beginning or end is reached between groupings\n\ | |
2448 but before count is used up, nil is returned.") | |
2449 (from, count) | |
2450 Lisp_Object from, count; | |
2451 { | |
2452 CHECK_NUMBER (from, 0); | |
2453 CHECK_NUMBER (count, 1); | |
2454 | |
2455 return scan_lists (XINT (from), XINT (count), 0, 1); | |
2456 } | |
2457 | |
2458 DEFUN ("backward-prefix-chars", Fbackward_prefix_chars, Sbackward_prefix_chars, | |
2459 0, 0, 0, | |
2460 "Move point backward over any number of chars with prefix syntax.\n\ | |
2461 This includes chars with \"quote\" or \"prefix\" syntax (' or p).") | |
2462 () | |
2463 { | |
2464 int beg = BEGV; | |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
2465 int opoint = PT; |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
2466 int opoint_byte = PT_BYTE; |
16039
855c8d8ba0f0
Change all references from point to PT.
Karl Heuer <kwzh@gnu.org>
parents:
14661
diff
changeset
|
2467 int pos = PT; |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
2468 int pos_byte = PT_BYTE; |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
2469 int c; |
163 | 2470 |
22370
1f0dc0251be3
(scan_lists): Properly skip the comment-fence character
Richard M. Stallman <rms@gnu.org>
parents:
22130
diff
changeset
|
2471 if (pos <= beg) |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
2472 { |
22370
1f0dc0251be3
(scan_lists): Properly skip the comment-fence character
Richard M. Stallman <rms@gnu.org>
parents:
22130
diff
changeset
|
2473 SET_PT_BOTH (opoint, opoint_byte); |
1f0dc0251be3
(scan_lists): Properly skip the comment-fence character
Richard M. Stallman <rms@gnu.org>
parents:
22130
diff
changeset
|
2474 |
1f0dc0251be3
(scan_lists): Properly skip the comment-fence character
Richard M. Stallman <rms@gnu.org>
parents:
22130
diff
changeset
|
2475 return Qnil; |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
2476 } |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
2477 |
22370
1f0dc0251be3
(scan_lists): Properly skip the comment-fence character
Richard M. Stallman <rms@gnu.org>
parents:
22130
diff
changeset
|
2478 SETUP_SYNTAX_TABLE (pos, -1); |
1f0dc0251be3
(scan_lists): Properly skip the comment-fence character
Richard M. Stallman <rms@gnu.org>
parents:
22130
diff
changeset
|
2479 |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
2480 DEC_BOTH (pos, pos_byte); |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
2481 |
21207
390b39d69836
(Fbackward_prefix_chars): Set point properly while scanning.
Richard M. Stallman <rms@gnu.org>
parents:
21011
diff
changeset
|
2482 while (!char_quoted (pos, pos_byte) |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
2483 /* Previous statement updates syntax table. */ |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
2484 && ((c = FETCH_CHAR (pos_byte), SYNTAX (c) == Squote) |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
2485 || SYNTAX_PREFIX (c))) |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
2486 { |
21207
390b39d69836
(Fbackward_prefix_chars): Set point properly while scanning.
Richard M. Stallman <rms@gnu.org>
parents:
21011
diff
changeset
|
2487 opoint = pos; |
390b39d69836
(Fbackward_prefix_chars): Set point properly while scanning.
Richard M. Stallman <rms@gnu.org>
parents:
21011
diff
changeset
|
2488 opoint_byte = pos_byte; |
390b39d69836
(Fbackward_prefix_chars): Set point properly while scanning.
Richard M. Stallman <rms@gnu.org>
parents:
21011
diff
changeset
|
2489 |
390b39d69836
(Fbackward_prefix_chars): Set point properly while scanning.
Richard M. Stallman <rms@gnu.org>
parents:
21011
diff
changeset
|
2490 if (pos + 1 > beg) |
390b39d69836
(Fbackward_prefix_chars): Set point properly while scanning.
Richard M. Stallman <rms@gnu.org>
parents:
21011
diff
changeset
|
2491 DEC_BOTH (pos, pos_byte); |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
2492 } |
163 | 2493 |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
2494 SET_PT_BOTH (opoint, opoint_byte); |
163 | 2495 |
2496 return Qnil; | |
2497 } | |
2498 | |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
2499 /* Parse forward from FROM / FROM_BYTE to END, |
1085
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
2500 assuming that FROM has state OLDSTATE (nil means FROM is start of function), |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
2501 and return a description of the state of the parse at END. |
3568
3ee951a22a80
(Fforward_comment): Set point to where scan stops,
Richard M. Stallman <rms@gnu.org>
parents:
3095
diff
changeset
|
2502 If STOPBEFORE is nonzero, stop at the start of an atom. |
20475
efbebc38e077
Comment and whitespace changes.
Richard M. Stallman <rms@gnu.org>
parents:
20330
diff
changeset
|
2503 If COMMENTSTOP is 1, stop at the start of a comment. |
efbebc38e077
Comment and whitespace changes.
Richard M. Stallman <rms@gnu.org>
parents:
20330
diff
changeset
|
2504 If COMMENTSTOP is -1, stop at the start or end of a comment, |
efbebc38e077
Comment and whitespace changes.
Richard M. Stallman <rms@gnu.org>
parents:
20330
diff
changeset
|
2505 after the beginning of a string, or after the end of a string. */ |
163 | 2506 |
3720
408c7ee69be7
(scan_lists, Fforward_comment): Pass 0 as commentstop arg
Richard M. Stallman <rms@gnu.org>
parents:
3684
diff
changeset
|
2507 static void |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
2508 scan_sexps_forward (stateptr, from, from_byte, end, targetdepth, |
3568
3ee951a22a80
(Fforward_comment): Set point to where scan stops,
Richard M. Stallman <rms@gnu.org>
parents:
3095
diff
changeset
|
2509 stopbefore, oldstate, commentstop) |
1085
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
2510 struct lisp_parse_state *stateptr; |
163 | 2511 register int from; |
2512 int end, targetdepth, stopbefore; | |
2513 Lisp_Object oldstate; | |
3568
3ee951a22a80
(Fforward_comment): Set point to where scan stops,
Richard M. Stallman <rms@gnu.org>
parents:
3095
diff
changeset
|
2514 int commentstop; |
163 | 2515 { |
2516 struct lisp_parse_state state; | |
2517 | |
2518 register enum syntaxcode code; | |
25445
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
2519 int c1; |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
2520 int comnested; |
163 | 2521 struct level { int last, prev; }; |
2522 struct level levelstart[100]; | |
2523 register struct level *curlevel = levelstart; | |
2524 struct level *endlevel = levelstart + 100; | |
2525 register int depth; /* Paren depth of current scanning location. | |
2526 level - levelstart equals this except | |
2527 when the depth becomes negative. */ | |
2528 int mindepth; /* Lowest DEPTH value seen. */ | |
2529 int start_quoted = 0; /* Nonzero means starting after a char quote */ | |
2530 Lisp_Object tem; | |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
2531 int prev_from; /* Keep one character before FROM. */ |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
2532 int prev_from_byte; |
21207
390b39d69836
(Fbackward_prefix_chars): Set point properly while scanning.
Richard M. Stallman <rms@gnu.org>
parents:
21011
diff
changeset
|
2533 int prev_from_syntax; |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
2534 int boundary_stop = commentstop == -1; |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
2535 int nofence; |
25445
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
2536 int found; |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
2537 int out_bytepos, out_charpos; |
22006
31c39cdc9e11
(scan_lists, scan_sexps_forward): Move complex expressions
Richard M. Stallman <rms@gnu.org>
parents:
21514
diff
changeset
|
2538 int temp; |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
2539 |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
2540 prev_from = from; |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
2541 prev_from_byte = from_byte; |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
2542 if (from != BEGV) |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
2543 DEC_BOTH (prev_from, prev_from_byte); |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
2544 |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
2545 /* Use this macro instead of `from++'. */ |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
2546 #define INC_FROM \ |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
2547 do { prev_from = from; \ |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
2548 prev_from_byte = from_byte; \ |
21207
390b39d69836
(Fbackward_prefix_chars): Set point properly while scanning.
Richard M. Stallman <rms@gnu.org>
parents:
21011
diff
changeset
|
2549 prev_from_syntax \ |
390b39d69836
(Fbackward_prefix_chars): Set point properly while scanning.
Richard M. Stallman <rms@gnu.org>
parents:
21011
diff
changeset
|
2550 = SYNTAX_WITH_FLAGS (FETCH_CHAR (prev_from_byte)); \ |
20905
e646a6ae42cd
(skip_chars): Use INC_POS instead of INC_BOTH.
Richard M. Stallman <rms@gnu.org>
parents:
20766
diff
changeset
|
2551 INC_BOTH (from, from_byte); \ |
21207
390b39d69836
(Fbackward_prefix_chars): Set point properly while scanning.
Richard M. Stallman <rms@gnu.org>
parents:
21011
diff
changeset
|
2552 UPDATE_SYNTAX_TABLE_FORWARD (from); \ |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
2553 } while (0) |
163 | 2554 |
2555 immediate_quit = 1; | |
2556 QUIT; | |
2557 | |
485 | 2558 if (NILP (oldstate)) |
163 | 2559 { |
2560 depth = 0; | |
2561 state.instring = -1; | |
2562 state.incomment = 0; | |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
2563 state.comstyle = 0; /* comment style a by default. */ |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
2564 state.comstr_start = -1; /* no comment/string seen. */ |
163 | 2565 } |
2566 else | |
2567 { | |
2568 tem = Fcar (oldstate); | |
485 | 2569 if (!NILP (tem)) |
163 | 2570 depth = XINT (tem); |
2571 else | |
2572 depth = 0; | |
2573 | |
2574 oldstate = Fcdr (oldstate); | |
2575 oldstate = Fcdr (oldstate); | |
2576 oldstate = Fcdr (oldstate); | |
2577 tem = Fcar (oldstate); | |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
2578 /* Check whether we are inside string_fence-style string: */ |
26272
1cbb1b30793d
Remove whitespace after open or in front of closing parentheses.
Gerd Moellmann <gerd@gnu.org>
parents:
26060
diff
changeset
|
2579 state.instring = (!NILP (tem) |
1cbb1b30793d
Remove whitespace after open or in front of closing parentheses.
Gerd Moellmann <gerd@gnu.org>
parents:
26060
diff
changeset
|
2580 ? (INTEGERP (tem) ? XINT (tem) : ST_STRING_STYLE) |
1cbb1b30793d
Remove whitespace after open or in front of closing parentheses.
Gerd Moellmann <gerd@gnu.org>
parents:
26060
diff
changeset
|
2581 : -1); |
163 | 2582 |
2583 oldstate = Fcdr (oldstate); | |
2584 tem = Fcar (oldstate); | |
26272
1cbb1b30793d
Remove whitespace after open or in front of closing parentheses.
Gerd Moellmann <gerd@gnu.org>
parents:
26060
diff
changeset
|
2585 state.incomment = (!NILP (tem) |
1cbb1b30793d
Remove whitespace after open or in front of closing parentheses.
Gerd Moellmann <gerd@gnu.org>
parents:
26060
diff
changeset
|
2586 ? (INTEGERP (tem) ? XINT (tem) : -1) |
25445
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
2587 : 0); |
163 | 2588 |
2589 oldstate = Fcdr (oldstate); | |
2590 tem = Fcar (oldstate); | |
485 | 2591 start_quoted = !NILP (tem); |
1085
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
2592 |
25445
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
2593 /* if the eighth element of the list is nil, we are in comment |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
2594 style a. If it is non-nil, we are in comment style b */ |
1085
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
2595 oldstate = Fcdr (oldstate); |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
2596 oldstate = Fcdr (oldstate); |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
2597 tem = Fcar (oldstate); |
26272
1cbb1b30793d
Remove whitespace after open or in front of closing parentheses.
Gerd Moellmann <gerd@gnu.org>
parents:
26060
diff
changeset
|
2598 state.comstyle = NILP (tem) ? 0 : (EQ (tem, Qsyntax_table) |
1cbb1b30793d
Remove whitespace after open or in front of closing parentheses.
Gerd Moellmann <gerd@gnu.org>
parents:
26060
diff
changeset
|
2599 ? ST_COMMENT_STYLE : 1); |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
2600 |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
2601 oldstate = Fcdr (oldstate); |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
2602 tem = Fcar (oldstate); |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
2603 state.comstr_start = NILP (tem) ? -1 : XINT (tem) ; |
22394
5e1f0caf1873
(struct lisp_parse_state): New field, levelstarts.
Richard M. Stallman <rms@gnu.org>
parents:
22370
diff
changeset
|
2604 oldstate = Fcdr (oldstate); |
5e1f0caf1873
(struct lisp_parse_state): New field, levelstarts.
Richard M. Stallman <rms@gnu.org>
parents:
22370
diff
changeset
|
2605 tem = Fcar (oldstate); |
5e1f0caf1873
(struct lisp_parse_state): New field, levelstarts.
Richard M. Stallman <rms@gnu.org>
parents:
22370
diff
changeset
|
2606 while (!NILP (tem)) /* >= second enclosing sexps. */ |
5e1f0caf1873
(struct lisp_parse_state): New field, levelstarts.
Richard M. Stallman <rms@gnu.org>
parents:
22370
diff
changeset
|
2607 { |
5e1f0caf1873
(struct lisp_parse_state): New field, levelstarts.
Richard M. Stallman <rms@gnu.org>
parents:
22370
diff
changeset
|
2608 /* curlevel++->last ran into compiler bug on Apollo */ |
5e1f0caf1873
(struct lisp_parse_state): New field, levelstarts.
Richard M. Stallman <rms@gnu.org>
parents:
22370
diff
changeset
|
2609 curlevel->last = XINT (Fcar (tem)); |
5e1f0caf1873
(struct lisp_parse_state): New field, levelstarts.
Richard M. Stallman <rms@gnu.org>
parents:
22370
diff
changeset
|
2610 if (++curlevel == endlevel) |
30156
f59021679260
(back_comment): Use one switch rather than a few `if's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29835
diff
changeset
|
2611 curlevel--; /* error ("Nesting too deep for parser"); */ |
22394
5e1f0caf1873
(struct lisp_parse_state): New field, levelstarts.
Richard M. Stallman <rms@gnu.org>
parents:
22370
diff
changeset
|
2612 curlevel->prev = -1; |
5e1f0caf1873
(struct lisp_parse_state): New field, levelstarts.
Richard M. Stallman <rms@gnu.org>
parents:
22370
diff
changeset
|
2613 curlevel->last = -1; |
5e1f0caf1873
(struct lisp_parse_state): New field, levelstarts.
Richard M. Stallman <rms@gnu.org>
parents:
22370
diff
changeset
|
2614 tem = Fcdr (tem); |
5e1f0caf1873
(struct lisp_parse_state): New field, levelstarts.
Richard M. Stallman <rms@gnu.org>
parents:
22370
diff
changeset
|
2615 } |
163 | 2616 } |
2617 state.quoted = 0; | |
2618 mindepth = depth; | |
2619 | |
2620 curlevel->prev = -1; | |
2621 curlevel->last = -1; | |
2622 | |
22994
85f64bf341c3
(scan_sexps_forward): Set up the syntax table scanning
Richard M. Stallman <rms@gnu.org>
parents:
22547
diff
changeset
|
2623 SETUP_SYNTAX_TABLE (prev_from, 1); |
85f64bf341c3
(scan_sexps_forward): Set up the syntax table scanning
Richard M. Stallman <rms@gnu.org>
parents:
22547
diff
changeset
|
2624 prev_from_syntax = SYNTAX_WITH_FLAGS (FETCH_CHAR (prev_from_byte)); |
85f64bf341c3
(scan_sexps_forward): Set up the syntax table scanning
Richard M. Stallman <rms@gnu.org>
parents:
22547
diff
changeset
|
2625 UPDATE_SYNTAX_TABLE_FORWARD (from); |
85f64bf341c3
(scan_sexps_forward): Set up the syntax table scanning
Richard M. Stallman <rms@gnu.org>
parents:
22547
diff
changeset
|
2626 |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
2627 /* Enter the loop at a place appropriate for initial state. */ |
163 | 2628 |
22994
85f64bf341c3
(scan_sexps_forward): Set up the syntax table scanning
Richard M. Stallman <rms@gnu.org>
parents:
22547
diff
changeset
|
2629 if (state.incomment) |
85f64bf341c3
(scan_sexps_forward): Set up the syntax table scanning
Richard M. Stallman <rms@gnu.org>
parents:
22547
diff
changeset
|
2630 goto startincomment; |
163 | 2631 if (state.instring >= 0) |
2632 { | |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
2633 nofence = state.instring != ST_STRING_STYLE; |
22994
85f64bf341c3
(scan_sexps_forward): Set up the syntax table scanning
Richard M. Stallman <rms@gnu.org>
parents:
22547
diff
changeset
|
2634 if (start_quoted) |
85f64bf341c3
(scan_sexps_forward): Set up the syntax table scanning
Richard M. Stallman <rms@gnu.org>
parents:
22547
diff
changeset
|
2635 goto startquotedinstring; |
163 | 2636 goto startinstring; |
2637 } | |
22994
85f64bf341c3
(scan_sexps_forward): Set up the syntax table scanning
Richard M. Stallman <rms@gnu.org>
parents:
22547
diff
changeset
|
2638 else if (start_quoted) |
85f64bf341c3
(scan_sexps_forward): Set up the syntax table scanning
Richard M. Stallman <rms@gnu.org>
parents:
22547
diff
changeset
|
2639 goto startquoted; |
21207
390b39d69836
(Fbackward_prefix_chars): Set point properly while scanning.
Richard M. Stallman <rms@gnu.org>
parents:
21011
diff
changeset
|
2640 |
24148
b69751ec40fe
(scan_sexps_forward): Delete duplicate code
Karl Heuer <kwzh@gnu.org>
parents:
23503
diff
changeset
|
2641 #if 0 /* This seems to be redundant with the identical code above. */ |
21207
390b39d69836
(Fbackward_prefix_chars): Set point properly while scanning.
Richard M. Stallman <rms@gnu.org>
parents:
21011
diff
changeset
|
2642 SETUP_SYNTAX_TABLE (prev_from, 1); |
390b39d69836
(Fbackward_prefix_chars): Set point properly while scanning.
Richard M. Stallman <rms@gnu.org>
parents:
21011
diff
changeset
|
2643 prev_from_syntax = SYNTAX_WITH_FLAGS (FETCH_CHAR (prev_from_byte)); |
390b39d69836
(Fbackward_prefix_chars): Set point properly while scanning.
Richard M. Stallman <rms@gnu.org>
parents:
21011
diff
changeset
|
2644 UPDATE_SYNTAX_TABLE_FORWARD (from); |
24148
b69751ec40fe
(scan_sexps_forward): Delete duplicate code
Karl Heuer <kwzh@gnu.org>
parents:
23503
diff
changeset
|
2645 #endif |
21207
390b39d69836
(Fbackward_prefix_chars): Set point properly while scanning.
Richard M. Stallman <rms@gnu.org>
parents:
21011
diff
changeset
|
2646 |
163 | 2647 while (from < end) |
2648 { | |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
2649 INC_FROM; |
21207
390b39d69836
(Fbackward_prefix_chars): Set point properly while scanning.
Richard M. Stallman <rms@gnu.org>
parents:
21011
diff
changeset
|
2650 code = prev_from_syntax & 0xff; |
18491
bf0d449581c8
(scan_sexps_forward): Split up a complex if-test.
Richard M. Stallman <rms@gnu.org>
parents:
18113
diff
changeset
|
2651 |
3794
ea9d3f2cd5fa
(scan_lists, Fforward_comment): #if 0 the code
Richard M. Stallman <rms@gnu.org>
parents:
3720
diff
changeset
|
2652 if (code == Scomment) |
25445
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
2653 { |
29823
5a736b07dbf2
(scan_sexps_forward):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29821
diff
changeset
|
2654 state.comstyle = SYNTAX_FLAGS_COMMENT_STYLE (prev_from_syntax); |
25445
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
2655 state.incomment = (SYNTAX_FLAGS_COMMENT_NESTED (prev_from_syntax) ? |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
2656 1 : -1); |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
2657 state.comstr_start = prev_from; |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
2658 } |
18491
bf0d449581c8
(scan_sexps_forward): Split up a complex if-test.
Richard M. Stallman <rms@gnu.org>
parents:
18113
diff
changeset
|
2659 else if (code == Scomment_fence) |
1085
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
2660 { |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
2661 /* Record the comment style we have entered so that only |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
2662 the comment-end sequence of the same style actually |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
2663 terminates the comment section. */ |
25445
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
2664 state.comstyle = ST_COMMENT_STYLE; |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
2665 state.incomment = -1; |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
2666 state.comstr_start = prev_from; |
1085
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
2667 code = Scomment; |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
2668 } |
18491
bf0d449581c8
(scan_sexps_forward): Split up a complex if-test.
Richard M. Stallman <rms@gnu.org>
parents:
18113
diff
changeset
|
2669 else if (from < end) |
21207
390b39d69836
(Fbackward_prefix_chars): Set point properly while scanning.
Richard M. Stallman <rms@gnu.org>
parents:
21011
diff
changeset
|
2670 if (SYNTAX_FLAGS_COMSTART_FIRST (prev_from_syntax)) |
25445
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
2671 if (c1 = FETCH_CHAR (from_byte), |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
2672 SYNTAX_COMSTART_SECOND (c1)) |
21207
390b39d69836
(Fbackward_prefix_chars): Set point properly while scanning.
Richard M. Stallman <rms@gnu.org>
parents:
21011
diff
changeset
|
2673 /* Duplicate code to avoid a complex if-expression |
18491
bf0d449581c8
(scan_sexps_forward): Split up a complex if-test.
Richard M. Stallman <rms@gnu.org>
parents:
18113
diff
changeset
|
2674 which causes trouble for the SGI compiler. */ |
bf0d449581c8
(scan_sexps_forward): Split up a complex if-test.
Richard M. Stallman <rms@gnu.org>
parents:
18113
diff
changeset
|
2675 { |
bf0d449581c8
(scan_sexps_forward): Split up a complex if-test.
Richard M. Stallman <rms@gnu.org>
parents:
18113
diff
changeset
|
2676 /* Record the comment style we have entered so that only |
bf0d449581c8
(scan_sexps_forward): Split up a complex if-test.
Richard M. Stallman <rms@gnu.org>
parents:
18113
diff
changeset
|
2677 the comment-end sequence of the same style actually |
bf0d449581c8
(scan_sexps_forward): Split up a complex if-test.
Richard M. Stallman <rms@gnu.org>
parents:
18113
diff
changeset
|
2678 terminates the comment section. */ |
25445
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
2679 state.comstyle = SYNTAX_COMMENT_STYLE (FETCH_CHAR (from_byte)); |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
2680 comnested = SYNTAX_FLAGS_COMMENT_NESTED (prev_from_syntax); |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
2681 comnested = comnested || SYNTAX_COMMENT_NESTED (c1); |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
2682 state.incomment = comnested ? 1 : -1; |
18491
bf0d449581c8
(scan_sexps_forward): Split up a complex if-test.
Richard M. Stallman <rms@gnu.org>
parents:
18113
diff
changeset
|
2683 state.comstr_start = prev_from; |
25445
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
2684 INC_FROM; |
18491
bf0d449581c8
(scan_sexps_forward): Split up a complex if-test.
Richard M. Stallman <rms@gnu.org>
parents:
18113
diff
changeset
|
2685 code = Scomment; |
bf0d449581c8
(scan_sexps_forward): Split up a complex if-test.
Richard M. Stallman <rms@gnu.org>
parents:
18113
diff
changeset
|
2686 } |
1085
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
2687 |
21207
390b39d69836
(Fbackward_prefix_chars): Set point properly while scanning.
Richard M. Stallman <rms@gnu.org>
parents:
21011
diff
changeset
|
2688 if (SYNTAX_FLAGS_PREFIX (prev_from_syntax)) |
163 | 2689 continue; |
10457
2ab3bd0288a9
Change all occurences of SWITCH_ENUM_BUG to use SWITCH_ENUM_CAST instead.
Karl Heuer <kwzh@gnu.org>
parents:
9863
diff
changeset
|
2690 switch (SWITCH_ENUM_CAST (code)) |
163 | 2691 { |
2692 case Sescape: | |
2693 case Scharquote: | |
2694 if (stopbefore) goto stop; /* this arg means stop at sexp start */ | |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
2695 curlevel->last = prev_from; |
163 | 2696 startquoted: |
2697 if (from == end) goto endquoted; | |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
2698 INC_FROM; |
163 | 2699 goto symstarted; |
2700 /* treat following character as a word constituent */ | |
2701 case Sword: | |
2702 case Ssymbol: | |
2703 if (stopbefore) goto stop; /* this arg means stop at sexp start */ | |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
2704 curlevel->last = prev_from; |
163 | 2705 symstarted: |
2706 while (from < end) | |
2707 { | |
22006
31c39cdc9e11
(scan_lists, scan_sexps_forward): Move complex expressions
Richard M. Stallman <rms@gnu.org>
parents:
21514
diff
changeset
|
2708 /* Some compilers can't handle this inside the switch. */ |
31c39cdc9e11
(scan_lists, scan_sexps_forward): Move complex expressions
Richard M. Stallman <rms@gnu.org>
parents:
21514
diff
changeset
|
2709 temp = SYNTAX (FETCH_CHAR (from_byte)); |
31c39cdc9e11
(scan_lists, scan_sexps_forward): Move complex expressions
Richard M. Stallman <rms@gnu.org>
parents:
21514
diff
changeset
|
2710 switch (temp) |
163 | 2711 { |
2712 case Scharquote: | |
2713 case Sescape: | |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
2714 INC_FROM; |
163 | 2715 if (from == end) goto endquoted; |
2716 break; | |
2717 case Sword: | |
2718 case Ssymbol: | |
2719 case Squote: | |
2720 break; | |
2721 default: | |
2722 goto symdone; | |
2723 } | |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
2724 INC_FROM; |
163 | 2725 } |
2726 symdone: | |
2727 curlevel->prev = curlevel->last; | |
2728 break; | |
2729 | |
29823
5a736b07dbf2
(scan_sexps_forward):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29821
diff
changeset
|
2730 case Scomment: |
5a736b07dbf2
(scan_sexps_forward):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29821
diff
changeset
|
2731 if (commentstop || boundary_stop) goto done; |
9475
c15caadae3c4
(scan_sexps_forward): At startincomment,
Richard M. Stallman <rms@gnu.org>
parents:
9411
diff
changeset
|
2732 startincomment: |
29823
5a736b07dbf2
(scan_sexps_forward):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29821
diff
changeset
|
2733 /* The (from == BEGV) test was to enter the loop in the middle so |
25445
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
2734 that we find a 2-char comment ender even if we start in the |
29821
819dfcbd36c7
(describe_syntax): Recognize the `n'estable bit.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29757
diff
changeset
|
2735 middle of it. We don't want to do that if we're just at the |
29823
5a736b07dbf2
(scan_sexps_forward):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29821
diff
changeset
|
2736 beginning of the comment (think of (*) ... (*)). */ |
25445
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
2737 found = forw_comment (from, from_byte, end, |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
2738 state.incomment, state.comstyle, |
29821
819dfcbd36c7
(describe_syntax): Recognize the `n'estable bit.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29757
diff
changeset
|
2739 (from == BEGV || from < state.comstr_start + 3) |
819dfcbd36c7
(describe_syntax): Recognize the `n'estable bit.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29757
diff
changeset
|
2740 ? 0 : prev_from_syntax, |
25445
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
2741 &out_charpos, &out_bytepos, &state.incomment); |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
2742 from = out_charpos; from_byte = out_bytepos; |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
2743 /* Beware! prev_from and friends are invalid now. |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
2744 Luckily, the `done' doesn't use them and the INC_FROM |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
2745 sets them to a sane value without looking at them. */ |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
2746 if (!found) goto done; |
29823
5a736b07dbf2
(scan_sexps_forward):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29821
diff
changeset
|
2747 INC_FROM; |
163 | 2748 state.incomment = 0; |
1085
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
2749 state.comstyle = 0; /* reset the comment style */ |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
2750 if (boundary_stop) goto done; |
163 | 2751 break; |
2752 | |
2753 case Sopen: | |
2754 if (stopbefore) goto stop; /* this arg means stop at sexp start */ | |
2755 depth++; | |
2756 /* curlevel++->last ran into compiler bug on Apollo */ | |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
2757 curlevel->last = prev_from; |
163 | 2758 if (++curlevel == endlevel) |
30156
f59021679260
(back_comment): Use one switch rather than a few `if's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29835
diff
changeset
|
2759 curlevel--; /* error ("Nesting too deep for parser"); */ |
163 | 2760 curlevel->prev = -1; |
2761 curlevel->last = -1; | |
12894
b2a75405de3c
(scan_sexps_forward): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents:
12870
diff
changeset
|
2762 if (targetdepth == depth) goto done; |
163 | 2763 break; |
2764 | |
2765 case Sclose: | |
2766 depth--; | |
2767 if (depth < mindepth) | |
2768 mindepth = depth; | |
2769 if (curlevel != levelstart) | |
2770 curlevel--; | |
2771 curlevel->prev = curlevel->last; | |
12894
b2a75405de3c
(scan_sexps_forward): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents:
12870
diff
changeset
|
2772 if (targetdepth == depth) goto done; |
163 | 2773 break; |
2774 | |
2775 case Sstring: | |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
2776 case Sstring_fence: |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
2777 state.comstr_start = from - 1; |
163 | 2778 if (stopbefore) goto stop; /* this arg means stop at sexp start */ |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
2779 curlevel->last = prev_from; |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
2780 state.instring = (code == Sstring |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
2781 ? (FETCH_CHAR (prev_from_byte)) |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
2782 : ST_STRING_STYLE); |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
2783 if (boundary_stop) goto done; |
163 | 2784 startinstring: |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
2785 { |
20475
efbebc38e077
Comment and whitespace changes.
Richard M. Stallman <rms@gnu.org>
parents:
20330
diff
changeset
|
2786 nofence = state.instring != ST_STRING_STYLE; |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
2787 |
20475
efbebc38e077
Comment and whitespace changes.
Richard M. Stallman <rms@gnu.org>
parents:
20330
diff
changeset
|
2788 while (1) |
efbebc38e077
Comment and whitespace changes.
Richard M. Stallman <rms@gnu.org>
parents:
20330
diff
changeset
|
2789 { |
efbebc38e077
Comment and whitespace changes.
Richard M. Stallman <rms@gnu.org>
parents:
20330
diff
changeset
|
2790 int c; |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
2791 |
20475
efbebc38e077
Comment and whitespace changes.
Richard M. Stallman <rms@gnu.org>
parents:
20330
diff
changeset
|
2792 if (from >= end) goto done; |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
2793 c = FETCH_CHAR (from_byte); |
22006
31c39cdc9e11
(scan_lists, scan_sexps_forward): Move complex expressions
Richard M. Stallman <rms@gnu.org>
parents:
21514
diff
changeset
|
2794 /* Some compilers can't handle this inside the switch. */ |
31c39cdc9e11
(scan_lists, scan_sexps_forward): Move complex expressions
Richard M. Stallman <rms@gnu.org>
parents:
21514
diff
changeset
|
2795 temp = SYNTAX (c); |
24148
b69751ec40fe
(scan_sexps_forward): Delete duplicate code
Karl Heuer <kwzh@gnu.org>
parents:
23503
diff
changeset
|
2796 |
b69751ec40fe
(scan_sexps_forward): Delete duplicate code
Karl Heuer <kwzh@gnu.org>
parents:
23503
diff
changeset
|
2797 /* Check TEMP here so that if the char has |
b69751ec40fe
(scan_sexps_forward): Delete duplicate code
Karl Heuer <kwzh@gnu.org>
parents:
23503
diff
changeset
|
2798 a syntax-table property which says it is NOT |
b69751ec40fe
(scan_sexps_forward): Delete duplicate code
Karl Heuer <kwzh@gnu.org>
parents:
23503
diff
changeset
|
2799 a string character, it does not end the string. */ |
b69751ec40fe
(scan_sexps_forward): Delete duplicate code
Karl Heuer <kwzh@gnu.org>
parents:
23503
diff
changeset
|
2800 if (nofence && c == state.instring && temp == Sstring) |
b69751ec40fe
(scan_sexps_forward): Delete duplicate code
Karl Heuer <kwzh@gnu.org>
parents:
23503
diff
changeset
|
2801 break; |
b69751ec40fe
(scan_sexps_forward): Delete duplicate code
Karl Heuer <kwzh@gnu.org>
parents:
23503
diff
changeset
|
2802 |
22006
31c39cdc9e11
(scan_lists, scan_sexps_forward): Move complex expressions
Richard M. Stallman <rms@gnu.org>
parents:
21514
diff
changeset
|
2803 switch (temp) |
20475
efbebc38e077
Comment and whitespace changes.
Richard M. Stallman <rms@gnu.org>
parents:
20330
diff
changeset
|
2804 { |
efbebc38e077
Comment and whitespace changes.
Richard M. Stallman <rms@gnu.org>
parents:
20330
diff
changeset
|
2805 case Sstring_fence: |
efbebc38e077
Comment and whitespace changes.
Richard M. Stallman <rms@gnu.org>
parents:
20330
diff
changeset
|
2806 if (!nofence) goto string_end; |
efbebc38e077
Comment and whitespace changes.
Richard M. Stallman <rms@gnu.org>
parents:
20330
diff
changeset
|
2807 break; |
efbebc38e077
Comment and whitespace changes.
Richard M. Stallman <rms@gnu.org>
parents:
20330
diff
changeset
|
2808 case Scharquote: |
efbebc38e077
Comment and whitespace changes.
Richard M. Stallman <rms@gnu.org>
parents:
20330
diff
changeset
|
2809 case Sescape: |
efbebc38e077
Comment and whitespace changes.
Richard M. Stallman <rms@gnu.org>
parents:
20330
diff
changeset
|
2810 INC_FROM; |
efbebc38e077
Comment and whitespace changes.
Richard M. Stallman <rms@gnu.org>
parents:
20330
diff
changeset
|
2811 startquotedinstring: |
efbebc38e077
Comment and whitespace changes.
Richard M. Stallman <rms@gnu.org>
parents:
20330
diff
changeset
|
2812 if (from >= end) goto endquoted; |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
2813 } |
20475
efbebc38e077
Comment and whitespace changes.
Richard M. Stallman <rms@gnu.org>
parents:
20330
diff
changeset
|
2814 INC_FROM; |
efbebc38e077
Comment and whitespace changes.
Richard M. Stallman <rms@gnu.org>
parents:
20330
diff
changeset
|
2815 } |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
2816 } |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
2817 string_end: |
163 | 2818 state.instring = -1; |
2819 curlevel->prev = curlevel->last; | |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
2820 INC_FROM; |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
2821 if (boundary_stop) goto done; |
163 | 2822 break; |
2823 | |
2824 case Smath: | |
2825 break; | |
2826 } | |
2827 } | |
2828 goto done; | |
2829 | |
2830 stop: /* Here if stopping before start of sexp. */ | |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
2831 from = prev_from; /* We have just fetched the char that starts it; */ |
163 | 2832 goto done; /* but return the position before it. */ |
2833 | |
2834 endquoted: | |
2835 state.quoted = 1; | |
2836 done: | |
2837 state.depth = depth; | |
2838 state.mindepth = mindepth; | |
2839 state.thislevelstart = curlevel->prev; | |
2840 state.prevlevelstart | |
2841 = (curlevel == levelstart) ? -1 : (curlevel - 1)->last; | |
2842 state.location = from; | |
22394
5e1f0caf1873
(struct lisp_parse_state): New field, levelstarts.
Richard M. Stallman <rms@gnu.org>
parents:
22370
diff
changeset
|
2843 state.levelstarts = Qnil; |
5e1f0caf1873
(struct lisp_parse_state): New field, levelstarts.
Richard M. Stallman <rms@gnu.org>
parents:
22370
diff
changeset
|
2844 while (--curlevel >= levelstart) |
5e1f0caf1873
(struct lisp_parse_state): New field, levelstarts.
Richard M. Stallman <rms@gnu.org>
parents:
22370
diff
changeset
|
2845 state.levelstarts = Fcons (make_number (curlevel->last), |
5e1f0caf1873
(struct lisp_parse_state): New field, levelstarts.
Richard M. Stallman <rms@gnu.org>
parents:
22370
diff
changeset
|
2846 state.levelstarts); |
163 | 2847 immediate_quit = 0; |
2848 | |
1085
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
2849 *stateptr = state; |
163 | 2850 } |
2851 | |
2852 /* This comment supplies the doc string for parse-partial-sexp, | |
2853 for make-docfile to see. We cannot put this in the real DEFUN | |
2854 due to limits in the Unix cpp. | |
2855 | |
3568
3ee951a22a80
(Fforward_comment): Set point to where scan stops,
Richard M. Stallman <rms@gnu.org>
parents:
3095
diff
changeset
|
2856 DEFUN ("parse-partial-sexp", Ffoo, Sfoo, 2, 6, 0, |
163 | 2857 "Parse Lisp syntax starting at FROM until TO; return status of parse at TO.\n\ |
2858 Parsing stops at TO or when certain criteria are met;\n\ | |
2859 point is set to where parsing stops.\n\ | |
2860 If fifth arg STATE is omitted or nil,\n\ | |
2861 parsing assumes that FROM is the beginning of a function.\n\ | |
22394
5e1f0caf1873
(struct lisp_parse_state): New field, levelstarts.
Richard M. Stallman <rms@gnu.org>
parents:
22370
diff
changeset
|
2862 Value is a list of ten elements describing final state of parsing:\n\ |
4458 | 2863 0. depth in parens.\n\ |
2864 1. character address of start of innermost containing list; nil if none.\n\ | |
2865 2. character address of start of last complete sexp terminated.\n\ | |
2866 3. non-nil if inside a string.\n\ | |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
2867 (it is the character that will terminate the string,\n\ |
20486
26d12c66acc1
(Fparse_partial_sexp): Return nil for 9th element
Richard M. Stallman <rms@gnu.org>
parents:
20475
diff
changeset
|
2868 or t if the string should be terminated by a generic string delimiter.)\n\ |
25445
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
2869 4. nil if outside a comment, t if inside a non-nestable comment, \n\ |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
2870 else an integer (the current comment nesting).\n\ |
4458 | 2871 5. t if following a quote character.\n\ |
2872 6. the minimum paren-depth encountered during this scan.\n\ | |
29757 | 2873 7. t if in a comment of style b; symbol `syntax-table' if the comment\n\ |
20486
26d12c66acc1
(Fparse_partial_sexp): Return nil for 9th element
Richard M. Stallman <rms@gnu.org>
parents:
20475
diff
changeset
|
2874 should be terminated by a generic comment delimiter.\n\ |
26d12c66acc1
(Fparse_partial_sexp): Return nil for 9th element
Richard M. Stallman <rms@gnu.org>
parents:
20475
diff
changeset
|
2875 8. character address of start of comment or string; nil if not in one.\n\ |
22394
5e1f0caf1873
(struct lisp_parse_state): New field, levelstarts.
Richard M. Stallman <rms@gnu.org>
parents:
22370
diff
changeset
|
2876 9. Intermediate data for continuation of parsing (subject to change).\n\ |
163 | 2877 If third arg TARGETDEPTH is non-nil, parsing stops if the depth\n\ |
2878 in parentheses becomes equal to TARGETDEPTH.\n\ | |
2879 Fourth arg STOPBEFORE non-nil means stop when come to\n\ | |
2880 any character that starts a sexp.\n\ | |
20486
26d12c66acc1
(Fparse_partial_sexp): Return nil for 9th element
Richard M. Stallman <rms@gnu.org>
parents:
20475
diff
changeset
|
2881 Fifth arg STATE is a nine-element list like what this function returns.\n\ |
26d12c66acc1
(Fparse_partial_sexp): Return nil for 9th element
Richard M. Stallman <rms@gnu.org>
parents:
20475
diff
changeset
|
2882 It is used to initialize the state of the parse. Elements number 1, 2, 6\n\ |
26d12c66acc1
(Fparse_partial_sexp): Return nil for 9th element
Richard M. Stallman <rms@gnu.org>
parents:
20475
diff
changeset
|
2883 and 8 are ignored; you can leave off element 8 (the last) entirely.\n\ |
26d12c66acc1
(Fparse_partial_sexp): Return nil for 9th element
Richard M. Stallman <rms@gnu.org>
parents:
20475
diff
changeset
|
2884 Sixth arg COMMENTSTOP non-nil means stop at the start of a comment.\n\ |
29757 | 2885 If it is symbol `syntax-table', stop after the start of a comment or a\n\ |
2886 string, or after end of a comment or a string.") | |
3568
3ee951a22a80
(Fforward_comment): Set point to where scan stops,
Richard M. Stallman <rms@gnu.org>
parents:
3095
diff
changeset
|
2887 (from, to, targetdepth, stopbefore, state, commentstop) |
163 | 2888 */ |
2889 | |
3568
3ee951a22a80
(Fforward_comment): Set point to where scan stops,
Richard M. Stallman <rms@gnu.org>
parents:
3095
diff
changeset
|
2890 DEFUN ("parse-partial-sexp", Fparse_partial_sexp, Sparse_partial_sexp, 2, 6, 0, |
163 | 2891 0 /* See immediately above */) |
3568
3ee951a22a80
(Fforward_comment): Set point to where scan stops,
Richard M. Stallman <rms@gnu.org>
parents:
3095
diff
changeset
|
2892 (from, to, targetdepth, stopbefore, oldstate, commentstop) |
3ee951a22a80
(Fforward_comment): Set point to where scan stops,
Richard M. Stallman <rms@gnu.org>
parents:
3095
diff
changeset
|
2893 Lisp_Object from, to, targetdepth, stopbefore, oldstate, commentstop; |
163 | 2894 { |
2895 struct lisp_parse_state state; | |
2896 int target; | |
2897 | |
485 | 2898 if (!NILP (targetdepth)) |
163 | 2899 { |
2900 CHECK_NUMBER (targetdepth, 3); | |
2901 target = XINT (targetdepth); | |
2902 } | |
2903 else | |
2904 target = -100000; /* We won't reach this depth */ | |
2905 | |
2906 validate_region (&from, &to); | |
20546
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
2907 scan_sexps_forward (&state, XINT (from), CHAR_TO_BYTE (XINT (from)), |
a475efff810e
(scan_sexps_forward): Additional arg FROM_BYTE. Calls changed.
Richard M. Stallman <rms@gnu.org>
parents:
20486
diff
changeset
|
2908 XINT (to), |
3568
3ee951a22a80
(Fforward_comment): Set point to where scan stops,
Richard M. Stallman <rms@gnu.org>
parents:
3095
diff
changeset
|
2909 target, !NILP (stopbefore), oldstate, |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
2910 (NILP (commentstop) |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
2911 ? 0 : (EQ (commentstop, Qsyntax_table) ? -1 : 1))); |
163 | 2912 |
2913 SET_PT (state.location); | |
2914 | |
2915 return Fcons (make_number (state.depth), | |
2916 Fcons (state.prevlevelstart < 0 ? Qnil : make_number (state.prevlevelstart), | |
2917 Fcons (state.thislevelstart < 0 ? Qnil : make_number (state.thislevelstart), | |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
2918 Fcons (state.instring >= 0 |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
2919 ? (state.instring == ST_STRING_STYLE |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
2920 ? Qt : make_number (state.instring)) : Qnil, |
25445
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
2921 Fcons (state.incomment < 0 ? Qt : |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
2922 (state.incomment == 0 ? Qnil : |
d678b229c05a
(lisp_parse_state, back_comment, Fmodify_syntax_entry)
Richard M. Stallman <rms@gnu.org>
parents:
25401
diff
changeset
|
2923 make_number (state.incomment)), |
163 | 2924 Fcons (state.quoted ? Qt : Qnil, |
20486
26d12c66acc1
(Fparse_partial_sexp): Return nil for 9th element
Richard M. Stallman <rms@gnu.org>
parents:
20475
diff
changeset
|
2925 Fcons (make_number (state.mindepth), |
26d12c66acc1
(Fparse_partial_sexp): Return nil for 9th element
Richard M. Stallman <rms@gnu.org>
parents:
20475
diff
changeset
|
2926 Fcons ((state.comstyle |
26d12c66acc1
(Fparse_partial_sexp): Return nil for 9th element
Richard M. Stallman <rms@gnu.org>
parents:
20475
diff
changeset
|
2927 ? (state.comstyle == ST_COMMENT_STYLE |
26d12c66acc1
(Fparse_partial_sexp): Return nil for 9th element
Richard M. Stallman <rms@gnu.org>
parents:
20475
diff
changeset
|
2928 ? Qsyntax_table : Qt) : |
26d12c66acc1
(Fparse_partial_sexp): Return nil for 9th element
Richard M. Stallman <rms@gnu.org>
parents:
20475
diff
changeset
|
2929 Qnil), |
24728
e94104cf5891
(Fparse_partial_sexp): Correct test for element 8 to be
Dave Love <fx@gnu.org>
parents:
24148
diff
changeset
|
2930 Fcons (((state.incomment |
e94104cf5891
(Fparse_partial_sexp): Correct test for element 8 to be
Dave Love <fx@gnu.org>
parents:
24148
diff
changeset
|
2931 || (state.instring >= 0)) |
20486
26d12c66acc1
(Fparse_partial_sexp): Return nil for 9th element
Richard M. Stallman <rms@gnu.org>
parents:
20475
diff
changeset
|
2932 ? make_number (state.comstr_start) |
26d12c66acc1
(Fparse_partial_sexp): Return nil for 9th element
Richard M. Stallman <rms@gnu.org>
parents:
20475
diff
changeset
|
2933 : Qnil), |
22394
5e1f0caf1873
(struct lisp_parse_state): New field, levelstarts.
Richard M. Stallman <rms@gnu.org>
parents:
22370
diff
changeset
|
2934 Fcons (state.levelstarts, Qnil)))))))))); |
163 | 2935 } |
2936 | |
21514 | 2937 void |
163 | 2938 init_syntax_once () |
2939 { | |
17126
f8d7263cce09
(init_syntax_once): Add trick to avoid compiler warning
Kenichi Handa <handa@m17n.org>
parents:
17109
diff
changeset
|
2940 register int i, c; |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
2941 Lisp_Object temp; |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
2942 |
13218
d2fc560c7740
(Qsyntax_table): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13144
diff
changeset
|
2943 /* This has to be done here, before we call Fmake_char_table. */ |
d2fc560c7740
(Qsyntax_table): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13144
diff
changeset
|
2944 Qsyntax_table = intern ("syntax-table"); |
d2fc560c7740
(Qsyntax_table): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13144
diff
changeset
|
2945 staticpro (&Qsyntax_table); |
d2fc560c7740
(Qsyntax_table): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13144
diff
changeset
|
2946 |
d2fc560c7740
(Qsyntax_table): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13144
diff
changeset
|
2947 /* Intern this now in case it isn't already done. |
d2fc560c7740
(Qsyntax_table): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13144
diff
changeset
|
2948 Setting this variable twice is harmless. |
d2fc560c7740
(Qsyntax_table): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13144
diff
changeset
|
2949 But don't staticpro it here--that is done in alloc.c. */ |
d2fc560c7740
(Qsyntax_table): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13144
diff
changeset
|
2950 Qchar_table_extra_slots = intern ("char-table-extra-slots"); |
d2fc560c7740
(Qsyntax_table): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13144
diff
changeset
|
2951 |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
2952 /* Create objects which can be shared among syntax tables. */ |
34398
945b3e6bf3e7
(scan_lists): Check that the right quote char has the
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32794
diff
changeset
|
2953 Vsyntax_code_object = Fmake_vector (make_number (Smax), Qnil); |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
2954 for (i = 0; i < XVECTOR (Vsyntax_code_object)->size; i++) |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
2955 XVECTOR (Vsyntax_code_object)->contents[i] |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
2956 = Fcons (make_number (i), Qnil); |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
2957 |
13218
d2fc560c7740
(Qsyntax_table): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13144
diff
changeset
|
2958 /* Now we are ready to set up this property, so we can |
d2fc560c7740
(Qsyntax_table): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13144
diff
changeset
|
2959 create syntax tables. */ |
d2fc560c7740
(Qsyntax_table): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13144
diff
changeset
|
2960 Fput (Qsyntax_table, Qchar_table_extra_slots, make_number (0)); |
d2fc560c7740
(Qsyntax_table): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13144
diff
changeset
|
2961 |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
2962 temp = XVECTOR (Vsyntax_code_object)->contents[(int) Swhitespace]; |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
2963 |
13218
d2fc560c7740
(Qsyntax_table): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13144
diff
changeset
|
2964 Vstandard_syntax_table = Fmake_char_table (Qsyntax_table, temp); |
163 | 2965 |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
2966 temp = XVECTOR (Vsyntax_code_object)->contents[(int) Sword]; |
163 | 2967 for (i = 'a'; i <= 'z'; i++) |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
2968 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, i, temp); |
163 | 2969 for (i = 'A'; i <= 'Z'; i++) |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
2970 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, i, temp); |
163 | 2971 for (i = '0'; i <= '9'; i++) |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
2972 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, i, temp); |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
2973 |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
2974 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, '$', temp); |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
2975 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, '%', temp); |
163 | 2976 |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
2977 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, '(', |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
2978 Fcons (make_number (Sopen), make_number (')'))); |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
2979 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, ')', |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
2980 Fcons (make_number (Sclose), make_number ('('))); |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
2981 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, '[', |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
2982 Fcons (make_number (Sopen), make_number (']'))); |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
2983 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, ']', |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
2984 Fcons (make_number (Sclose), make_number ('['))); |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
2985 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, '{', |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
2986 Fcons (make_number (Sopen), make_number ('}'))); |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
2987 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, '}', |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
2988 Fcons (make_number (Sclose), make_number ('{'))); |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
2989 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, '"', |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
2990 Fcons (make_number ((int) Sstring), Qnil)); |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
2991 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, '\\', |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
2992 Fcons (make_number ((int) Sescape), Qnil)); |
163 | 2993 |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
2994 temp = XVECTOR (Vsyntax_code_object)->contents[(int) Ssymbol]; |
163 | 2995 for (i = 0; i < 10; i++) |
17126
f8d7263cce09
(init_syntax_once): Add trick to avoid compiler warning
Kenichi Handa <handa@m17n.org>
parents:
17109
diff
changeset
|
2996 { |
f8d7263cce09
(init_syntax_once): Add trick to avoid compiler warning
Kenichi Handa <handa@m17n.org>
parents:
17109
diff
changeset
|
2997 c = "_-+*/&|<>="[i]; |
f8d7263cce09
(init_syntax_once): Add trick to avoid compiler warning
Kenichi Handa <handa@m17n.org>
parents:
17109
diff
changeset
|
2998 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, c, temp); |
f8d7263cce09
(init_syntax_once): Add trick to avoid compiler warning
Kenichi Handa <handa@m17n.org>
parents:
17109
diff
changeset
|
2999 } |
163 | 3000 |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
3001 temp = XVECTOR (Vsyntax_code_object)->contents[(int) Spunct]; |
163 | 3002 for (i = 0; i < 12; i++) |
17126
f8d7263cce09
(init_syntax_once): Add trick to avoid compiler warning
Kenichi Handa <handa@m17n.org>
parents:
17109
diff
changeset
|
3003 { |
f8d7263cce09
(init_syntax_once): Add trick to avoid compiler warning
Kenichi Handa <handa@m17n.org>
parents:
17109
diff
changeset
|
3004 c = ".,;:?!#@~^'`"[i]; |
f8d7263cce09
(init_syntax_once): Add trick to avoid compiler warning
Kenichi Handa <handa@m17n.org>
parents:
17109
diff
changeset
|
3005 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, c, temp); |
f8d7263cce09
(init_syntax_once): Add trick to avoid compiler warning
Kenichi Handa <handa@m17n.org>
parents:
17109
diff
changeset
|
3006 } |
27812
e2216823484d
(multibyte_syntax_as_symbol): New variable.
Kenichi Handa <handa@m17n.org>
parents:
27719
diff
changeset
|
3007 |
e2216823484d
(multibyte_syntax_as_symbol): New variable.
Kenichi Handa <handa@m17n.org>
parents:
27719
diff
changeset
|
3008 /* All multibyte characters have syntax `word' by default. */ |
e2216823484d
(multibyte_syntax_as_symbol): New variable.
Kenichi Handa <handa@m17n.org>
parents:
27719
diff
changeset
|
3009 temp = XVECTOR (Vsyntax_code_object)->contents[(int) Sword]; |
e2216823484d
(multibyte_syntax_as_symbol): New variable.
Kenichi Handa <handa@m17n.org>
parents:
27719
diff
changeset
|
3010 for (i = CHAR_TABLE_SINGLE_BYTE_SLOTS; i < CHAR_TABLE_ORDINARY_SLOTS; i++) |
e2216823484d
(multibyte_syntax_as_symbol): New variable.
Kenichi Handa <handa@m17n.org>
parents:
27719
diff
changeset
|
3011 XCHAR_TABLE (Vstandard_syntax_table)->contents[i] = temp; |
163 | 3012 } |
3013 | |
21514 | 3014 void |
163 | 3015 syms_of_syntax () |
3016 { | |
3017 Qsyntax_table_p = intern ("syntax-table-p"); | |
3018 staticpro (&Qsyntax_table_p); | |
3019 | |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
3020 staticpro (&Vsyntax_code_object); |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
3021 |
16992
ff7346c31184
(scan_lists): Signal errors using scan-error.
Richard M. Stallman <rms@gnu.org>
parents:
16039
diff
changeset
|
3022 Qscan_error = intern ("scan-error"); |
ff7346c31184
(scan_lists): Signal errors using scan-error.
Richard M. Stallman <rms@gnu.org>
parents:
16039
diff
changeset
|
3023 staticpro (&Qscan_error); |
ff7346c31184
(scan_lists): Signal errors using scan-error.
Richard M. Stallman <rms@gnu.org>
parents:
16039
diff
changeset
|
3024 Fput (Qscan_error, Qerror_conditions, |
23503
ce7900230b17
(syms_of_syntax): Fix the setup of Qscan_error.
Richard M. Stallman <rms@gnu.org>
parents:
23404
diff
changeset
|
3025 Fcons (Qscan_error, Fcons (Qerror, Qnil))); |
16992
ff7346c31184
(scan_lists): Signal errors using scan-error.
Richard M. Stallman <rms@gnu.org>
parents:
16039
diff
changeset
|
3026 Fput (Qscan_error, Qerror_message, |
ff7346c31184
(scan_lists): Signal errors using scan-error.
Richard M. Stallman <rms@gnu.org>
parents:
16039
diff
changeset
|
3027 build_string ("Scan error")); |
ff7346c31184
(scan_lists): Signal errors using scan-error.
Richard M. Stallman <rms@gnu.org>
parents:
16039
diff
changeset
|
3028 |
163 | 3029 DEFVAR_BOOL ("parse-sexp-ignore-comments", &parse_sexp_ignore_comments, |
3030 "Non-nil means `forward-sexp', etc., should treat comments as whitespace."); | |
3031 | |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
3032 DEFVAR_BOOL ("parse-sexp-lookup-properties", &parse_sexp_lookup_properties, |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
3033 "Non-nil means `forward-sexp', etc., grant `syntax-table' property.\n\ |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
3034 The value of this property should be either a syntax table, or a cons\n\ |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
3035 of the form (SYNTAXCODE . MATCHCHAR), SYNTAXCODE being the numeric\n\ |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
3036 syntax code, MATCHCHAR being nil or the character to match (which is\n\ |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
3037 relevant only for open/close type."); |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
3038 |
163 | 3039 words_include_escapes = 0; |
3040 DEFVAR_BOOL ("words-include-escapes", &words_include_escapes, | |
3041 "Non-nil means `forward-word', etc., should treat escape chars part of words."); | |
3042 | |
27812
e2216823484d
(multibyte_syntax_as_symbol): New variable.
Kenichi Handa <handa@m17n.org>
parents:
27719
diff
changeset
|
3043 DEFVAR_BOOL ("multibyte-syntax-as-symbol", &multibyte_syntax_as_symbol, |
e2216823484d
(multibyte_syntax_as_symbol): New variable.
Kenichi Handa <handa@m17n.org>
parents:
27719
diff
changeset
|
3044 "Non-nil means `scan-sexps' treats all multibyte characters as symbol."); |
e2216823484d
(multibyte_syntax_as_symbol): New variable.
Kenichi Handa <handa@m17n.org>
parents:
27719
diff
changeset
|
3045 multibyte_syntax_as_symbol = 0; |
e2216823484d
(multibyte_syntax_as_symbol): New variable.
Kenichi Handa <handa@m17n.org>
parents:
27719
diff
changeset
|
3046 |
28302
27ffe1e3b06d
(open_paren_in_column_0_is_defun_start): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3047 DEFVAR_BOOL ("open-paren-in-column-0-is-defun-start", |
27ffe1e3b06d
(open_paren_in_column_0_is_defun_start): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3048 &open_paren_in_column_0_is_defun_start, |
27ffe1e3b06d
(open_paren_in_column_0_is_defun_start): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3049 "Non-nil means an open paren in column 0 denotes the start of a defun."); |
27ffe1e3b06d
(open_paren_in_column_0_is_defun_start): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3050 open_paren_in_column_0_is_defun_start = 1; |
27ffe1e3b06d
(open_paren_in_column_0_is_defun_start): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
28269
diff
changeset
|
3051 |
163 | 3052 defsubr (&Ssyntax_table_p); |
3053 defsubr (&Ssyntax_table); | |
3054 defsubr (&Sstandard_syntax_table); | |
3055 defsubr (&Scopy_syntax_table); | |
3056 defsubr (&Sset_syntax_table); | |
3057 defsubr (&Schar_syntax); | |
7968
a6372621abd9
(Fmatching_paren): New function.
Richard M. Stallman <rms@gnu.org>
parents:
7924
diff
changeset
|
3058 defsubr (&Smatching_paren); |
32506
a85522b7799c
(Fstring_to_syntax): New function extracted from Fmodify_syntax_entry.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32496
diff
changeset
|
3059 defsubr (&Sstring_to_syntax); |
163 | 3060 defsubr (&Smodify_syntax_entry); |
3061 defsubr (&Sdescribe_syntax); | |
3062 | |
3063 defsubr (&Sforward_word); | |
3064 | |
17464
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
3065 defsubr (&Sskip_chars_forward); |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
3066 defsubr (&Sskip_chars_backward); |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
3067 defsubr (&Sskip_syntax_forward); |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
3068 defsubr (&Sskip_syntax_backward); |
36483a1ada24
(SYNTAX_ENTRY_VIA_PROPERTY): Set to take `syntax-table'
Richard M. Stallman <rms@gnu.org>
parents:
17126
diff
changeset
|
3069 |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
3070 defsubr (&Sforward_comment); |
163 | 3071 defsubr (&Sscan_lists); |
3072 defsubr (&Sscan_sexps); | |
3073 defsubr (&Sbackward_prefix_chars); | |
3074 defsubr (&Sparse_partial_sexp); | |
3075 } |