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