Mercurial > emacs
annotate src/syntax.c @ 17229:b48a8dd2d8ce
(imenu-scanning-message): Support for bigger numbers.
(imenu--generic-function): Fixed probably a typo: named appeared
twice in an item. Put function after name and beg in a special
item because a normal item has name and beg (for orthogonality).
(imenu-add-to-menubar): First test to see if the mode supports imenu.
(imenu--menubar-select): Use the defined variable imenu-rescan-item.
(imenu-default-goto-function): New subroutine, broken out of `imenu'.
(imenu-default-goto-function): New variable.
(imenu): Made it use the above function, via that variable.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sat, 22 Mar 1997 23:42:48 +0000 |
parents | f8d7263cce09 |
children | 36483a1ada24 |
rev | line source |
---|---|
163 | 1 /* GNU Emacs routines to deal with syntax tables; also word and list parsing. |
10457
2ab3bd0288a9
Change all occurences of SWITCH_ENUM_BUG to use SWITCH_ENUM_CAST instead.
Karl Heuer <kwzh@gnu.org>
parents:
9863
diff
changeset
|
2 Copyright (C) 1985, 1987, 1993, 1994, 1995 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" |
163 | 28 #include "syntax.h" |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
29 #include "category.h" |
163 | 30 |
16992
ff7346c31184
(scan_lists): Signal errors using scan-error.
Richard M. Stallman <rms@gnu.org>
parents:
16039
diff
changeset
|
31 Lisp_Object Qsyntax_table_p, Qsyntax_table, Qscan_error; |
163 | 32 |
3720
408c7ee69be7
(scan_lists, Fforward_comment): Pass 0 as commentstop arg
Richard M. Stallman <rms@gnu.org>
parents:
3684
diff
changeset
|
33 static void scan_sexps_forward (); |
408c7ee69be7
(scan_lists, Fforward_comment): Pass 0 as commentstop arg
Richard M. Stallman <rms@gnu.org>
parents:
3684
diff
changeset
|
34 static int char_quoted (); |
408c7ee69be7
(scan_lists, Fforward_comment): Pass 0 as commentstop arg
Richard M. Stallman <rms@gnu.org>
parents:
3684
diff
changeset
|
35 |
163 | 36 int words_include_escapes; |
37 | |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
38 /* 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
|
39 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
|
40 only very temporarily. */ |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
41 Lisp_Object syntax_temp; |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
42 |
1085
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
43 /* 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
|
44 |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
45 struct lisp_parse_state |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
46 { |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
47 int depth; /* Depth at end of parsing */ |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
48 int instring; /* -1 if not within string, else desired terminator. */ |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
49 int incomment; /* Nonzero if within a comment at end of parsing */ |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
50 int comstyle; /* comment style a=0, or b=1 */ |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
51 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
|
52 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
|
53 int prevlevelstart; /* Char number of start of containing expression */ |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
54 int location; /* Char number at which parsing stopped. */ |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
55 int mindepth; /* Minimum depth seen while scanning. */ |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
56 int comstart; /* Position just after last comment starter. */ |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
57 }; |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
58 |
1167
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
59 /* 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
|
60 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
|
61 find_start_value is the defun start position found for it. |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
62 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
|
63 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
|
64 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
|
65 |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
66 static int find_start_pos; |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
67 static int find_start_value; |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
68 static struct buffer *find_start_buffer; |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
69 static int find_start_begv; |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
70 static int find_start_modiff; |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
71 |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
72 /* 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
|
73 We record what we find, so that another call in the same area |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
74 can return the same value right away. */ |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
75 |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
76 static int |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
77 find_defun_start (pos) |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
78 int pos; |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
79 { |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
80 int tem; |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
81 int shortage; |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
82 |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
83 /* 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
|
84 if (current_buffer == find_start_buffer |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
85 /* 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
|
86 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
|
87 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
|
88 && pos <= find_start_pos + 1000 |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
89 && pos >= find_start_value |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
90 && BEGV == find_start_begv |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
91 && MODIFF == find_start_modiff) |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
92 return find_start_value; |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
93 |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
94 /* Back up to start of line. */ |
9411
0b9c70f56cf8
* syntax.c (find_defun_start): Call scan_buffer with new args.
Jim Blandy <jimb@redhat.com>
parents:
9333
diff
changeset
|
95 tem = scan_buffer ('\n', pos, BEGV, -1, &shortage, 1); |
1167
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
96 |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
97 while (tem > BEGV) |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
98 { |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
99 /* Open-paren at start of line means we found our defun-start. */ |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
100 if (SYNTAX (FETCH_CHAR (tem)) == Sopen) |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
101 break; |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
102 /* Move to beg of previous line. */ |
9411
0b9c70f56cf8
* syntax.c (find_defun_start): Call scan_buffer with new args.
Jim Blandy <jimb@redhat.com>
parents:
9333
diff
changeset
|
103 tem = scan_buffer ('\n', tem, BEGV, -2, &shortage, 1); |
1167
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
104 } |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
105 |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
106 /* Record what we found, for the next try. */ |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
107 find_start_value = tem; |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
108 find_start_buffer = current_buffer; |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
109 find_start_modiff = MODIFF; |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
110 find_start_begv = BEGV; |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
111 find_start_pos = pos; |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
112 |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
113 return find_start_value; |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
114 } |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
115 |
163 | 116 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
|
117 "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
|
118 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
|
119 (object) |
1709d9f11c66
(Fsyntax_table_p, Fchar_syntax, Fmatching_paren, Fmodify_syntax_entry):
Erik Naggum <erik@naggum.no>
parents:
13513
diff
changeset
|
120 Lisp_Object object; |
163 | 121 { |
14087
1709d9f11c66
(Fsyntax_table_p, Fchar_syntax, Fmatching_paren, Fmodify_syntax_entry):
Erik Naggum <erik@naggum.no>
parents:
13513
diff
changeset
|
122 if (CHAR_TABLE_P (object) |
1709d9f11c66
(Fsyntax_table_p, Fchar_syntax, Fmatching_paren, Fmodify_syntax_entry):
Erik Naggum <erik@naggum.no>
parents:
13513
diff
changeset
|
123 && XCHAR_TABLE (object)->purpose == Qsyntax_table) |
163 | 124 return Qt; |
125 return Qnil; | |
126 } | |
127 | |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
128 static void |
163 | 129 check_syntax_table (obj) |
130 Lisp_Object obj; | |
131 { | |
13513
907544cb2c7d
(check_syntax_table): Check the purpose slot.
Richard M. Stallman <rms@gnu.org>
parents:
13218
diff
changeset
|
132 if (!(CHAR_TABLE_P (obj) |
907544cb2c7d
(check_syntax_table): Check the purpose slot.
Richard M. Stallman <rms@gnu.org>
parents:
13218
diff
changeset
|
133 && XCHAR_TABLE (obj)->purpose == Qsyntax_table)) |
907544cb2c7d
(check_syntax_table): Check the purpose slot.
Richard M. Stallman <rms@gnu.org>
parents:
13218
diff
changeset
|
134 wrong_type_argument (Qsyntax_table_p, obj); |
163 | 135 } |
136 | |
137 DEFUN ("syntax-table", Fsyntax_table, Ssyntax_table, 0, 0, 0, | |
138 "Return the current syntax table.\n\ | |
139 This is the one specified by the current buffer.") | |
140 () | |
141 { | |
142 return current_buffer->syntax_table; | |
143 } | |
144 | |
145 DEFUN ("standard-syntax-table", Fstandard_syntax_table, | |
146 Sstandard_syntax_table, 0, 0, 0, | |
147 "Return the standard syntax table.\n\ | |
148 This is the one used for new buffers.") | |
149 () | |
150 { | |
151 return Vstandard_syntax_table; | |
152 } | |
153 | |
154 DEFUN ("copy-syntax-table", Fcopy_syntax_table, Scopy_syntax_table, 0, 1, 0, | |
155 "Construct a new syntax table and return it.\n\ | |
156 It is a copy of the TABLE, which defaults to the standard syntax table.") | |
157 (table) | |
158 Lisp_Object table; | |
159 { | |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
160 Lisp_Object copy; |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
161 |
485 | 162 if (!NILP (table)) |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
163 check_syntax_table (table); |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
164 else |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
165 table = Vstandard_syntax_table; |
163 | 166 |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
167 copy = Fcopy_sequence (table); |
14661
46ba65e7976c
(Fcopy_syntax_table): Set default to nil.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
168 |
46ba65e7976c
(Fcopy_syntax_table): Set default to nil.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
169 /* 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
|
170 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
|
171 XCHAR_TABLE (copy)->defalt = Qnil; |
46ba65e7976c
(Fcopy_syntax_table): Set default to nil.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
172 |
46ba65e7976c
(Fcopy_syntax_table): Set default to nil.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
173 /* 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
|
174 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
|
175 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
|
176 if (NILP (XCHAR_TABLE (copy)->parent)) |
46ba65e7976c
(Fcopy_syntax_table): Set default to nil.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
177 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
|
178 return copy; |
163 | 179 } |
180 | |
181 DEFUN ("set-syntax-table", Fset_syntax_table, Sset_syntax_table, 1, 1, 0, | |
182 "Select a new syntax table for the current buffer.\n\ | |
183 One argument, a syntax table.") | |
184 (table) | |
185 Lisp_Object table; | |
186 { | |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
187 check_syntax_table (table); |
163 | 188 current_buffer->syntax_table = table; |
189 /* Indicate that this buffer now has a specified syntax table. */ | |
3684
2be7629a9e17
(Fset_syntax_table): Add XFASTINT.
Richard M. Stallman <rms@gnu.org>
parents:
3609
diff
changeset
|
190 current_buffer->local_var_flags |
2be7629a9e17
(Fset_syntax_table): Add XFASTINT.
Richard M. Stallman <rms@gnu.org>
parents:
3609
diff
changeset
|
191 |= XFASTINT (buffer_local_flags.syntax_table); |
163 | 192 return table; |
193 } | |
194 | |
195 /* Convert a letter which signifies a syntax code | |
196 into the code it signifies. | |
197 This is used by modify-syntax-entry, and other things. */ | |
198 | |
199 unsigned char syntax_spec_code[0400] = | |
200 { 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377, | |
201 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377, | |
202 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377, | |
203 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377, | |
204 (char) Swhitespace, 0377, (char) Sstring, 0377, | |
205 (char) Smath, 0377, 0377, (char) Squote, | |
206 (char) Sopen, (char) Sclose, 0377, 0377, | |
207 0377, (char) Swhitespace, (char) Spunct, (char) Scharquote, | |
208 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377, | |
209 0377, 0377, 0377, 0377, | |
210 (char) Scomment, 0377, (char) Sendcomment, 0377, | |
5442
8cbae747a768
(describe_syntax): Handle Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
5339
diff
changeset
|
211 (char) Sinherit, 0377, 0377, 0377, 0377, 0377, 0377, 0377, /* @, A ... */ |
163 | 212 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377, |
213 0377, 0377, 0377, 0377, 0377, 0377, 0377, (char) Sword, | |
214 0377, 0377, 0377, 0377, (char) Sescape, 0377, 0377, (char) Ssymbol, | |
215 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377, /* `, a, ... */ | |
216 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377, | |
217 0377, 0377, 0377, 0377, 0377, 0377, 0377, (char) Sword, | |
218 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377 | |
219 }; | |
220 | |
221 /* Indexed by syntax code, give the letter that describes it. */ | |
222 | |
5442
8cbae747a768
(describe_syntax): Handle Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
5339
diff
changeset
|
223 char syntax_code_spec[14] = |
163 | 224 { |
5442
8cbae747a768
(describe_syntax): Handle Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
5339
diff
changeset
|
225 ' ', '.', 'w', '_', '(', ')', '\'', '\"', '$', '\\', '/', '<', '>', '@' |
163 | 226 }; |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
227 |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
228 /* 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
|
229 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
|
230 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
|
231 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
|
232 compact listing. */ |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
233 static Lisp_Object Vsyntax_code_object; |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
234 |
163 | 235 |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
236 /* 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
|
237 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
|
238 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
|
239 |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
240 Lisp_Object |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
241 syntax_parent_lookup (table, character) |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
242 Lisp_Object table; |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
243 int character; |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
244 { |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
245 Lisp_Object value; |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
246 |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
247 while (1) |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
248 { |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
249 table = XCHAR_TABLE (table)->parent; |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
250 if (NILP (table)) |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
251 return Qnil; |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
252 |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
253 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
|
254 if (!NILP (value)) |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
255 return value; |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
256 } |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
257 } |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
258 |
163 | 259 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
|
260 "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
|
261 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
|
262 the character `w' is returned.\n\ |
163 | 263 The characters that correspond to various syntax codes\n\ |
264 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
|
265 (character) |
1709d9f11c66
(Fsyntax_table_p, Fchar_syntax, Fmatching_paren, Fmodify_syntax_entry):
Erik Naggum <erik@naggum.no>
parents:
13513
diff
changeset
|
266 Lisp_Object character; |
163 | 267 { |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
268 int char_int; |
14087
1709d9f11c66
(Fsyntax_table_p, Fchar_syntax, Fmatching_paren, Fmodify_syntax_entry):
Erik Naggum <erik@naggum.no>
parents:
13513
diff
changeset
|
269 CHECK_NUMBER (character, 0); |
1709d9f11c66
(Fsyntax_table_p, Fchar_syntax, Fmatching_paren, Fmodify_syntax_entry):
Erik Naggum <erik@naggum.no>
parents:
13513
diff
changeset
|
270 char_int = XINT (character); |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
271 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
|
272 } |
a6372621abd9
(Fmatching_paren): New function.
Richard M. Stallman <rms@gnu.org>
parents:
7924
diff
changeset
|
273 |
a6372621abd9
(Fmatching_paren): New function.
Richard M. Stallman <rms@gnu.org>
parents:
7924
diff
changeset
|
274 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
|
275 "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
|
276 (character) |
1709d9f11c66
(Fsyntax_table_p, Fchar_syntax, Fmatching_paren, Fmodify_syntax_entry):
Erik Naggum <erik@naggum.no>
parents:
13513
diff
changeset
|
277 Lisp_Object character; |
7968
a6372621abd9
(Fmatching_paren): New function.
Richard M. Stallman <rms@gnu.org>
parents:
7924
diff
changeset
|
278 { |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
279 int char_int, code; |
14087
1709d9f11c66
(Fsyntax_table_p, Fchar_syntax, Fmatching_paren, Fmodify_syntax_entry):
Erik Naggum <erik@naggum.no>
parents:
13513
diff
changeset
|
280 CHECK_NUMBER (character, 0); |
1709d9f11c66
(Fsyntax_table_p, Fchar_syntax, Fmatching_paren, Fmodify_syntax_entry):
Erik Naggum <erik@naggum.no>
parents:
13513
diff
changeset
|
281 char_int = XINT (character); |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
282 code = SYNTAX (char_int); |
7975
49dc4ea976a0
(Fmatching_paren): Fix typo.
Richard M. Stallman <rms@gnu.org>
parents:
7968
diff
changeset
|
283 if (code == Sopen || code == Sclose) |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
284 return make_number (SYNTAX_MATCH (char_int)); |
7968
a6372621abd9
(Fmatching_paren): New function.
Richard M. Stallman <rms@gnu.org>
parents:
7924
diff
changeset
|
285 return Qnil; |
163 | 286 } |
287 | |
288 /* This comment supplies the doc string for modify-syntax-entry, | |
289 for make-docfile to see. We cannot put this in the real DEFUN | |
290 due to limits in the Unix cpp. | |
291 | |
4141
373bff27d0d6
* syntax.c (Fmodify_syntax_entry): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
3794
diff
changeset
|
292 DEFUN ("modify-syntax-entry", foo, bar, 2, 3, 0, |
163 | 293 "Set syntax for character CHAR according to string S.\n\ |
294 The syntax is changed only for table TABLE, which defaults to\n\ | |
295 the current buffer's syntax table.\n\ | |
296 The first character of S should be one of the following:\n\ | |
624 | 297 Space or - whitespace syntax. w word constituent.\n\ |
298 _ symbol constituent. . punctuation.\n\ | |
299 ( open-parenthesis. ) close-parenthesis.\n\ | |
300 \" string quote. \\ escape.\n\ | |
301 $ 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
|
302 < comment starter. > comment ender.\n\ |
5442
8cbae747a768
(describe_syntax): Handle Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
5339
diff
changeset
|
303 / 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
|
304 \n\ |
163 | 305 Only single-character comment start and end sequences are represented thus.\n\ |
306 Two-character sequences are represented as described below.\n\ | |
307 The second character of S is the matching parenthesis,\n\ | |
308 used only if the first character is `(' or `)'.\n\ | |
309 Any additional characters are flags.\n\ | |
1085
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
310 Defined flags are the characters 1, 2, 3, 4, b, and p.\n\ |
14087
1709d9f11c66
(Fsyntax_table_p, Fchar_syntax, Fmatching_paren, Fmodify_syntax_entry):
Erik Naggum <erik@naggum.no>
parents:
13513
diff
changeset
|
311 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
|
312 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
|
313 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
|
314 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
|
315 \n\ |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
316 There can be up to two orthogonal comment sequences. This is to support\n\ |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
317 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
|
318 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
|
319 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
|
320 this flag:\n\ |
14087
1709d9f11c66
(Fsyntax_table_p, Fchar_syntax, Fmatching_paren, Fmodify_syntax_entry):
Erik Naggum <erik@naggum.no>
parents:
13513
diff
changeset
|
321 b means CHAR is part of comment sequence b.\n\ |
1085
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
322 \n\ |
14087
1709d9f11c66
(Fsyntax_table_p, Fchar_syntax, Fmatching_paren, Fmodify_syntax_entry):
Erik Naggum <erik@naggum.no>
parents:
13513
diff
changeset
|
323 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
|
324 such characters are treated as whitespace when they occur\n\ |
163 | 325 between expressions.") |
4141
373bff27d0d6
* syntax.c (Fmodify_syntax_entry): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
3794
diff
changeset
|
326 (char, s, table) |
163 | 327 */ |
328 | |
329 DEFUN ("modify-syntax-entry", Fmodify_syntax_entry, Smodify_syntax_entry, 2, 3, | |
330 /* I really don't know why this is interactive | |
331 help-form should at least be made useful whilst reading the second arg | |
332 */ | |
333 "cSet syntax for character: \nsSet syntax for %s to: ", | |
334 0 /* See immediately above */) | |
335 (c, newentry, syntax_table) | |
336 Lisp_Object c, newentry, syntax_table; | |
337 { | |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
338 register unsigned char *p; |
163 | 339 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
|
340 int val; |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
341 Lisp_Object match; |
163 | 342 |
343 CHECK_NUMBER (c, 0); | |
344 CHECK_STRING (newentry, 1); | |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
345 |
485 | 346 if (NILP (syntax_table)) |
163 | 347 syntax_table = current_buffer->syntax_table; |
348 else | |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
349 check_syntax_table (syntax_table); |
163 | 350 |
351 p = XSTRING (newentry)->data; | |
352 code = (enum syntaxcode) syntax_spec_code[*p++]; | |
353 if (((int) code & 0377) == 0377) | |
354 error ("invalid syntax description letter: %c", c); | |
355 | |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
356 if (code == Sinherit) |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
357 { |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
358 SET_RAW_SYNTAX_ENTRY (syntax_table, c, Qnil); |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
359 return Qnil; |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
360 } |
163 | 361 |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
362 if (*p) |
13513
907544cb2c7d
(check_syntax_table): Check the purpose slot.
Richard M. Stallman <rms@gnu.org>
parents:
13218
diff
changeset
|
363 { |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
364 int len; |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
365 int character = STRING_CHAR_AND_LENGTH (p, XSTRING (newentry)->size - 1, |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
366 len); |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
367 XSETINT (match, character); |
13513
907544cb2c7d
(check_syntax_table): Check the purpose slot.
Richard M. Stallman <rms@gnu.org>
parents:
13218
diff
changeset
|
368 if (XFASTINT (match) == ' ') |
907544cb2c7d
(check_syntax_table): Check the purpose slot.
Richard M. Stallman <rms@gnu.org>
parents:
13218
diff
changeset
|
369 match = Qnil; |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
370 p += len; |
13513
907544cb2c7d
(check_syntax_table): Check the purpose slot.
Richard M. Stallman <rms@gnu.org>
parents:
13218
diff
changeset
|
371 } |
907544cb2c7d
(check_syntax_table): Check the purpose slot.
Richard M. Stallman <rms@gnu.org>
parents:
13218
diff
changeset
|
372 else |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
373 match = Qnil; |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
374 |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
375 val = (int) code; |
163 | 376 while (*p) |
377 switch (*p++) | |
378 { | |
379 case '1': | |
9333
925795f1a594
(Fmodify_syntax_entry): Don't use XFASTINT as an lvalue.
Karl Heuer <kwzh@gnu.org>
parents:
9320
diff
changeset
|
380 val |= 1 << 16; |
163 | 381 break; |
382 | |
383 case '2': | |
9333
925795f1a594
(Fmodify_syntax_entry): Don't use XFASTINT as an lvalue.
Karl Heuer <kwzh@gnu.org>
parents:
9320
diff
changeset
|
384 val |= 1 << 17; |
163 | 385 break; |
386 | |
387 case '3': | |
9333
925795f1a594
(Fmodify_syntax_entry): Don't use XFASTINT as an lvalue.
Karl Heuer <kwzh@gnu.org>
parents:
9320
diff
changeset
|
388 val |= 1 << 18; |
163 | 389 break; |
390 | |
391 case '4': | |
9333
925795f1a594
(Fmodify_syntax_entry): Don't use XFASTINT as an lvalue.
Karl Heuer <kwzh@gnu.org>
parents:
9320
diff
changeset
|
392 val |= 1 << 19; |
163 | 393 break; |
394 | |
395 case 'p': | |
9333
925795f1a594
(Fmodify_syntax_entry): Don't use XFASTINT as an lvalue.
Karl Heuer <kwzh@gnu.org>
parents:
9320
diff
changeset
|
396 val |= 1 << 20; |
163 | 397 break; |
1085
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
398 |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
399 case 'b': |
9333
925795f1a594
(Fmodify_syntax_entry): Don't use XFASTINT as an lvalue.
Karl Heuer <kwzh@gnu.org>
parents:
9320
diff
changeset
|
400 val |= 1 << 21; |
1085
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
401 break; |
163 | 402 } |
403 | |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
404 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
|
405 newentry = XVECTOR (Vsyntax_code_object)->contents[val]; |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
406 else |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
407 /* 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
|
408 newentry = Fcons (make_number (val), match); |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
409 |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
410 SET_RAW_SYNTAX_ENTRY (syntax_table, c, newentry); |
163 | 411 |
412 return Qnil; | |
413 } | |
414 | |
415 /* Dump syntax table to buffer in human-readable format */ | |
416 | |
3720
408c7ee69be7
(scan_lists, Fforward_comment): Pass 0 as commentstop arg
Richard M. Stallman <rms@gnu.org>
parents:
3684
diff
changeset
|
417 static void |
163 | 418 describe_syntax (value) |
419 Lisp_Object value; | |
420 { | |
421 register enum syntaxcode code; | |
1085
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
422 char desc, match, start1, start2, end1, end2, prefix, comstyle; |
163 | 423 char str[2]; |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
424 Lisp_Object first, match_lisp; |
163 | 425 |
426 Findent_to (make_number (16), make_number (1)); | |
427 | |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
428 if (NILP (value)) |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
429 { |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
430 insert_string ("default\n"); |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
431 return; |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
432 } |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
433 |
17109
dfe4f98935c4
(describe_syntax): Handle the case that the argument
Kenichi Handa <handa@m17n.org>
parents:
17044
diff
changeset
|
434 if (CHAR_TABLE_P (value)) |
dfe4f98935c4
(describe_syntax): Handle the case that the argument
Kenichi Handa <handa@m17n.org>
parents:
17044
diff
changeset
|
435 { |
dfe4f98935c4
(describe_syntax): Handle the case that the argument
Kenichi Handa <handa@m17n.org>
parents:
17044
diff
changeset
|
436 insert_string ("deeper char-table ...\n"); |
dfe4f98935c4
(describe_syntax): Handle the case that the argument
Kenichi Handa <handa@m17n.org>
parents:
17044
diff
changeset
|
437 return; |
dfe4f98935c4
(describe_syntax): Handle the case that the argument
Kenichi Handa <handa@m17n.org>
parents:
17044
diff
changeset
|
438 } |
dfe4f98935c4
(describe_syntax): Handle the case that the argument
Kenichi Handa <handa@m17n.org>
parents:
17044
diff
changeset
|
439 |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
440 if (!CONSP (value)) |
163 | 441 { |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
442 insert_string ("invalid\n"); |
163 | 443 return; |
444 } | |
445 | |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
446 first = XCONS (value)->car; |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
447 match_lisp = XCONS (value)->cdr; |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
448 |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
449 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
|
450 { |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
451 insert_string ("invalid\n"); |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
452 return; |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
453 } |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
454 |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
455 code = (enum syntaxcode) (first & 0377); |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
456 start1 = (XINT (first) >> 16) & 1; |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
457 start2 = (XINT (first) >> 17) & 1; |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
458 end1 = (XINT (first) >> 18) & 1; |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
459 end2 = (XINT (first) >> 19) & 1; |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
460 prefix = (XINT (first) >> 20) & 1; |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
461 comstyle = (XINT (first) >> 21) & 1; |
163 | 462 |
463 if ((int) code < 0 || (int) code >= (int) Smax) | |
464 { | |
465 insert_string ("invalid"); | |
466 return; | |
467 } | |
468 desc = syntax_code_spec[(int) code]; | |
469 | |
470 str[0] = desc, str[1] = 0; | |
471 insert (str, 1); | |
472 | |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
473 if (NILP (match_lisp)) |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
474 insert (" ", 1); |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
475 else |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
476 insert_char (XINT (match_lisp)); |
163 | 477 |
478 if (start1) | |
479 insert ("1", 1); | |
480 if (start2) | |
481 insert ("2", 1); | |
482 | |
483 if (end1) | |
484 insert ("3", 1); | |
485 if (end2) | |
486 insert ("4", 1); | |
487 | |
488 if (prefix) | |
489 insert ("p", 1); | |
1085
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
490 if (comstyle) |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
491 insert ("b", 1); |
163 | 492 |
493 insert_string ("\twhich means: "); | |
494 | |
10457
2ab3bd0288a9
Change all occurences of SWITCH_ENUM_BUG to use SWITCH_ENUM_CAST instead.
Karl Heuer <kwzh@gnu.org>
parents:
9863
diff
changeset
|
495 switch (SWITCH_ENUM_CAST (code)) |
163 | 496 { |
497 case Swhitespace: | |
498 insert_string ("whitespace"); break; | |
499 case Spunct: | |
500 insert_string ("punctuation"); break; | |
501 case Sword: | |
502 insert_string ("word"); break; | |
503 case Ssymbol: | |
504 insert_string ("symbol"); break; | |
505 case Sopen: | |
506 insert_string ("open"); break; | |
507 case Sclose: | |
508 insert_string ("close"); break; | |
509 case Squote: | |
510 insert_string ("quote"); break; | |
511 case Sstring: | |
512 insert_string ("string"); break; | |
513 case Smath: | |
514 insert_string ("math"); break; | |
515 case Sescape: | |
516 insert_string ("escape"); break; | |
517 case Scharquote: | |
518 insert_string ("charquote"); break; | |
519 case Scomment: | |
520 insert_string ("comment"); break; | |
521 case Sendcomment: | |
522 insert_string ("endcomment"); break; | |
523 default: | |
524 insert_string ("invalid"); | |
525 return; | |
526 } | |
527 | |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
528 if (!NILP (match_lisp)) |
163 | 529 { |
530 insert_string (", matches "); | |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
531 insert_char (XINT (match_lisp)); |
163 | 532 } |
533 | |
534 if (start1) | |
535 insert_string (",\n\t is the first character of a comment-start sequence"); | |
536 if (start2) | |
537 insert_string (",\n\t is the second character of a comment-start sequence"); | |
538 | |
539 if (end1) | |
540 insert_string (",\n\t is the first character of a comment-end sequence"); | |
541 if (end2) | |
542 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
|
543 if (comstyle) |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
544 insert_string (" (comment style b)"); |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
545 |
163 | 546 if (prefix) |
547 insert_string (",\n\t is a prefix character for `backward-prefix-chars'"); | |
548 | |
549 insert_string ("\n"); | |
550 } | |
551 | |
3720
408c7ee69be7
(scan_lists, Fforward_comment): Pass 0 as commentstop arg
Richard M. Stallman <rms@gnu.org>
parents:
3684
diff
changeset
|
552 static Lisp_Object |
163 | 553 describe_syntax_1 (vector) |
554 Lisp_Object vector; | |
555 { | |
556 struct buffer *old = current_buffer; | |
557 set_buffer_internal (XBUFFER (Vstandard_output)); | |
11972
be9d727c58c2
(describe_syntax_1): Pass new arg to describe_vector.
Karl Heuer <kwzh@gnu.org>
parents:
11922
diff
changeset
|
558 describe_vector (vector, Qnil, describe_syntax, 0, Qnil, Qnil); |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
559 while (! NILP (XCHAR_TABLE (vector)->parent)) |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
560 { |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
561 vector = XCHAR_TABLE (vector)->parent; |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
562 insert_string ("\nThe parent syntax table is:"); |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
563 describe_vector (vector, Qnil, describe_syntax, 0, Qnil, Qnil); |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
564 } |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
565 |
9863
f918fd077a9f
(describe_syntax_1): Set help-mode in *Help* buffer.
Karl Heuer <kwzh@gnu.org>
parents:
9475
diff
changeset
|
566 call0 (intern ("help-mode")); |
163 | 567 set_buffer_internal (old); |
568 return Qnil; | |
569 } | |
570 | |
571 DEFUN ("describe-syntax", Fdescribe_syntax, Sdescribe_syntax, 0, 0, "", | |
572 "Describe the syntax specifications in the syntax table.\n\ | |
573 The descriptions are inserted in a buffer, which is then displayed.") | |
574 () | |
575 { | |
576 internal_with_output_to_temp_buffer | |
577 ("*Help*", describe_syntax_1, current_buffer->syntax_table); | |
578 | |
579 return Qnil; | |
580 } | |
581 | |
582 /* Return the position across COUNT words from FROM. | |
583 If that many words cannot be found before the end of the buffer, return 0. | |
584 COUNT negative means scan backward and stop at word beginning. */ | |
585 | |
586 scan_words (from, count) | |
587 register int from, count; | |
588 { | |
589 register int beg = BEGV; | |
590 register int end = ZV; | |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
591 register enum syntaxcode code; |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
592 int ch0, ch1; |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
593 int temp_pos; |
163 | 594 |
595 immediate_quit = 1; | |
596 QUIT; | |
597 | |
598 while (count > 0) | |
599 { | |
600 while (1) | |
601 { | |
602 if (from == end) | |
603 { | |
604 immediate_quit = 0; | |
605 return 0; | |
606 } | |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
607 ch0 = FETCH_CHAR (from); |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
608 code = SYNTAX (ch0); |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
609 INC_POS (from); |
163 | 610 if (words_include_escapes |
611 && (code == Sescape || code == Scharquote)) | |
612 break; | |
613 if (code == Sword) | |
614 break; | |
615 } | |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
616 /* 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
|
617 position of the next character. */ |
163 | 618 while (1) |
619 { | |
620 if (from == end) break; | |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
621 ch1 = FETCH_CHAR (from); |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
622 code = SYNTAX (ch1); |
163 | 623 if (!(words_include_escapes |
624 && (code == Sescape || code == Scharquote))) | |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
625 if (code != Sword || WORD_BOUNDARY_P (ch0, ch1)) |
163 | 626 break; |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
627 INC_POS (from); |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
628 ch0 = ch1; |
163 | 629 } |
630 count--; | |
631 } | |
632 while (count < 0) | |
633 { | |
634 while (1) | |
635 { | |
636 if (from == beg) | |
637 { | |
638 immediate_quit = 0; | |
639 return 0; | |
640 } | |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
641 DEC_POS (from); |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
642 ch1 = FETCH_CHAR (from); |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
643 code = SYNTAX (ch1); |
163 | 644 if (words_include_escapes |
645 && (code == Sescape || code == Scharquote)) | |
646 break; | |
647 if (code == Sword) | |
648 break; | |
649 } | |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
650 /* 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
|
651 position of it. */ |
163 | 652 while (1) |
653 { | |
654 if (from == beg) break; | |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
655 temp_pos = from; |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
656 DEC_POS (temp_pos); |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
657 ch0 = FETCH_CHAR (temp_pos); |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
658 code = SYNTAX (ch0); |
163 | 659 if (!(words_include_escapes |
660 && (code == Sescape || code == Scharquote))) | |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
661 if (code != Sword || WORD_BOUNDARY_P (ch0, ch1)) |
163 | 662 break; |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
663 from = temp_pos; |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
664 ch1 = ch0; |
163 | 665 } |
666 count++; | |
667 } | |
668 | |
669 immediate_quit = 0; | |
670 | |
671 return from; | |
672 } | |
673 | |
674 DEFUN ("forward-word", Fforward_word, Sforward_word, 1, 1, "p", | |
675 "Move point forward ARG words (backward if ARG is negative).\n\ | |
676 Normally returns t.\n\ | |
677 If an edge of the buffer is reached, point is left there\n\ | |
678 and nil is returned.") | |
679 (count) | |
680 Lisp_Object count; | |
681 { | |
682 int val; | |
683 CHECK_NUMBER (count, 0); | |
684 | |
16039
855c8d8ba0f0
Change all references from point to PT.
Karl Heuer <kwzh@gnu.org>
parents:
14661
diff
changeset
|
685 if (!(val = scan_words (PT, XINT (count)))) |
163 | 686 { |
687 SET_PT (XINT (count) > 0 ? ZV : BEGV); | |
688 return Qnil; | |
689 } | |
690 SET_PT (val); | |
691 return Qt; | |
692 } | |
693 | |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
694 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
|
695 "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
|
696 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
|
697 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
|
698 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
|
699 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
|
700 (count) |
3095
ef7d99920f81
(Fforward_comment): Arg is a Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
3087
diff
changeset
|
701 Lisp_Object count; |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
702 { |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
703 register int from; |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
704 register int stop; |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
705 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
|
706 register enum syntaxcode code; |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
707 int comstyle = 0; /* style of comment encountered */ |
3087
ea0cb469490e
(Fforward_comment): Fix last change.
Richard M. Stallman <rms@gnu.org>
parents:
3086
diff
changeset
|
708 int found; |
3095
ef7d99920f81
(Fforward_comment): Arg is a Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
3087
diff
changeset
|
709 int count1; |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
710 int temp_pos; |
3095
ef7d99920f81
(Fforward_comment): Arg is a Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
3087
diff
changeset
|
711 |
ef7d99920f81
(Fforward_comment): Arg is a Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
3087
diff
changeset
|
712 CHECK_NUMBER (count, 0); |
ef7d99920f81
(Fforward_comment): Arg is a Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
3087
diff
changeset
|
713 count1 = XINT (count); |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
714 |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
715 immediate_quit = 1; |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
716 QUIT; |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
717 |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
718 from = PT; |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
719 |
3095
ef7d99920f81
(Fforward_comment): Arg is a Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
3087
diff
changeset
|
720 while (count1 > 0) |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
721 { |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
722 stop = ZV; |
6142
2dbc79d01191
(Fforward_comment): Do the right thing at eob.
Karl Heuer <kwzh@gnu.org>
parents:
5755
diff
changeset
|
723 do |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
724 { |
6142
2dbc79d01191
(Fforward_comment): Do the right thing at eob.
Karl Heuer <kwzh@gnu.org>
parents:
5755
diff
changeset
|
725 if (from == stop) |
2dbc79d01191
(Fforward_comment): Do the right thing at eob.
Karl Heuer <kwzh@gnu.org>
parents:
5755
diff
changeset
|
726 { |
2dbc79d01191
(Fforward_comment): Do the right thing at eob.
Karl Heuer <kwzh@gnu.org>
parents:
5755
diff
changeset
|
727 SET_PT (from); |
10947
e805ef6b931c
(Fforward_comment): Always clear immediate_quit for return.
Richard M. Stallman <rms@gnu.org>
parents:
10457
diff
changeset
|
728 immediate_quit = 0; |
6142
2dbc79d01191
(Fforward_comment): Do the right thing at eob.
Karl Heuer <kwzh@gnu.org>
parents:
5755
diff
changeset
|
729 return Qnil; |
2dbc79d01191
(Fforward_comment): Do the right thing at eob.
Karl Heuer <kwzh@gnu.org>
parents:
5755
diff
changeset
|
730 } |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
731 c = FETCH_CHAR (from); |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
732 code = SYNTAX (c); |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
733 INC_POS (from); |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
734 comstyle = 0; |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
735 if (from < stop && SYNTAX_COMSTART_FIRST (c) |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
736 && (c1 = FETCH_CHAR (from), |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
737 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
|
738 { |
4953
7545290052bf
(Fforward_comment): On backward scan, exit inner loop
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
739 /* 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
|
740 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
|
741 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
|
742 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
|
743 the comment section. */ |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
744 code = Scomment; |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
745 comstyle = SYNTAX_COMMENT_STYLE (c1); |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
746 INC_POS (from); |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
747 } |
6142
2dbc79d01191
(Fforward_comment): Do the right thing at eob.
Karl Heuer <kwzh@gnu.org>
parents:
5755
diff
changeset
|
748 } |
2dbc79d01191
(Fforward_comment): Do the right thing at eob.
Karl Heuer <kwzh@gnu.org>
parents:
5755
diff
changeset
|
749 while (code == Swhitespace || code == Sendcomment); |
2dbc79d01191
(Fforward_comment): Do the right thing at eob.
Karl Heuer <kwzh@gnu.org>
parents:
5755
diff
changeset
|
750 if (code != Scomment) |
2dbc79d01191
(Fforward_comment): Do the right thing at eob.
Karl Heuer <kwzh@gnu.org>
parents:
5755
diff
changeset
|
751 { |
2dbc79d01191
(Fforward_comment): Do the right thing at eob.
Karl Heuer <kwzh@gnu.org>
parents:
5755
diff
changeset
|
752 immediate_quit = 0; |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
753 DEC_POS (from); |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
754 SET_PT (from); |
6142
2dbc79d01191
(Fforward_comment): Do the right thing at eob.
Karl Heuer <kwzh@gnu.org>
parents:
5755
diff
changeset
|
755 return Qnil; |
2dbc79d01191
(Fforward_comment): Do the right thing at eob.
Karl Heuer <kwzh@gnu.org>
parents:
5755
diff
changeset
|
756 } |
2dbc79d01191
(Fforward_comment): Do the right thing at eob.
Karl Heuer <kwzh@gnu.org>
parents:
5755
diff
changeset
|
757 /* We're at the start of a comment. */ |
2dbc79d01191
(Fforward_comment): Do the right thing at eob.
Karl Heuer <kwzh@gnu.org>
parents:
5755
diff
changeset
|
758 while (1) |
2dbc79d01191
(Fforward_comment): Do the right thing at eob.
Karl Heuer <kwzh@gnu.org>
parents:
5755
diff
changeset
|
759 { |
2dbc79d01191
(Fforward_comment): Do the right thing at eob.
Karl Heuer <kwzh@gnu.org>
parents:
5755
diff
changeset
|
760 if (from == stop) |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
761 { |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
762 immediate_quit = 0; |
6142
2dbc79d01191
(Fforward_comment): Do the right thing at eob.
Karl Heuer <kwzh@gnu.org>
parents:
5755
diff
changeset
|
763 SET_PT (from); |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
764 return Qnil; |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
765 } |
6142
2dbc79d01191
(Fforward_comment): Do the right thing at eob.
Karl Heuer <kwzh@gnu.org>
parents:
5755
diff
changeset
|
766 c = FETCH_CHAR (from); |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
767 INC_POS (from); |
6142
2dbc79d01191
(Fforward_comment): Do the right thing at eob.
Karl Heuer <kwzh@gnu.org>
parents:
5755
diff
changeset
|
768 if (SYNTAX (c) == Sendcomment |
2dbc79d01191
(Fforward_comment): Do the right thing at eob.
Karl Heuer <kwzh@gnu.org>
parents:
5755
diff
changeset
|
769 && SYNTAX_COMMENT_STYLE (c) == comstyle) |
2dbc79d01191
(Fforward_comment): Do the right thing at eob.
Karl Heuer <kwzh@gnu.org>
parents:
5755
diff
changeset
|
770 /* we have encountered a comment end of the same style |
2dbc79d01191
(Fforward_comment): Do the right thing at eob.
Karl Heuer <kwzh@gnu.org>
parents:
5755
diff
changeset
|
771 as the comment sequence which began this comment |
2dbc79d01191
(Fforward_comment): Do the right thing at eob.
Karl Heuer <kwzh@gnu.org>
parents:
5755
diff
changeset
|
772 section */ |
2dbc79d01191
(Fforward_comment): Do the right thing at eob.
Karl Heuer <kwzh@gnu.org>
parents:
5755
diff
changeset
|
773 break; |
2dbc79d01191
(Fforward_comment): Do the right thing at eob.
Karl Heuer <kwzh@gnu.org>
parents:
5755
diff
changeset
|
774 if (from < stop && SYNTAX_COMEND_FIRST (c) |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
775 && (c1 = FETCH_CHAR (from), |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
776 SYNTAX_COMEND_SECOND (c1)) |
6142
2dbc79d01191
(Fforward_comment): Do the right thing at eob.
Karl Heuer <kwzh@gnu.org>
parents:
5755
diff
changeset
|
777 && SYNTAX_COMMENT_STYLE (c) == comstyle) |
2dbc79d01191
(Fforward_comment): Do the right thing at eob.
Karl Heuer <kwzh@gnu.org>
parents:
5755
diff
changeset
|
778 /* we have encountered a comment end of the same style |
2dbc79d01191
(Fforward_comment): Do the right thing at eob.
Karl Heuer <kwzh@gnu.org>
parents:
5755
diff
changeset
|
779 as the comment sequence which began this comment |
2dbc79d01191
(Fforward_comment): Do the right thing at eob.
Karl Heuer <kwzh@gnu.org>
parents:
5755
diff
changeset
|
780 section */ |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
781 { INC_POS (from); break; } |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
782 } |
6142
2dbc79d01191
(Fforward_comment): Do the right thing at eob.
Karl Heuer <kwzh@gnu.org>
parents:
5755
diff
changeset
|
783 /* We have skipped one comment. */ |
3095
ef7d99920f81
(Fforward_comment): Arg is a Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
3087
diff
changeset
|
784 count1--; |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
785 } |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
786 |
3095
ef7d99920f81
(Fforward_comment): Arg is a Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
3087
diff
changeset
|
787 while (count1 < 0) |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
788 { |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
789 stop = BEGV; |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
790 while (from > stop) |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
791 { |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
792 int quoted; |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
793 |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
794 DEC_POS (from); |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
795 quoted = char_quoted (from); |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
796 if (quoted) |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
797 DEC_POS (from); |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
798 c = FETCH_CHAR (from); |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
799 code = SYNTAX (c); |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
800 comstyle = 0; |
4953
7545290052bf
(Fforward_comment): On backward scan, exit inner loop
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
801 if (code == Sendcomment) |
7545290052bf
(Fforward_comment): On backward scan, exit inner loop
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
802 comstyle = SYNTAX_COMMENT_STYLE (c); |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
803 temp_pos = from; |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
804 DEC_POS (temp_pos); |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
805 if (from > stop && SYNTAX_COMEND_SECOND (c) |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
806 && (c1 = FETCH_CHAR (temp_pos), |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
807 SYNTAX_COMEND_FIRST (c1)) |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
808 && !char_quoted (temp_pos)) |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
809 { |
4953
7545290052bf
(Fforward_comment): On backward scan, exit inner loop
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
810 /* 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
|
811 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
|
812 sequence of the same style. */ |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
813 code = Sendcomment; |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
814 comstyle = SYNTAX_COMMENT_STYLE (c1); |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
815 from = temp_pos; |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
816 } |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
817 |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
818 if (code == Sendcomment && !quoted) |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
819 { |
3794
ea9d3f2cd5fa
(scan_lists, Fforward_comment): #if 0 the code
Richard M. Stallman <rms@gnu.org>
parents:
3720
diff
changeset
|
820 #if 0 |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
821 if (code != SYNTAX (c)) |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
822 /* For a two-char comment ender, we can assume |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
823 it does end a comment. So scan back in a simple way. */ |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
824 { |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
825 if (from != stop) DEC_POS (from); |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
826 while (1) |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
827 { |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
828 if ((c = FETCH_CHAR (from), |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
829 SYNTAX (c) == Scomment) |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
830 && SYNTAX_COMMENT_STYLE (c) == comstyle) |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
831 break; |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
832 if (from == stop) |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
833 { |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
834 immediate_quit = 0; |
3568
3ee951a22a80
(Fforward_comment): Set point to where scan stops,
Richard M. Stallman <rms@gnu.org>
parents:
3095
diff
changeset
|
835 SET_PT (from); |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
836 return Qnil; |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
837 } |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
838 DEC_POS (from); |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
839 if (SYNTAX_COMSTART_SECOND (c) |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
840 && (c1 = FETCH_CHAR (from), |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
841 SYNTAX_COMSTART_FIRST (c1)) |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
842 && SYNTAX_COMMENT_STYLE (c) == comstyle |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
843 && !char_quoted (from)) |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
844 break; |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
845 } |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
846 break; |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
847 } |
3794
ea9d3f2cd5fa
(scan_lists, Fforward_comment): #if 0 the code
Richard M. Stallman <rms@gnu.org>
parents:
3720
diff
changeset
|
848 #endif /* 0 */ |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
849 |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
850 /* Look back, counting the parity of string-quotes, |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
851 and recording the comment-starters seen. |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
852 When we reach a safe place, assume that's not in a string; |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
853 then step the main scan to the earliest comment-starter seen |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
854 an even number of string quotes away from the safe place. |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
855 |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
856 OFROM[I] is position of the earliest comment-starter seen |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
857 which is I+2X quotes from the comment-end. |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
858 PARITY is current parity of quotes from the comment end. */ |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
859 { |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
860 int parity = 0; |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
861 char my_stringend = 0; |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
862 int string_lossage = 0; |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
863 int comment_end = from; |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
864 int comstart_pos = 0; |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
865 int comstart_parity = 0; |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
866 int scanstart = from; |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
867 |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
868 DEC_POS (scanstart); |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
869 /* At beginning of range to scan, we're outside of strings; |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
870 that determines quote parity to the comment-end. */ |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
871 while (from != stop) |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
872 { |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
873 /* Move back and examine a character. */ |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
874 DEC_POS (from); |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
875 |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
876 c = FETCH_CHAR (from); |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
877 code = SYNTAX (c); |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
878 |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
879 /* If this char is the second of a 2-char comment sequence, |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
880 back up and give the pair the appropriate syntax. */ |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
881 temp_pos = from; |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
882 DEC_POS (temp_pos); |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
883 if (from > stop && SYNTAX_COMEND_SECOND (c) |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
884 && (c1 = FETCH_CHAR (temp_pos), |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
885 SYNTAX_COMEND_FIRST (c1))) |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
886 { |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
887 code = Sendcomment; |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
888 from = temp_pos; |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
889 c = c1; |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
890 } |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
891 |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
892 temp_pos = from; |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
893 INC_POS (temp_pos); |
8045
18c2ad4ddc83
(scan_lists, Fforward_comment): When moving backward over
Richard M. Stallman <rms@gnu.org>
parents:
7975
diff
changeset
|
894 /* If this char starts a 2-char comment start sequence, |
18c2ad4ddc83
(scan_lists, Fforward_comment): When moving backward over
Richard M. Stallman <rms@gnu.org>
parents:
7975
diff
changeset
|
895 treat it like a 1-char comment starter. */ |
18c2ad4ddc83
(scan_lists, Fforward_comment): When moving backward over
Richard M. Stallman <rms@gnu.org>
parents:
7975
diff
changeset
|
896 if (from < scanstart && SYNTAX_COMSTART_FIRST (c) |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
897 && (c1 = FETCH_CHAR (temp_pos), |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
898 SYNTAX_COMSTART_SECOND (c1)) |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
899 && comstyle == SYNTAX_COMMENT_STYLE (c1)) |
8045
18c2ad4ddc83
(scan_lists, Fforward_comment): When moving backward over
Richard M. Stallman <rms@gnu.org>
parents:
7975
diff
changeset
|
900 code = Scomment; |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
901 |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
902 /* Ignore escaped characters. */ |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
903 if (char_quoted (from)) |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
904 continue; |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
905 |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
906 /* Track parity of quotes. */ |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
907 if (code == Sstring) |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
908 { |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
909 parity ^= 1; |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
910 if (my_stringend == 0) |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
911 my_stringend = c; |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
912 /* If we have two kinds of string delimiters. |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
913 There's no way to grok this scanning backwards. */ |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
914 else if (my_stringend != c) |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
915 string_lossage = 1; |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
916 } |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
917 |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
918 /* Record comment-starters according to that |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
919 quote-parity to the comment-end. */ |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
920 if (code == Scomment) |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
921 { |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
922 comstart_parity = parity; |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
923 comstart_pos = from; |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
924 } |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
925 |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
926 /* If we find another earlier comment-ender, |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3568
diff
changeset
|
927 any comment-starts earlier than that don't count |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
928 (because they go with the earlier comment-ender). */ |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
929 if (code == Sendcomment |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
930 && SYNTAX_COMMENT_STYLE (FETCH_CHAR (from)) == comstyle) |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
931 break; |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
932 |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
933 /* Assume a defun-start point is outside of strings. */ |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
934 if (code == Sopen |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
935 && (from == stop || FETCH_BYTE (from - 1) == '\n')) |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
936 break; |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
937 } |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
938 |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
939 if (comstart_pos == 0) |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
940 from = comment_end; |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
941 /* If the earliest comment starter |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
942 is followed by uniform paired string quotes or none, |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
943 we know it can't be inside a string |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
944 since if it were then the comment ender would be inside one. |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
945 So it does start a comment. Skip back to it. */ |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
946 else if (comstart_parity == 0 && !string_lossage) |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
947 from = comstart_pos; |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
948 else |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
949 { |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
950 /* We had two kinds of string delimiters mixed up |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
951 together. Decode this going forwards. |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
952 Scan fwd from the previous comment ender |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
953 to the one in question; this records where we |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
954 last passed a comment starter. */ |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
955 struct lisp_parse_state state; |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
956 scan_sexps_forward (&state, find_defun_start (comment_end), |
3720
408c7ee69be7
(scan_lists, Fforward_comment): Pass 0 as commentstop arg
Richard M. Stallman <rms@gnu.org>
parents:
3684
diff
changeset
|
957 comment_end - 1, -10000, 0, Qnil, 0); |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
958 if (state.incomment) |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
959 from = state.comstart; |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
960 else |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
961 /* We can't grok this as a comment; scan it normally. */ |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
962 from = comment_end; |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
963 } |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
964 } |
4953
7545290052bf
(Fforward_comment): On backward scan, exit inner loop
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
965 /* We have skipped one comment. */ |
7545290052bf
(Fforward_comment): On backward scan, exit inner loop
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
966 break; |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
967 } |
3568
3ee951a22a80
(Fforward_comment): Set point to where scan stops,
Richard M. Stallman <rms@gnu.org>
parents:
3095
diff
changeset
|
968 else if ((code != Swhitespace && code != Scomment) || quoted) |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
969 { |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
970 immediate_quit = 0; |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
971 INC_POS (from); |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
972 SET_PT (from); |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
973 return Qnil; |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
974 } |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
975 } |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
976 |
3095
ef7d99920f81
(Fforward_comment): Arg is a Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
3087
diff
changeset
|
977 count1++; |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
978 } |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
979 |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
980 SET_PT (from); |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
981 immediate_quit = 0; |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
982 return Qt; |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
983 } |
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
984 |
163 | 985 int parse_sexp_ignore_comments; |
986 | |
987 Lisp_Object | |
988 scan_lists (from, count, depth, sexpflag) | |
989 register int from; | |
990 int count, depth, sexpflag; | |
991 { | |
992 Lisp_Object val; | |
993 register int stop; | |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
994 register int c, c1; |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
995 int stringterm; |
163 | 996 int quoted; |
997 int mathexit = 0; | |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
998 register enum syntaxcode code, temp_code; |
163 | 999 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
|
1000 int comstyle = 0; /* style of comment encountered */ |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1001 int temp_pos; |
16992
ff7346c31184
(scan_lists): Signal errors using scan-error.
Richard M. Stallman <rms@gnu.org>
parents:
16039
diff
changeset
|
1002 int last_good = from; |
163 | 1003 |
1004 if (depth > 0) min_depth = 0; | |
1005 | |
1006 immediate_quit = 1; | |
1007 QUIT; | |
1008 | |
1009 while (count > 0) | |
1010 { | |
1011 stop = ZV; | |
1012 while (from < stop) | |
1013 { | |
1014 c = FETCH_CHAR (from); | |
1085
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1015 code = SYNTAX (c); |
16992
ff7346c31184
(scan_lists): Signal errors using scan-error.
Richard M. Stallman <rms@gnu.org>
parents:
16039
diff
changeset
|
1016 if (depth == min_depth) |
ff7346c31184
(scan_lists): Signal errors using scan-error.
Richard M. Stallman <rms@gnu.org>
parents:
16039
diff
changeset
|
1017 last_good = from; |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1018 INC_POS (from); |
163 | 1019 if (from < stop && SYNTAX_COMSTART_FIRST (c) |
1020 && SYNTAX_COMSTART_SECOND (FETCH_CHAR (from)) | |
1021 && 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
|
1022 { |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1023 /* we have encountered a comment start sequence and we |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1024 are ignoring all text inside comments. we must record |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1025 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
|
1026 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
|
1027 the comment section */ |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1028 code = Scomment; |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1029 comstyle = SYNTAX_COMMENT_STYLE (FETCH_CHAR (from)); |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1030 INC_POS (from); |
1085
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1031 } |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1032 |
163 | 1033 if (SYNTAX_PREFIX (c)) |
1034 continue; | |
1035 | |
10457
2ab3bd0288a9
Change all occurences of SWITCH_ENUM_BUG to use SWITCH_ENUM_CAST instead.
Karl Heuer <kwzh@gnu.org>
parents:
9863
diff
changeset
|
1036 switch (SWITCH_ENUM_CAST (code)) |
163 | 1037 { |
1038 case Sescape: | |
1039 case Scharquote: | |
1040 if (from == stop) goto lose; | |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1041 INC_POS (from); |
163 | 1042 /* treat following character as a word constituent */ |
1043 case Sword: | |
1044 case Ssymbol: | |
1045 if (depth || !sexpflag) break; | |
1046 /* This word counts as a sexp; return at end of it. */ | |
1047 while (from < stop) | |
1048 { | |
10457
2ab3bd0288a9
Change all occurences of SWITCH_ENUM_BUG to use SWITCH_ENUM_CAST instead.
Karl Heuer <kwzh@gnu.org>
parents:
9863
diff
changeset
|
1049 switch (SWITCH_ENUM_CAST (SYNTAX (FETCH_CHAR (from)))) |
163 | 1050 { |
1051 case Scharquote: | |
1052 case Sescape: | |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1053 INC_POS (from); |
163 | 1054 if (from == stop) goto lose; |
1055 break; | |
1056 case Sword: | |
1057 case Ssymbol: | |
1058 case Squote: | |
1059 break; | |
1060 default: | |
1061 goto done; | |
1062 } | |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1063 INC_POS (from); |
163 | 1064 } |
1065 goto done; | |
1066 | |
1067 case Scomment: | |
1068 if (!parse_sexp_ignore_comments) break; | |
1069 while (1) | |
1070 { | |
7924
63a2327f0783
(scan_lists): Get error if eob within comment with depth!=0.
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
1071 if (from == stop) |
63a2327f0783
(scan_lists): Get error if eob within comment with depth!=0.
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
1072 { |
63a2327f0783
(scan_lists): Get error if eob within comment with depth!=0.
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
1073 if (depth == 0) |
63a2327f0783
(scan_lists): Get error if eob within comment with depth!=0.
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
1074 goto done; |
63a2327f0783
(scan_lists): Get error if eob within comment with depth!=0.
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
1075 goto lose; |
63a2327f0783
(scan_lists): Get error if eob within comment with depth!=0.
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
1076 } |
1085
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1077 c = FETCH_CHAR (from); |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1078 if (SYNTAX (c) == Sendcomment |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1079 && SYNTAX_COMMENT_STYLE (c) == comstyle) |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1080 /* we have encountered a comment end of the same style |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1081 as the comment sequence which began this comment |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1082 section */ |
163 | 1083 break; |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1084 INC_POS (from); |
163 | 1085 if (from < stop && SYNTAX_COMEND_FIRST (c) |
1085
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1086 && SYNTAX_COMEND_SECOND (FETCH_CHAR (from)) |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1087 && SYNTAX_COMMENT_STYLE (c) == comstyle) |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1088 /* we have encountered a comment end of the same style |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1089 as the comment sequence which began this comment |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1090 section */ |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1091 { INC_POS (from); break; } |
163 | 1092 } |
1093 break; | |
1094 | |
1095 case Smath: | |
1096 if (!sexpflag) | |
1097 break; | |
1098 if (from != stop && c == FETCH_CHAR (from)) | |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1099 INC_POS (from); |
163 | 1100 if (mathexit) |
1101 { | |
1102 mathexit = 0; | |
1103 goto close1; | |
1104 } | |
1105 mathexit = 1; | |
1106 | |
1107 case Sopen: | |
1108 if (!++depth) goto done; | |
1109 break; | |
1110 | |
1111 case Sclose: | |
1112 close1: | |
1113 if (!--depth) goto done; | |
1114 if (depth < min_depth) | |
16992
ff7346c31184
(scan_lists): Signal errors using scan-error.
Richard M. Stallman <rms@gnu.org>
parents:
16039
diff
changeset
|
1115 Fsignal (Qscan_error, |
ff7346c31184
(scan_lists): Signal errors using scan-error.
Richard M. Stallman <rms@gnu.org>
parents:
16039
diff
changeset
|
1116 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
|
1117 Fcons (make_number (last_good), |
ff7346c31184
(scan_lists): Signal errors using scan-error.
Richard M. Stallman <rms@gnu.org>
parents:
16039
diff
changeset
|
1118 Fcons (make_number (from), Qnil)))); |
163 | 1119 break; |
1120 | |
1121 case Sstring: | |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1122 temp_pos = from; |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1123 DEC_POS (temp_pos); |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1124 stringterm = FETCH_CHAR (temp_pos); |
163 | 1125 while (1) |
1126 { | |
1127 if (from >= stop) goto lose; | |
1128 if (FETCH_CHAR (from) == stringterm) break; | |
10457
2ab3bd0288a9
Change all occurences of SWITCH_ENUM_BUG to use SWITCH_ENUM_CAST instead.
Karl Heuer <kwzh@gnu.org>
parents:
9863
diff
changeset
|
1129 switch (SWITCH_ENUM_CAST (SYNTAX (FETCH_CHAR (from)))) |
163 | 1130 { |
1131 case Scharquote: | |
1132 case Sescape: | |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1133 INC_POS (from); |
163 | 1134 } |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1135 INC_POS (from); |
163 | 1136 } |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1137 INC_POS (from); |
163 | 1138 if (!depth && sexpflag) goto done; |
1139 break; | |
1140 } | |
1141 } | |
1142 | |
1143 /* Reached end of buffer. Error if within object, return nil if between */ | |
1144 if (depth) goto lose; | |
1145 | |
1146 immediate_quit = 0; | |
1147 return Qnil; | |
1148 | |
1149 /* End of object reached */ | |
1150 done: | |
1151 count--; | |
1152 } | |
1153 | |
1154 while (count < 0) | |
1155 { | |
1156 stop = BEGV; | |
1157 while (from > stop) | |
1158 { | |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1159 DEC_POS (from); |
163 | 1160 if (quoted = char_quoted (from)) |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1161 DEC_POS (from); |
163 | 1162 c = FETCH_CHAR (from); |
1163 code = SYNTAX (c); | |
16992
ff7346c31184
(scan_lists): Signal errors using scan-error.
Richard M. Stallman <rms@gnu.org>
parents:
16039
diff
changeset
|
1164 if (depth == min_depth) |
ff7346c31184
(scan_lists): Signal errors using scan-error.
Richard M. Stallman <rms@gnu.org>
parents:
16039
diff
changeset
|
1165 last_good = from; |
4953
7545290052bf
(Fforward_comment): On backward scan, exit inner loop
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
1166 comstyle = 0; |
7545290052bf
(Fforward_comment): On backward scan, exit inner loop
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
1167 if (code == Sendcomment) |
7545290052bf
(Fforward_comment): On backward scan, exit inner loop
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
1168 comstyle = SYNTAX_COMMENT_STYLE (c); |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1169 temp_pos = from; |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1170 DEC_POS (temp_pos); |
163 | 1171 if (from > stop && SYNTAX_COMEND_SECOND (c) |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1172 && (c1 = FETCH_CHAR (temp_pos), SYNTAX_COMEND_FIRST (c1)) |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1173 && !char_quoted (temp_pos) |
163 | 1174 && 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
|
1175 { |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1176 /* we must record the comment style encountered so that |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1177 later, we can match only the proper comment begin |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1178 sequence of the same style */ |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1179 code = Sendcomment; |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1180 comstyle = SYNTAX_COMMENT_STYLE (c1); |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1181 from = temp_pos; |
1085
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1182 } |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1183 |
163 | 1184 if (SYNTAX_PREFIX (c)) |
1185 continue; | |
1186 | |
10457
2ab3bd0288a9
Change all occurences of SWITCH_ENUM_BUG to use SWITCH_ENUM_CAST instead.
Karl Heuer <kwzh@gnu.org>
parents:
9863
diff
changeset
|
1187 switch (SWITCH_ENUM_CAST (quoted ? Sword : code)) |
163 | 1188 { |
1189 case Sword: | |
1190 case Ssymbol: | |
1191 if (depth || !sexpflag) break; | |
1192 /* This word counts as a sexp; count object finished after passing it. */ | |
1193 while (from > stop) | |
1194 { | |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1195 temp_pos = from; |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1196 DEC_POS (temp_pos); |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1197 quoted = char_quoted (temp_pos); |
163 | 1198 if (quoted) |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1199 { |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1200 from = temp_pos; |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1201 DEC_POS (temp_pos); |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1202 } |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1203 c1 = FETCH_CHAR (temp_pos); |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1204 temp_code = SYNTAX (c1); |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1205 if (! (quoted || temp_code == Sword |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1206 || temp_code == Ssymbol |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1207 || temp_code == Squote)) |
163 | 1208 goto done2; |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1209 from = temp_pos; |
163 | 1210 } |
1211 goto done2; | |
1212 | |
1213 case Smath: | |
1214 if (!sexpflag) | |
1215 break; | |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1216 temp_pos = from; |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1217 DEC_POS (temp_pos); |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1218 if (from != stop && c == FETCH_CHAR (temp_pos)) |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1219 from = temp_pos; |
163 | 1220 if (mathexit) |
1221 { | |
1222 mathexit = 0; | |
1223 goto open2; | |
1224 } | |
1225 mathexit = 1; | |
1226 | |
1227 case Sclose: | |
1228 if (!++depth) goto done2; | |
1229 break; | |
1230 | |
1231 case Sopen: | |
1232 open2: | |
1233 if (!--depth) goto done2; | |
1234 if (depth < min_depth) | |
16992
ff7346c31184
(scan_lists): Signal errors using scan-error.
Richard M. Stallman <rms@gnu.org>
parents:
16039
diff
changeset
|
1235 Fsignal (Qscan_error, |
ff7346c31184
(scan_lists): Signal errors using scan-error.
Richard M. Stallman <rms@gnu.org>
parents:
16039
diff
changeset
|
1236 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
|
1237 Fcons (make_number (last_good), |
ff7346c31184
(scan_lists): Signal errors using scan-error.
Richard M. Stallman <rms@gnu.org>
parents:
16039
diff
changeset
|
1238 Fcons (make_number (from), Qnil)))); |
163 | 1239 break; |
1240 | |
1241 case Sendcomment: | |
1242 if (!parse_sexp_ignore_comments) | |
1243 break; | |
3794
ea9d3f2cd5fa
(scan_lists, Fforward_comment): #if 0 the code
Richard M. Stallman <rms@gnu.org>
parents:
3720
diff
changeset
|
1244 #if 0 |
1167
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
1245 if (code != SYNTAX (c)) |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
1246 /* For a two-char comment ender, we can assume |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
1247 it does end a comment. So scan back in a simple way. */ |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
1248 { |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1249 if (from != stop) DEC_POS (from); |
1167
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
1250 while (1) |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
1251 { |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
1252 if (SYNTAX (c = FETCH_CHAR (from)) == Scomment |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
1253 && SYNTAX_COMMENT_STYLE (c) == comstyle) |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
1254 break; |
7924
63a2327f0783
(scan_lists): Get error if eob within comment with depth!=0.
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
1255 if (from == stop) |
63a2327f0783
(scan_lists): Get error if eob within comment with depth!=0.
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
1256 { |
63a2327f0783
(scan_lists): Get error if eob within comment with depth!=0.
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
1257 if (depth == 0) |
63a2327f0783
(scan_lists): Get error if eob within comment with depth!=0.
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
1258 goto done2; |
63a2327f0783
(scan_lists): Get error if eob within comment with depth!=0.
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
1259 goto lose; |
63a2327f0783
(scan_lists): Get error if eob within comment with depth!=0.
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
1260 } |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1261 DEC_POS (from); |
1167
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
1262 if (SYNTAX_COMSTART_SECOND (c) |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
1263 && SYNTAX_COMSTART_FIRST (FETCH_CHAR (from)) |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
1264 && SYNTAX_COMMENT_STYLE (c) == comstyle |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
1265 && !char_quoted (from)) |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
1266 break; |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
1267 } |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
1268 break; |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
1269 } |
3794
ea9d3f2cd5fa
(scan_lists, Fforward_comment): #if 0 the code
Richard M. Stallman <rms@gnu.org>
parents:
3720
diff
changeset
|
1270 #endif /* 0 */ |
1167
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
1271 |
163 | 1272 /* Look back, counting the parity of string-quotes, |
1273 and recording the comment-starters seen. | |
1274 When we reach a safe place, assume that's not in a string; | |
1275 then step the main scan to the earliest comment-starter seen | |
1276 an even number of string quotes away from the safe place. | |
1277 | |
1278 OFROM[I] is position of the earliest comment-starter seen | |
1279 which is I+2X quotes from the comment-end. | |
1280 PARITY is current parity of quotes from the comment end. */ | |
1281 { | |
1282 int parity = 0; | |
1085
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1283 char my_stringend = 0; |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1284 int string_lossage = 0; |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1285 int comment_end = from; |
1167
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
1286 int comstart_pos = 0; |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
1287 int comstart_parity = 0; |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1288 int scanstart = from; |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1289 |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1290 DEC_POS (scanstart); |
163 | 1291 |
1292 /* At beginning of range to scan, we're outside of strings; | |
1293 that determines quote parity to the comment-end. */ | |
1294 while (from != stop) | |
1295 { | |
1296 /* Move back and examine a character. */ | |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1297 DEC_POS (from); |
163 | 1298 |
1299 c = FETCH_CHAR (from); | |
1300 code = SYNTAX (c); | |
1301 | |
1302 /* If this char is the second of a 2-char comment sequence, | |
1303 back up and give the pair the appropriate syntax. */ | |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1304 temp_pos = from; |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1305 DEC_POS (temp_pos); |
163 | 1306 if (from > stop && SYNTAX_COMEND_SECOND (c) |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1307 && (c1 = FETCH_CHAR (temp_pos), |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1308 SYNTAX_COMEND_FIRST (c1))) |
1085
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1309 { |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1310 code = Sendcomment; |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1311 from = temp_pos; |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1312 c = c1; |
1085
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1313 } |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1314 |
8045
18c2ad4ddc83
(scan_lists, Fforward_comment): When moving backward over
Richard M. Stallman <rms@gnu.org>
parents:
7975
diff
changeset
|
1315 /* If this char starts a 2-char comment start sequence, |
18c2ad4ddc83
(scan_lists, Fforward_comment): When moving backward over
Richard M. Stallman <rms@gnu.org>
parents:
7975
diff
changeset
|
1316 treat it like a 1-char comment starter. */ |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1317 temp_pos = from; |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1318 INC_POS (temp_pos); |
8045
18c2ad4ddc83
(scan_lists, Fforward_comment): When moving backward over
Richard M. Stallman <rms@gnu.org>
parents:
7975
diff
changeset
|
1319 if (from < scanstart && SYNTAX_COMSTART_FIRST (c) |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1320 && (c1 = FETCH_CHAR (temp_pos), |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1321 SYNTAX_COMSTART_SECOND (c1)) |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1322 && comstyle == SYNTAX_COMMENT_STYLE (c1)) |
8045
18c2ad4ddc83
(scan_lists, Fforward_comment): When moving backward over
Richard M. Stallman <rms@gnu.org>
parents:
7975
diff
changeset
|
1323 code = Scomment; |
163 | 1324 |
1325 /* Ignore escaped characters. */ | |
1326 if (char_quoted (from)) | |
1327 continue; | |
1328 | |
1167
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
1329 /* Track parity of quotes. */ |
163 | 1330 if (code == Sstring) |
1085
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1331 { |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1332 parity ^= 1; |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1333 if (my_stringend == 0) |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1334 my_stringend = c; |
1167
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
1335 /* If we have two kinds of string delimiters. |
1085
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1336 There's no way to grok this scanning backwards. */ |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1337 else if (my_stringend != c) |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1338 string_lossage = 1; |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1339 } |
163 | 1340 |
1341 /* Record comment-starters according to that | |
1342 quote-parity to the comment-end. */ | |
1343 if (code == Scomment) | |
1167
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
1344 { |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
1345 comstart_parity = parity; |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
1346 comstart_pos = from; |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
1347 } |
163 | 1348 |
1167
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
1349 /* If we find another earlier comment-ender, |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3568
diff
changeset
|
1350 any comment-starts earlier than that don't count |
1167
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
1351 (because they go with the earlier comment-ender). */ |
1085
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1352 if (code == Sendcomment |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1353 && SYNTAX_COMMENT_STYLE (FETCH_CHAR (from)) == comstyle) |
163 | 1354 break; |
1167
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
1355 |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
1356 /* Assume a defun-start point is outside of strings. */ |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
1357 if (code == Sopen |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1358 && (from == stop || FETCH_BYTE (from - 1) == '\n')) |
1167
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
1359 break; |
163 | 1360 } |
1167
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
1361 |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
1362 if (comstart_pos == 0) |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
1363 from = comment_end; |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
1364 /* If the earliest comment starter |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
1365 is followed by uniform paired string quotes or none, |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
1366 we know it can't be inside a string |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
1367 since if it were then the comment ender would be inside one. |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
1368 So it does start a comment. Skip back to it. */ |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
1369 else if (comstart_parity == 0 && !string_lossage) |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
1370 from = comstart_pos; |
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
1371 else |
1085
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1372 { |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1373 /* We had two kinds of string delimiters mixed up |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1374 together. Decode this going forwards. |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1375 Scan fwd from the previous comment ender |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1376 to the one in question; this records where we |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1377 last passed a comment starter. */ |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1378 struct lisp_parse_state state; |
1167
a9aeeaa9da8f
(scan_lists): When searching back for comment:
Richard M. Stallman <rms@gnu.org>
parents:
1085
diff
changeset
|
1379 scan_sexps_forward (&state, find_defun_start (comment_end), |
3720
408c7ee69be7
(scan_lists, Fforward_comment): Pass 0 as commentstop arg
Richard M. Stallman <rms@gnu.org>
parents:
3684
diff
changeset
|
1380 comment_end - 1, -10000, 0, Qnil, 0); |
1085
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1381 if (state.incomment) |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1382 from = state.comstart; |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1383 else |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1384 /* We can't grok this as a comment; scan it normally. */ |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1385 from = comment_end; |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1386 } |
163 | 1387 } |
1388 break; | |
1389 | |
1390 case Sstring: | |
1391 stringterm = FETCH_CHAR (from); | |
1392 while (1) | |
1393 { | |
1394 if (from == stop) goto lose; | |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1395 temp_pos = from; |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1396 DEC_POS (temp_pos); |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1397 if (!char_quoted (temp_pos) |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1398 && stringterm == FETCH_CHAR (temp_pos)) |
163 | 1399 break; |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1400 from = temp_pos; |
163 | 1401 } |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1402 DEC_POS (from); |
163 | 1403 if (!depth && sexpflag) goto done2; |
1404 break; | |
1405 } | |
1406 } | |
1407 | |
1408 /* Reached start of buffer. Error if within object, return nil if between */ | |
1409 if (depth) goto lose; | |
1410 | |
1411 immediate_quit = 0; | |
1412 return Qnil; | |
1413 | |
1414 done2: | |
1415 count++; | |
1416 } | |
1417 | |
1418 | |
1419 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
|
1420 XSETFASTINT (val, from); |
163 | 1421 return val; |
1422 | |
1423 lose: | |
16992
ff7346c31184
(scan_lists): Signal errors using scan-error.
Richard M. Stallman <rms@gnu.org>
parents:
16039
diff
changeset
|
1424 Fsignal (Qscan_error, |
ff7346c31184
(scan_lists): Signal errors using scan-error.
Richard M. Stallman <rms@gnu.org>
parents:
16039
diff
changeset
|
1425 Fcons (build_string ("Unbalanced parentheses"), |
ff7346c31184
(scan_lists): Signal errors using scan-error.
Richard M. Stallman <rms@gnu.org>
parents:
16039
diff
changeset
|
1426 Fcons (make_number (last_good), |
ff7346c31184
(scan_lists): Signal errors using scan-error.
Richard M. Stallman <rms@gnu.org>
parents:
16039
diff
changeset
|
1427 Fcons (make_number (from), Qnil)))); |
ff7346c31184
(scan_lists): Signal errors using scan-error.
Richard M. Stallman <rms@gnu.org>
parents:
16039
diff
changeset
|
1428 |
163 | 1429 /* NOTREACHED */ |
1430 } | |
1431 | |
3720
408c7ee69be7
(scan_lists, Fforward_comment): Pass 0 as commentstop arg
Richard M. Stallman <rms@gnu.org>
parents:
3684
diff
changeset
|
1432 static int |
163 | 1433 char_quoted (pos) |
1434 register int pos; | |
1435 { | |
1436 register enum syntaxcode code; | |
1437 register int beg = BEGV; | |
1438 register int quoted = 0; | |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1439 int temp_pos = pos; |
163 | 1440 |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1441 DEC_POS (temp_pos); |
163 | 1442 while (pos > beg |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1443 && ((code = SYNTAX (FETCH_CHAR (temp_pos))) == Scharquote |
163 | 1444 || code == Sescape)) |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1445 { |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1446 pos = temp_pos; |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1447 quoted = !quoted; |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1448 DEC_POS (temp_pos); |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1449 } |
163 | 1450 return quoted; |
1451 } | |
1452 | |
1453 DEFUN ("scan-lists", Fscan_lists, Sscan_lists, 3, 3, 0, | |
1454 "Scan from character number FROM by COUNT lists.\n\ | |
1455 Returns the character number of the position thus found.\n\ | |
1456 \n\ | |
1457 If DEPTH is nonzero, paren depth begins counting from that value,\n\ | |
1458 only places where the depth in parentheses becomes zero\n\ | |
1459 are candidates for stopping; COUNT such places are counted.\n\ | |
1460 Thus, a positive value for DEPTH means go out levels.\n\ | |
1461 \n\ | |
1462 Comments are ignored if `parse-sexp-ignore-comments' is non-nil.\n\ | |
1463 \n\ | |
1464 If the beginning or end of (the accessible part of) the buffer is reached\n\ | |
1465 and the depth is wrong, an error is signaled.\n\ | |
1466 If the depth is right but the count is not used up, nil is returned.") | |
1467 (from, count, depth) | |
1468 Lisp_Object from, count, depth; | |
1469 { | |
1470 CHECK_NUMBER (from, 0); | |
1471 CHECK_NUMBER (count, 1); | |
1472 CHECK_NUMBER (depth, 2); | |
1473 | |
1474 return scan_lists (XINT (from), XINT (count), XINT (depth), 0); | |
1475 } | |
1476 | |
1477 DEFUN ("scan-sexps", Fscan_sexps, Sscan_sexps, 2, 2, 0, | |
1478 "Scan from character number FROM by COUNT balanced expressions.\n\ | |
1479 If COUNT is negative, scan backwards.\n\ | |
1480 Returns the character number of the position thus found.\n\ | |
1481 \n\ | |
1482 Comments are ignored if `parse-sexp-ignore-comments' is non-nil.\n\ | |
1483 \n\ | |
1484 If the beginning or end of (the accessible part of) the buffer is reached\n\ | |
1485 in the middle of a parenthetical grouping, an error is signaled.\n\ | |
1486 If the beginning or end is reached between groupings\n\ | |
1487 but before count is used up, nil is returned.") | |
1488 (from, count) | |
1489 Lisp_Object from, count; | |
1490 { | |
1491 CHECK_NUMBER (from, 0); | |
1492 CHECK_NUMBER (count, 1); | |
1493 | |
1494 return scan_lists (XINT (from), XINT (count), 0, 1); | |
1495 } | |
1496 | |
1497 DEFUN ("backward-prefix-chars", Fbackward_prefix_chars, Sbackward_prefix_chars, | |
1498 0, 0, 0, | |
1499 "Move point backward over any number of chars with prefix syntax.\n\ | |
1500 This includes chars with \"quote\" or \"prefix\" syntax (' or p).") | |
1501 () | |
1502 { | |
1503 int beg = BEGV; | |
16039
855c8d8ba0f0
Change all references from point to PT.
Karl Heuer <kwzh@gnu.org>
parents:
14661
diff
changeset
|
1504 int pos = PT; |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1505 int c; |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1506 int temp_pos = pos; |
163 | 1507 |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1508 DEC_POS (temp_pos); |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1509 |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1510 while (pos > beg && !char_quoted (temp_pos) |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1511 && ((c = FETCH_CHAR (temp_pos), SYNTAX (c) == Squote) |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1512 || SYNTAX_PREFIX (c))) |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1513 { |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1514 pos = temp_pos; |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1515 DEC_POS (temp_pos); |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1516 } |
163 | 1517 |
1518 SET_PT (pos); | |
1519 | |
1520 return Qnil; | |
1521 } | |
1522 | |
1085
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1523 /* Parse forward from FROM to END, |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1524 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
|
1525 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
|
1526 If STOPBEFORE is nonzero, stop at the start of an atom. |
3ee951a22a80
(Fforward_comment): Set point to where scan stops,
Richard M. Stallman <rms@gnu.org>
parents:
3095
diff
changeset
|
1527 If COMMENTSTOP is nonzero, stop at the start of a comment. */ |
163 | 1528 |
3720
408c7ee69be7
(scan_lists, Fforward_comment): Pass 0 as commentstop arg
Richard M. Stallman <rms@gnu.org>
parents:
3684
diff
changeset
|
1529 static void |
3568
3ee951a22a80
(Fforward_comment): Set point to where scan stops,
Richard M. Stallman <rms@gnu.org>
parents:
3095
diff
changeset
|
1530 scan_sexps_forward (stateptr, from, end, targetdepth, |
3ee951a22a80
(Fforward_comment): Set point to where scan stops,
Richard M. Stallman <rms@gnu.org>
parents:
3095
diff
changeset
|
1531 stopbefore, oldstate, commentstop) |
1085
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1532 struct lisp_parse_state *stateptr; |
163 | 1533 register int from; |
1534 int end, targetdepth, stopbefore; | |
1535 Lisp_Object oldstate; | |
3568
3ee951a22a80
(Fforward_comment): Set point to where scan stops,
Richard M. Stallman <rms@gnu.org>
parents:
3095
diff
changeset
|
1536 int commentstop; |
163 | 1537 { |
1538 struct lisp_parse_state state; | |
1539 | |
1540 register enum syntaxcode code; | |
1541 struct level { int last, prev; }; | |
1542 struct level levelstart[100]; | |
1543 register struct level *curlevel = levelstart; | |
1544 struct level *endlevel = levelstart + 100; | |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1545 int prev; |
163 | 1546 register int depth; /* Paren depth of current scanning location. |
1547 level - levelstart equals this except | |
1548 when the depth becomes negative. */ | |
1549 int mindepth; /* Lowest DEPTH value seen. */ | |
1550 int start_quoted = 0; /* Nonzero means starting after a char quote */ | |
1551 Lisp_Object tem; | |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1552 int prev_from; /* Keep one character before FROM. */ |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1553 |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1554 prev_from = from; |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1555 DEC_POS (prev_from); |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1556 |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1557 /* Use this macro instead of `from++'. */ |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1558 #define INC_FROM do { prev_from = from; INC_POS (from); } while (0) |
163 | 1559 |
1560 immediate_quit = 1; | |
1561 QUIT; | |
1562 | |
485 | 1563 if (NILP (oldstate)) |
163 | 1564 { |
1565 depth = 0; | |
1566 state.instring = -1; | |
1567 state.incomment = 0; | |
1085
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1568 state.comstyle = 0; /* comment style a by default */ |
163 | 1569 } |
1570 else | |
1571 { | |
1572 tem = Fcar (oldstate); | |
485 | 1573 if (!NILP (tem)) |
163 | 1574 depth = XINT (tem); |
1575 else | |
1576 depth = 0; | |
1577 | |
1578 oldstate = Fcdr (oldstate); | |
1579 oldstate = Fcdr (oldstate); | |
1580 oldstate = Fcdr (oldstate); | |
1581 tem = Fcar (oldstate); | |
485 | 1582 state.instring = !NILP (tem) ? XINT (tem) : -1; |
163 | 1583 |
1584 oldstate = Fcdr (oldstate); | |
1585 tem = Fcar (oldstate); | |
485 | 1586 state.incomment = !NILP (tem); |
163 | 1587 |
1588 oldstate = Fcdr (oldstate); | |
1589 tem = Fcar (oldstate); | |
485 | 1590 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
|
1591 |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1592 /* if the eight element of the list is nil, we are in comment |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1593 style a. if it is non-nil, we are in comment style b */ |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1594 oldstate = Fcdr (oldstate); |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1595 oldstate = Fcdr (oldstate); |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1596 tem = Fcar (oldstate); |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1597 state.comstyle = !NILP (tem); |
163 | 1598 } |
1599 state.quoted = 0; | |
1600 mindepth = depth; | |
1601 | |
1602 curlevel->prev = -1; | |
1603 curlevel->last = -1; | |
1604 | |
1605 /* Enter the loop at a place appropriate for initial state. */ | |
1606 | |
1607 if (state.incomment) goto startincomment; | |
1608 if (state.instring >= 0) | |
1609 { | |
1610 if (start_quoted) goto startquotedinstring; | |
1611 goto startinstring; | |
1612 } | |
1613 if (start_quoted) goto startquoted; | |
1614 | |
1615 while (from < end) | |
1616 { | |
1085
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1617 code = SYNTAX (FETCH_CHAR (from)); |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1618 INC_FROM; |
3794
ea9d3f2cd5fa
(scan_lists, Fforward_comment): #if 0 the code
Richard M. Stallman <rms@gnu.org>
parents:
3720
diff
changeset
|
1619 if (code == Scomment) |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1620 state.comstart = prev_from; |
3794
ea9d3f2cd5fa
(scan_lists, Fforward_comment): #if 0 the code
Richard M. Stallman <rms@gnu.org>
parents:
3720
diff
changeset
|
1621 |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1622 else if (from < end && SYNTAX_COMSTART_FIRST (FETCH_CHAR (prev_from)) |
3794
ea9d3f2cd5fa
(scan_lists, Fforward_comment): #if 0 the code
Richard M. Stallman <rms@gnu.org>
parents:
3720
diff
changeset
|
1623 && SYNTAX_COMSTART_SECOND (FETCH_CHAR (from))) |
1085
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1624 { |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1625 /* 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
|
1626 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
|
1627 terminates the comment section. */ |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1628 code = Scomment; |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1629 state.comstyle = SYNTAX_COMMENT_STYLE (FETCH_CHAR (from)); |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1630 state.comstart = prev_from; |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1631 INC_FROM; |
1085
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1632 } |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1633 |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1634 if (SYNTAX_PREFIX (FETCH_CHAR (prev_from))) |
163 | 1635 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
|
1636 switch (SWITCH_ENUM_CAST (code)) |
163 | 1637 { |
1638 case Sescape: | |
1639 case Scharquote: | |
1640 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
|
1641 curlevel->last = prev_from; |
163 | 1642 startquoted: |
1643 if (from == end) goto endquoted; | |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1644 INC_FROM; |
163 | 1645 goto symstarted; |
1646 /* treat following character as a word constituent */ | |
1647 case Sword: | |
1648 case Ssymbol: | |
1649 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
|
1650 curlevel->last = prev_from; |
163 | 1651 symstarted: |
1652 while (from < end) | |
1653 { | |
10457
2ab3bd0288a9
Change all occurences of SWITCH_ENUM_BUG to use SWITCH_ENUM_CAST instead.
Karl Heuer <kwzh@gnu.org>
parents:
9863
diff
changeset
|
1654 switch (SWITCH_ENUM_CAST (SYNTAX (FETCH_CHAR (from)))) |
163 | 1655 { |
1656 case Scharquote: | |
1657 case Sescape: | |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1658 INC_FROM; |
163 | 1659 if (from == end) goto endquoted; |
1660 break; | |
1661 case Sword: | |
1662 case Ssymbol: | |
1663 case Squote: | |
1664 break; | |
1665 default: | |
1666 goto symdone; | |
1667 } | |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1668 INC_FROM; |
163 | 1669 } |
1670 symdone: | |
1671 curlevel->prev = curlevel->last; | |
1672 break; | |
1673 | |
9475
c15caadae3c4
(scan_sexps_forward): At startincomment,
Richard M. Stallman <rms@gnu.org>
parents:
9411
diff
changeset
|
1674 startincomment: |
c15caadae3c4
(scan_sexps_forward): At startincomment,
Richard M. Stallman <rms@gnu.org>
parents:
9411
diff
changeset
|
1675 if (commentstop) |
c15caadae3c4
(scan_sexps_forward): At startincomment,
Richard M. Stallman <rms@gnu.org>
parents:
9411
diff
changeset
|
1676 goto done; |
c15caadae3c4
(scan_sexps_forward): At startincomment,
Richard M. Stallman <rms@gnu.org>
parents:
9411
diff
changeset
|
1677 if (from != BEGV) |
c15caadae3c4
(scan_sexps_forward): At startincomment,
Richard M. Stallman <rms@gnu.org>
parents:
9411
diff
changeset
|
1678 { |
c15caadae3c4
(scan_sexps_forward): At startincomment,
Richard M. Stallman <rms@gnu.org>
parents:
9411
diff
changeset
|
1679 /* Enter the loop in the middle so that we find |
c15caadae3c4
(scan_sexps_forward): At startincomment,
Richard M. Stallman <rms@gnu.org>
parents:
9411
diff
changeset
|
1680 a 2-char comment ender if we start in the middle of it. */ |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1681 prev = FETCH_CHAR (prev_from); |
9475
c15caadae3c4
(scan_sexps_forward): At startincomment,
Richard M. Stallman <rms@gnu.org>
parents:
9411
diff
changeset
|
1682 goto startincomment_1; |
c15caadae3c4
(scan_sexps_forward): At startincomment,
Richard M. Stallman <rms@gnu.org>
parents:
9411
diff
changeset
|
1683 } |
c15caadae3c4
(scan_sexps_forward): At startincomment,
Richard M. Stallman <rms@gnu.org>
parents:
9411
diff
changeset
|
1684 /* At beginning of buffer, enter the loop the ordinary way. */ |
c15caadae3c4
(scan_sexps_forward): At startincomment,
Richard M. Stallman <rms@gnu.org>
parents:
9411
diff
changeset
|
1685 |
163 | 1686 case Scomment: |
1687 state.incomment = 1; | |
3568
3ee951a22a80
(Fforward_comment): Set point to where scan stops,
Richard M. Stallman <rms@gnu.org>
parents:
3095
diff
changeset
|
1688 if (commentstop) |
3ee951a22a80
(Fforward_comment): Set point to where scan stops,
Richard M. Stallman <rms@gnu.org>
parents:
3095
diff
changeset
|
1689 goto done; |
163 | 1690 while (1) |
1691 { | |
1692 if (from == end) goto done; | |
1085
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1693 prev = FETCH_CHAR (from); |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1694 if (SYNTAX (prev) == Sendcomment |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1695 && SYNTAX_COMMENT_STYLE (prev) == state.comstyle) |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1696 /* Only terminate the comment section if the endcomment |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1697 of the same style as the start sequence has been |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1698 encountered. */ |
163 | 1699 break; |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1700 INC_FROM; |
9475
c15caadae3c4
(scan_sexps_forward): At startincomment,
Richard M. Stallman <rms@gnu.org>
parents:
9411
diff
changeset
|
1701 startincomment_1: |
163 | 1702 if (from < end && SYNTAX_COMEND_FIRST (prev) |
1085
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1703 && SYNTAX_COMEND_SECOND (FETCH_CHAR (from)) |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1704 && SYNTAX_COMMENT_STYLE (prev) == state.comstyle) |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1705 /* Only terminate the comment section if the end-comment |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1706 sequence of the same style as the start sequence has |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1707 been encountered. */ |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1708 { INC_FROM; break; } |
163 | 1709 } |
1710 state.incomment = 0; | |
1085
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1711 state.comstyle = 0; /* reset the comment style */ |
163 | 1712 break; |
1713 | |
1714 case Sopen: | |
1715 if (stopbefore) goto stop; /* this arg means stop at sexp start */ | |
1716 depth++; | |
1717 /* 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
|
1718 curlevel->last = prev_from; |
163 | 1719 if (++curlevel == endlevel) |
1720 error ("Nesting too deep for parser"); | |
1721 curlevel->prev = -1; | |
1722 curlevel->last = -1; | |
12894
b2a75405de3c
(scan_sexps_forward): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents:
12870
diff
changeset
|
1723 if (targetdepth == depth) goto done; |
163 | 1724 break; |
1725 | |
1726 case Sclose: | |
1727 depth--; | |
1728 if (depth < mindepth) | |
1729 mindepth = depth; | |
1730 if (curlevel != levelstart) | |
1731 curlevel--; | |
1732 curlevel->prev = curlevel->last; | |
12894
b2a75405de3c
(scan_sexps_forward): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents:
12870
diff
changeset
|
1733 if (targetdepth == depth) goto done; |
163 | 1734 break; |
1735 | |
1736 case Sstring: | |
1737 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
|
1738 curlevel->last = prev_from; |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1739 state.instring = FETCH_CHAR (prev_from); |
163 | 1740 startinstring: |
1741 while (1) | |
1742 { | |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1743 int c; |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1744 |
163 | 1745 if (from >= end) goto done; |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1746 c = FETCH_CHAR (from); |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1747 if (c == state.instring) break; |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1748 switch (SWITCH_ENUM_CAST (SYNTAX (c))) |
163 | 1749 { |
1750 case Scharquote: | |
1751 case Sescape: | |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1752 INC_FROM; |
163 | 1753 startquotedinstring: |
1754 if (from >= end) goto endquoted; | |
1755 } | |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1756 INC_FROM; |
163 | 1757 } |
1758 state.instring = -1; | |
1759 curlevel->prev = curlevel->last; | |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1760 INC_FROM; |
163 | 1761 break; |
1762 | |
1763 case Smath: | |
1764 break; | |
1765 } | |
1766 } | |
1767 goto done; | |
1768 | |
1769 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
|
1770 from = prev_from; /* We have just fetched the char that starts it; */ |
163 | 1771 goto done; /* but return the position before it. */ |
1772 | |
1773 endquoted: | |
1774 state.quoted = 1; | |
1775 done: | |
1776 state.depth = depth; | |
1777 state.mindepth = mindepth; | |
1778 state.thislevelstart = curlevel->prev; | |
1779 state.prevlevelstart | |
1780 = (curlevel == levelstart) ? -1 : (curlevel - 1)->last; | |
1781 state.location = from; | |
1782 immediate_quit = 0; | |
1783 | |
1085
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1784 *stateptr = state; |
163 | 1785 } |
1786 | |
1787 /* This comment supplies the doc string for parse-partial-sexp, | |
1788 for make-docfile to see. We cannot put this in the real DEFUN | |
1789 due to limits in the Unix cpp. | |
1790 | |
3568
3ee951a22a80
(Fforward_comment): Set point to where scan stops,
Richard M. Stallman <rms@gnu.org>
parents:
3095
diff
changeset
|
1791 DEFUN ("parse-partial-sexp", Ffoo, Sfoo, 2, 6, 0, |
163 | 1792 "Parse Lisp syntax starting at FROM until TO; return status of parse at TO.\n\ |
1793 Parsing stops at TO or when certain criteria are met;\n\ | |
1794 point is set to where parsing stops.\n\ | |
1795 If fifth arg STATE is omitted or nil,\n\ | |
1796 parsing assumes that FROM is the beginning of a function.\n\ | |
1085
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1797 Value is a list of eight elements describing final state of parsing:\n\ |
4458 | 1798 0. depth in parens.\n\ |
1799 1. character address of start of innermost containing list; nil if none.\n\ | |
1800 2. character address of start of last complete sexp terminated.\n\ | |
1801 3. non-nil if inside a string.\n\ | |
163 | 1802 (it is the character that will terminate the string.)\n\ |
4458 | 1803 4. t if inside a comment.\n\ |
1804 5. t if following a quote character.\n\ | |
1805 6. the minimum paren-depth encountered during this scan.\n\ | |
1806 7. t if in a comment of style `b'.\n\ | |
163 | 1807 If third arg TARGETDEPTH is non-nil, parsing stops if the depth\n\ |
1808 in parentheses becomes equal to TARGETDEPTH.\n\ | |
1809 Fourth arg STOPBEFORE non-nil means stop when come to\n\ | |
1810 any character that starts a sexp.\n\ | |
4393 | 1811 Fifth arg STATE is an eight-list like what this function returns.\n\ |
726 | 1812 It is used to initialize the state of the parse. Its second and third |
3568
3ee951a22a80
(Fforward_comment): Set point to where scan stops,
Richard M. Stallman <rms@gnu.org>
parents:
3095
diff
changeset
|
1813 elements are ignored. |
3ee951a22a80
(Fforward_comment): Set point to where scan stops,
Richard M. Stallman <rms@gnu.org>
parents:
3095
diff
changeset
|
1814 Sixth args COMMENTSTOP non-nil means stop at the start of a comment.") |
3ee951a22a80
(Fforward_comment): Set point to where scan stops,
Richard M. Stallman <rms@gnu.org>
parents:
3095
diff
changeset
|
1815 (from, to, targetdepth, stopbefore, state, commentstop) |
163 | 1816 */ |
1817 | |
3568
3ee951a22a80
(Fforward_comment): Set point to where scan stops,
Richard M. Stallman <rms@gnu.org>
parents:
3095
diff
changeset
|
1818 DEFUN ("parse-partial-sexp", Fparse_partial_sexp, Sparse_partial_sexp, 2, 6, 0, |
163 | 1819 0 /* See immediately above */) |
3568
3ee951a22a80
(Fforward_comment): Set point to where scan stops,
Richard M. Stallman <rms@gnu.org>
parents:
3095
diff
changeset
|
1820 (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
|
1821 Lisp_Object from, to, targetdepth, stopbefore, oldstate, commentstop; |
163 | 1822 { |
1823 struct lisp_parse_state state; | |
1824 int target; | |
1825 | |
485 | 1826 if (!NILP (targetdepth)) |
163 | 1827 { |
1828 CHECK_NUMBER (targetdepth, 3); | |
1829 target = XINT (targetdepth); | |
1830 } | |
1831 else | |
1832 target = -100000; /* We won't reach this depth */ | |
1833 | |
1834 validate_region (&from, &to); | |
1085
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1835 scan_sexps_forward (&state, XINT (from), XINT (to), |
3568
3ee951a22a80
(Fforward_comment): Set point to where scan stops,
Richard M. Stallman <rms@gnu.org>
parents:
3095
diff
changeset
|
1836 target, !NILP (stopbefore), oldstate, |
3ee951a22a80
(Fforward_comment): Set point to where scan stops,
Richard M. Stallman <rms@gnu.org>
parents:
3095
diff
changeset
|
1837 !NILP (commentstop)); |
163 | 1838 |
1839 SET_PT (state.location); | |
1840 | |
1841 return Fcons (make_number (state.depth), | |
1842 Fcons (state.prevlevelstart < 0 ? Qnil : make_number (state.prevlevelstart), | |
1843 Fcons (state.thislevelstart < 0 ? Qnil : make_number (state.thislevelstart), | |
1844 Fcons (state.instring >= 0 ? make_number (state.instring) : Qnil, | |
1845 Fcons (state.incomment ? Qt : Qnil, | |
1846 Fcons (state.quoted ? Qt : Qnil, | |
1085
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1847 Fcons (make_number (state.mindepth), |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1848 Fcons (state.comstyle ? Qt : Qnil, |
91a456e52db1
(scan_lists): Improve smarts for backwards scan of comments.
Richard M. Stallman <rms@gnu.org>
parents:
726
diff
changeset
|
1849 Qnil)))))))); |
163 | 1850 } |
1851 | |
1852 init_syntax_once () | |
1853 { | |
17126
f8d7263cce09
(init_syntax_once): Add trick to avoid compiler warning
Kenichi Handa <handa@m17n.org>
parents:
17109
diff
changeset
|
1854 register int i, c; |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
1855 Lisp_Object temp; |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
1856 |
13218
d2fc560c7740
(Qsyntax_table): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13144
diff
changeset
|
1857 /* 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
|
1858 Qsyntax_table = intern ("syntax-table"); |
d2fc560c7740
(Qsyntax_table): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13144
diff
changeset
|
1859 staticpro (&Qsyntax_table); |
d2fc560c7740
(Qsyntax_table): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13144
diff
changeset
|
1860 |
d2fc560c7740
(Qsyntax_table): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13144
diff
changeset
|
1861 /* 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
|
1862 Setting this variable twice is harmless. |
d2fc560c7740
(Qsyntax_table): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13144
diff
changeset
|
1863 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
|
1864 Qchar_table_extra_slots = intern ("char-table-extra-slots"); |
d2fc560c7740
(Qsyntax_table): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13144
diff
changeset
|
1865 |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1866 /* Create objects which can be shared among syntax tables. */ |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1867 Vsyntax_code_object = Fmake_vector (13, Qnil); |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1868 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
|
1869 XVECTOR (Vsyntax_code_object)->contents[i] |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1870 = Fcons (make_number (i), Qnil); |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1871 |
13218
d2fc560c7740
(Qsyntax_table): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13144
diff
changeset
|
1872 /* 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
|
1873 create syntax tables. */ |
d2fc560c7740
(Qsyntax_table): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13144
diff
changeset
|
1874 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
|
1875 |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1876 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
|
1877 |
13218
d2fc560c7740
(Qsyntax_table): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
13144
diff
changeset
|
1878 Vstandard_syntax_table = Fmake_char_table (Qsyntax_table, temp); |
163 | 1879 |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1880 temp = XVECTOR (Vsyntax_code_object)->contents[(int) Sword]; |
163 | 1881 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
|
1882 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, i, temp); |
163 | 1883 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
|
1884 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, i, temp); |
163 | 1885 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
|
1886 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
|
1887 |
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
1888 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
|
1889 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, '%', temp); |
163 | 1890 |
13144
fd14ccddb85a
(describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents:
12894
diff
changeset
|
1891 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
|
1892 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
|
1893 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
|
1894 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
|
1895 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
|
1896 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
|
1897 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
|
1898 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
|
1899 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
|
1900 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
|
1901 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
|
1902 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
|
1903 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
|
1904 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
|
1905 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
|
1906 Fcons (make_number ((int) Sescape), Qnil)); |
163 | 1907 |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1908 temp = XVECTOR (Vsyntax_code_object)->contents[(int) Ssymbol]; |
163 | 1909 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
|
1910 { |
f8d7263cce09
(init_syntax_once): Add trick to avoid compiler warning
Kenichi Handa <handa@m17n.org>
parents:
17109
diff
changeset
|
1911 c = "_-+*/&|<>="[i]; |
f8d7263cce09
(init_syntax_once): Add trick to avoid compiler warning
Kenichi Handa <handa@m17n.org>
parents:
17109
diff
changeset
|
1912 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
|
1913 } |
163 | 1914 |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1915 temp = XVECTOR (Vsyntax_code_object)->contents[(int) Spunct]; |
163 | 1916 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
|
1917 { |
f8d7263cce09
(init_syntax_once): Add trick to avoid compiler warning
Kenichi Handa <handa@m17n.org>
parents:
17109
diff
changeset
|
1918 c = ".,;:?!#@~^'`"[i]; |
f8d7263cce09
(init_syntax_once): Add trick to avoid compiler warning
Kenichi Handa <handa@m17n.org>
parents:
17109
diff
changeset
|
1919 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
|
1920 } |
163 | 1921 } |
1922 | |
1923 syms_of_syntax () | |
1924 { | |
1925 Qsyntax_table_p = intern ("syntax-table-p"); | |
1926 staticpro (&Qsyntax_table_p); | |
1927 | |
17044
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1928 staticpro (&Vsyntax_code_object); |
f07c36097f33
Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents:
16992
diff
changeset
|
1929 |
16992
ff7346c31184
(scan_lists): Signal errors using scan-error.
Richard M. Stallman <rms@gnu.org>
parents:
16039
diff
changeset
|
1930 Qscan_error = intern ("scan-error"); |
ff7346c31184
(scan_lists): Signal errors using scan-error.
Richard M. Stallman <rms@gnu.org>
parents:
16039
diff
changeset
|
1931 staticpro (&Qscan_error); |
ff7346c31184
(scan_lists): Signal errors using scan-error.
Richard M. Stallman <rms@gnu.org>
parents:
16039
diff
changeset
|
1932 Fput (Qscan_error, Qerror_conditions, |
ff7346c31184
(scan_lists): Signal errors using scan-error.
Richard M. Stallman <rms@gnu.org>
parents:
16039
diff
changeset
|
1933 Fcons (Qerror, Qnil)); |
ff7346c31184
(scan_lists): Signal errors using scan-error.
Richard M. Stallman <rms@gnu.org>
parents:
16039
diff
changeset
|
1934 Fput (Qscan_error, Qerror_message, |
ff7346c31184
(scan_lists): Signal errors using scan-error.
Richard M. Stallman <rms@gnu.org>
parents:
16039
diff
changeset
|
1935 build_string ("Scan error")); |
ff7346c31184
(scan_lists): Signal errors using scan-error.
Richard M. Stallman <rms@gnu.org>
parents:
16039
diff
changeset
|
1936 |
163 | 1937 DEFVAR_BOOL ("parse-sexp-ignore-comments", &parse_sexp_ignore_comments, |
1938 "Non-nil means `forward-sexp', etc., should treat comments as whitespace."); | |
1939 | |
1940 words_include_escapes = 0; | |
1941 DEFVAR_BOOL ("words-include-escapes", &words_include_escapes, | |
1942 "Non-nil means `forward-word', etc., should treat escape chars part of words."); | |
1943 | |
1944 defsubr (&Ssyntax_table_p); | |
1945 defsubr (&Ssyntax_table); | |
1946 defsubr (&Sstandard_syntax_table); | |
1947 defsubr (&Scopy_syntax_table); | |
1948 defsubr (&Sset_syntax_table); | |
1949 defsubr (&Schar_syntax); | |
7968
a6372621abd9
(Fmatching_paren): New function.
Richard M. Stallman <rms@gnu.org>
parents:
7924
diff
changeset
|
1950 defsubr (&Smatching_paren); |
163 | 1951 defsubr (&Smodify_syntax_entry); |
1952 defsubr (&Sdescribe_syntax); | |
1953 | |
1954 defsubr (&Sforward_word); | |
1955 | |
1998
656f4297962e
(describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents:
1394
diff
changeset
|
1956 defsubr (&Sforward_comment); |
163 | 1957 defsubr (&Sscan_lists); |
1958 defsubr (&Sscan_sexps); | |
1959 defsubr (&Sbackward_prefix_chars); | |
1960 defsubr (&Sparse_partial_sexp); | |
1961 } |