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