annotate src/syntax.c @ 17109:dfe4f98935c4

(describe_syntax): Handle the case that the argument VALUE is char-table.
author Kenichi Handa <handa@m17n.org>
date Thu, 27 Feb 1997 07:47:24 +0000
parents f07c36097f33
children f8d7263cce09
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
163
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4 This file is part of GNU Emacs.
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6 GNU Emacs is free software; you can redistribute it and/or modify
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7 it under the terms of the GNU General Public License as published by
726
5f08efa38dd0 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 624
diff changeset
8 the Free Software Foundation; either version 2, or (at your option)
163
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9 any later version.
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 GNU Emacs is distributed in the hope that it will be useful,
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14 GNU General Public License for more details.
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21
4696
1fc792473491 Include <config.h> instead of "config.h".
Roland McGrath <roland@gnu.org>
parents: 4458
diff changeset
22 #include <config.h>
163
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23 #include <ctype.h>
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24 #include "lisp.h"
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25 #include "commands.h"
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 int words_include_escapes;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124 return Qt;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125 return Qnil;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126 }
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129 check_syntax_table (obj)
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
130 Lisp_Object obj;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
135 }
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
136
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137 DEFUN ("syntax-table", Fsyntax_table, Ssyntax_table, 0, 0, 0,
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138 "Return the current syntax table.\n\
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139 This is the one specified by the current buffer.")
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140 ()
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141 {
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142 return current_buffer->syntax_table;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
143 }
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
144
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
145 DEFUN ("standard-syntax-table", Fstandard_syntax_table,
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146 Sstandard_syntax_table, 0, 0, 0,
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147 "Return the standard syntax table.\n\
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148 This is the one used for new buffers.")
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149 ()
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
150 {
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
151 return Vstandard_syntax_table;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
152 }
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
153
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
154 DEFUN ("copy-syntax-table", Fcopy_syntax_table, Scopy_syntax_table, 0, 1, 0,
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155 "Construct a new syntax table and return it.\n\
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
156 It is a copy of the TABLE, which defaults to the standard syntax table.")
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157 (table)
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
158 Lisp_Object table;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 163
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
179 }
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
180
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
181 DEFUN ("set-syntax-table", Fset_syntax_table, Sset_syntax_table, 1, 1, 0,
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
182 "Select a new syntax table for the current buffer.\n\
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
183 One argument, a syntax table.")
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
184 (table)
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
185 Lisp_Object table;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
188 current_buffer->syntax_table = table;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
192 return table;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
193 }
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
194
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
195 /* Convert a letter which signifies a syntax code
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
196 into the code it signifies.
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
197 This is used by modify-syntax-entry, and other things. */
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
198
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
199 unsigned char syntax_spec_code[0400] =
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
200 { 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377,
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
201 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377,
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
202 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377,
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
203 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377,
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
204 (char) Swhitespace, 0377, (char) Sstring, 0377,
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
205 (char) Smath, 0377, 0377, (char) Squote,
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
206 (char) Sopen, (char) Sclose, 0377, 0377,
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
207 0377, (char) Swhitespace, (char) Spunct, (char) Scharquote,
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
208 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377,
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
209 0377, 0377, 0377, 0377,
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
212 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377,
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
213 0377, 0377, 0377, 0377, 0377, 0377, 0377, (char) Sword,
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
214 0377, 0377, 0377, 0377, (char) Sescape, 0377, 0377, (char) Ssymbol,
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
215 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377, /* `, a, ... */
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
216 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377,
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
217 0377, 0377, 0377, 0377, 0377, 0377, 0377, (char) Sword,
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
218 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
219 };
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
220
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
221 /* Indexed by syntax code, give the letter that describes it. */
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
222
5442
8cbae747a768 (describe_syntax): Handle Sinherit.
Richard M. Stallman <rms@gnu.org>
parents: 5339
diff changeset
223 char syntax_code_spec[14] =
163
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
224 {
5442
8cbae747a768 (describe_syntax): Handle Sinherit.
Richard M. Stallman <rms@gnu.org>
parents: 5339
diff changeset
225 ' ', '.', 'w', '_', '(', ')', '\'', '\"', '$', '\\', '/', '<', '>', '@'
163
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
263 The characters that correspond to various syntax codes\n\
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
286 }
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
287
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
288 /* This comment supplies the doc string for modify-syntax-entry,
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
289 for make-docfile to see. We cannot put this in the real DEFUN
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
290 due to limits in the Unix cpp.
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
293 "Set syntax for character CHAR according to string S.\n\
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
294 The syntax is changed only for table TABLE, which defaults to\n\
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
295 the current buffer's syntax table.\n\
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
296 The first character of S should be one of the following:\n\
624
2bb7f23b7ea5 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
297 Space or - whitespace syntax. w word constituent.\n\
2bb7f23b7ea5 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
298 _ symbol constituent. . punctuation.\n\
2bb7f23b7ea5 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
299 ( open-parenthesis. ) close-parenthesis.\n\
2bb7f23b7ea5 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
300 \" string quote. \\ escape.\n\
2bb7f23b7ea5 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
305 Only single-character comment start and end sequences are represented thus.\n\
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
306 Two-character sequences are represented as described below.\n\
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
307 The second character of S is the matching parenthesis,\n\
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
308 used only if the first character is `(' or `)'.\n\
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
327 */
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
328
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
329 DEFUN ("modify-syntax-entry", Fmodify_syntax_entry, Smodify_syntax_entry, 2, 3,
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
330 /* I really don't know why this is interactive
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
331 help-form should at least be made useful whilst reading the second arg
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
332 */
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
333 "cSet syntax for character: \nsSet syntax for %s to: ",
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
334 0 /* See immediately above */)
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
335 (c, newentry, syntax_table)
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
336 Lisp_Object c, newentry, syntax_table;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
342
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
343 CHECK_NUMBER (c, 0);
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 163
diff changeset
346 if (NILP (syntax_table))
163
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
347 syntax_table = current_buffer->syntax_table;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
350
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
351 p = XSTRING (newentry)->data;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
352 code = (enum syntaxcode) syntax_spec_code[*p++];
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
353 if (((int) code & 0377) == 0377)
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
354 error ("invalid syntax description letter: %c", c);
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
376 while (*p)
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
377 switch (*p++)
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
378 {
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
381 break;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
382
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
385 break;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
386
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
389 break;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
390
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
393 break;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
394
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
402 }
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
411
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
412 return Qnil;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
413 }
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
414
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
415 /* Dump syntax table to buffer in human-readable format */
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
418 describe_syntax (value)
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
419 Lisp_Object value;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
420 {
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
425
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
426 Findent_to (make_number (16), make_number (1));
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
441 {
17044
f07c36097f33 Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents: 16992
diff changeset
442 insert_string ("invalid\n");
163
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
443 return;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
444 }
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
462
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
463 if ((int) code < 0 || (int) code >= (int) Smax)
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
464 {
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
465 insert_string ("invalid");
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
466 return;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
467 }
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
468 desc = syntax_code_spec[(int) code];
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
469
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
470 str[0] = desc, str[1] = 0;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
471 insert (str, 1);
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
477
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
478 if (start1)
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
479 insert ("1", 1);
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
480 if (start2)
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
481 insert ("2", 1);
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
482
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
483 if (end1)
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
484 insert ("3", 1);
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
485 if (end2)
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
486 insert ("4", 1);
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
487
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
488 if (prefix)
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
492
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
493 insert_string ("\twhich means: ");
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
496 {
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
497 case Swhitespace:
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
498 insert_string ("whitespace"); break;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
499 case Spunct:
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
500 insert_string ("punctuation"); break;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
501 case Sword:
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
502 insert_string ("word"); break;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
503 case Ssymbol:
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
504 insert_string ("symbol"); break;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
505 case Sopen:
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
506 insert_string ("open"); break;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
507 case Sclose:
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
508 insert_string ("close"); break;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
509 case Squote:
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
510 insert_string ("quote"); break;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
511 case Sstring:
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
512 insert_string ("string"); break;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
513 case Smath:
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
514 insert_string ("math"); break;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
515 case Sescape:
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
516 insert_string ("escape"); break;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
517 case Scharquote:
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
518 insert_string ("charquote"); break;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
519 case Scomment:
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
520 insert_string ("comment"); break;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
521 case Sendcomment:
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
522 insert_string ("endcomment"); break;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
523 default:
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
524 insert_string ("invalid");
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
525 return;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
526 }
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
529 {
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
532 }
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
533
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
534 if (start1)
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
535 insert_string (",\n\t is the first character of a comment-start sequence");
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
536 if (start2)
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
537 insert_string (",\n\t is the second character of a comment-start sequence");
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
538
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
539 if (end1)
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
540 insert_string (",\n\t is the first character of a comment-end sequence");
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
541 if (end2)
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
546 if (prefix)
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
547 insert_string (",\n\t is a prefix character for `backward-prefix-chars'");
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
548
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
549 insert_string ("\n");
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
550 }
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
553 describe_syntax_1 (vector)
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
554 Lisp_Object vector;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
555 {
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
556 struct buffer *old = current_buffer;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
567 set_buffer_internal (old);
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
568 return Qnil;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
569 }
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
570
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
571 DEFUN ("describe-syntax", Fdescribe_syntax, Sdescribe_syntax, 0, 0, "",
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
572 "Describe the syntax specifications in the syntax table.\n\
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
573 The descriptions are inserted in a buffer, which is then displayed.")
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
574 ()
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
575 {
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
576 internal_with_output_to_temp_buffer
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
577 ("*Help*", describe_syntax_1, current_buffer->syntax_table);
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
578
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
579 return Qnil;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
580 }
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
581
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
582 /* Return the position across COUNT words from FROM.
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
583 If that many words cannot be found before the end of the buffer, return 0.
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
584 COUNT negative means scan backward and stop at word beginning. */
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
585
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
586 scan_words (from, count)
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
587 register int from, count;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
588 {
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
589 register int beg = BEGV;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
594
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
595 immediate_quit = 1;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
596 QUIT;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
597
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
598 while (count > 0)
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
599 {
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
600 while (1)
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
601 {
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
602 if (from == end)
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
603 {
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
604 immediate_quit = 0;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
605 return 0;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
610 if (words_include_escapes
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
611 && (code == Sescape || code == Scharquote))
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
612 break;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
613 if (code == Sword)
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
614 break;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
618 while (1)
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
619 {
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
623 if (!(words_include_escapes
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
629 }
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
630 count--;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
631 }
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
632 while (count < 0)
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
633 {
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
634 while (1)
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
635 {
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
636 if (from == beg)
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
637 {
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
638 immediate_quit = 0;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
639 return 0;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
644 if (words_include_escapes
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
645 && (code == Sescape || code == Scharquote))
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
646 break;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
647 if (code == Sword)
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
648 break;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
652 while (1)
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
653 {
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
659 if (!(words_include_escapes
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
665 }
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
666 count++;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
667 }
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
668
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
669 immediate_quit = 0;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
670
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
671 return from;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
672 }
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
673
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
674 DEFUN ("forward-word", Fforward_word, Sforward_word, 1, 1, "p",
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
675 "Move point forward ARG words (backward if ARG is negative).\n\
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
676 Normally returns t.\n\
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
677 If an edge of the buffer is reached, point is left there\n\
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
678 and nil is returned.")
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
679 (count)
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
680 Lisp_Object count;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
681 {
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
682 int val;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
683 CHECK_NUMBER (count, 0);
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
686 {
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
687 SET_PT (XINT (count) > 0 ? ZV : BEGV);
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
688 return Qnil;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
689 }
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
690 SET_PT (val);
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
691 return Qt;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
692 }
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
985 int parse_sexp_ignore_comments;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
986
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
987 Lisp_Object
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
988 scan_lists (from, count, depth, sexpflag)
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
989 register int from;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
990 int count, depth, sexpflag;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
991 {
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
992 Lisp_Object val;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
996 int quoted;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1003
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1004 if (depth > 0) min_depth = 0;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1005
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1006 immediate_quit = 1;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1007 QUIT;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1008
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1009 while (count > 0)
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1010 {
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1011 stop = ZV;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1012 while (from < stop)
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1013 {
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1019 if (from < stop && SYNTAX_COMSTART_FIRST (c)
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1020 && SYNTAX_COMSTART_SECOND (FETCH_CHAR (from))
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1033 if (SYNTAX_PREFIX (c))
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1034 continue;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1037 {
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1038 case Sescape:
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1039 case Scharquote:
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1042 /* treat following character as a word constituent */
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1043 case Sword:
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1044 case Ssymbol:
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1045 if (depth || !sexpflag) break;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1046 /* This word counts as a sexp; return at end of it. */
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1047 while (from < stop)
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1050 {
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1051 case Scharquote:
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1054 if (from == stop) goto lose;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1055 break;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1056 case Sword:
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1057 case Ssymbol:
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1058 case Squote:
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1059 break;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1060 default:
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1061 goto done;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1062 }
17044
f07c36097f33 Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents: 16992
diff changeset
1063 INC_POS (from);
163
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1064 }
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1065 goto done;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1066
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1067 case Scomment:
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1068 if (!parse_sexp_ignore_comments) break;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1069 while (1)
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1083 break;
17044
f07c36097f33 Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents: 16992
diff changeset
1084 INC_POS (from);
163
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1092 }
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1093 break;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1094
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1095 case Smath:
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1096 if (!sexpflag)
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1097 break;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1100 if (mathexit)
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1101 {
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1102 mathexit = 0;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1103 goto close1;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1104 }
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1105 mathexit = 1;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1106
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1107 case Sopen:
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1108 if (!++depth) goto done;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1109 break;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1110
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1111 case Sclose:
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1112 close1:
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1113 if (!--depth) goto done;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1119 break;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1120
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1125 while (1)
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1126 {
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1127 if (from >= stop) goto lose;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1130 {
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1131 case Scharquote:
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1134 }
17044
f07c36097f33 Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents: 16992
diff changeset
1135 INC_POS (from);
163
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1136 }
17044
f07c36097f33 Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents: 16992
diff changeset
1137 INC_POS (from);
163
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1138 if (!depth && sexpflag) goto done;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1139 break;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1140 }
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1141 }
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1142
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1143 /* Reached end of buffer. Error if within object, return nil if between */
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1144 if (depth) goto lose;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1145
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1146 immediate_quit = 0;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1147 return Qnil;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1148
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1149 /* End of object reached */
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1150 done:
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1151 count--;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1152 }
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1153
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1154 while (count < 0)
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1155 {
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1156 stop = BEGV;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1157 while (from > stop)
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1158 {
17044
f07c36097f33 Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents: 16992
diff changeset
1159 DEC_POS (from);
163
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1162 c = FETCH_CHAR (from);
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1184 if (SYNTAX_PREFIX (c))
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1185 continue;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1188 {
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1189 case Sword:
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1190 case Ssymbol:
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1191 if (depth || !sexpflag) break;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1192 /* This word counts as a sexp; count object finished after passing it. */
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1193 while (from > stop)
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1210 }
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1211 goto done2;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1212
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1213 case Smath:
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1214 if (!sexpflag)
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1220 if (mathexit)
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1221 {
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1222 mathexit = 0;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1223 goto open2;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1224 }
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1225 mathexit = 1;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1226
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1227 case Sclose:
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1228 if (!++depth) goto done2;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1229 break;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1230
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1231 case Sopen:
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1232 open2:
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1233 if (!--depth) goto done2;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1239 break;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1240
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1241 case Sendcomment:
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1242 if (!parse_sexp_ignore_comments)
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1272 /* Look back, counting the parity of string-quotes,
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1273 and recording the comment-starters seen.
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1274 When we reach a safe place, assume that's not in a string;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1275 then step the main scan to the earliest comment-starter seen
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1276 an even number of string quotes away from the safe place.
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1277
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1278 OFROM[I] is position of the earliest comment-starter seen
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1279 which is I+2X quotes from the comment-end.
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1280 PARITY is current parity of quotes from the comment end. */
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1281 {
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1291
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1292 /* At beginning of range to scan, we're outside of strings;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1293 that determines quote parity to the comment-end. */
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1294 while (from != stop)
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1295 {
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1298
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1299 c = FETCH_CHAR (from);
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1300 code = SYNTAX (c);
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1301
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1302 /* If this char is the second of a 2-char comment sequence,
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1324
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1325 /* Ignore escaped characters. */
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1326 if (char_quoted (from))
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1327 continue;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1340
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1341 /* Record comment-starters according to that
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1342 quote-parity to the comment-end. */
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1387 }
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1388 break;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1389
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1390 case Sstring:
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1391 stringterm = FETCH_CHAR (from);
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1392 while (1)
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1393 {
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1399 break;
17044
f07c36097f33 Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents: 16992
diff changeset
1400 from = temp_pos;
163
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1401 }
17044
f07c36097f33 Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents: 16992
diff changeset
1402 DEC_POS (from);
163
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1403 if (!depth && sexpflag) goto done2;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1404 break;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1405 }
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1406 }
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1407
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1408 /* Reached start of buffer. Error if within object, return nil if between */
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1409 if (depth) goto lose;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1410
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1411 immediate_quit = 0;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1412 return Qnil;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1413
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1414 done2:
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1415 count++;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1416 }
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1417
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1418
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1421 return val;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1422
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1429 /* NOTREACHED */
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1430 }
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1433 char_quoted (pos)
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1434 register int pos;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1435 {
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1436 register enum syntaxcode code;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1437 register int beg = BEGV;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1440
17044
f07c36097f33 Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents: 16992
diff changeset
1441 DEC_POS (temp_pos);
163
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1450 return quoted;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1451 }
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1452
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1453 DEFUN ("scan-lists", Fscan_lists, Sscan_lists, 3, 3, 0,
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1454 "Scan from character number FROM by COUNT lists.\n\
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1455 Returns the character number of the position thus found.\n\
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1456 \n\
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1457 If DEPTH is nonzero, paren depth begins counting from that value,\n\
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1458 only places where the depth in parentheses becomes zero\n\
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1459 are candidates for stopping; COUNT such places are counted.\n\
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1460 Thus, a positive value for DEPTH means go out levels.\n\
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1461 \n\
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1462 Comments are ignored if `parse-sexp-ignore-comments' is non-nil.\n\
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1463 \n\
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1464 If the beginning or end of (the accessible part of) the buffer is reached\n\
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1465 and the depth is wrong, an error is signaled.\n\
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1466 If the depth is right but the count is not used up, nil is returned.")
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1467 (from, count, depth)
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1468 Lisp_Object from, count, depth;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1469 {
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1470 CHECK_NUMBER (from, 0);
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1471 CHECK_NUMBER (count, 1);
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1472 CHECK_NUMBER (depth, 2);
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1473
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1474 return scan_lists (XINT (from), XINT (count), XINT (depth), 0);
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1475 }
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1476
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1477 DEFUN ("scan-sexps", Fscan_sexps, Sscan_sexps, 2, 2, 0,
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1478 "Scan from character number FROM by COUNT balanced expressions.\n\
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1479 If COUNT is negative, scan backwards.\n\
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1480 Returns the character number of the position thus found.\n\
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1481 \n\
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1482 Comments are ignored if `parse-sexp-ignore-comments' is non-nil.\n\
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1483 \n\
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1484 If the beginning or end of (the accessible part of) the buffer is reached\n\
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1485 in the middle of a parenthetical grouping, an error is signaled.\n\
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1486 If the beginning or end is reached between groupings\n\
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1487 but before count is used up, nil is returned.")
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1488 (from, count)
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1489 Lisp_Object from, count;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1490 {
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1491 CHECK_NUMBER (from, 0);
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1492 CHECK_NUMBER (count, 1);
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1493
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1494 return scan_lists (XINT (from), XINT (count), 0, 1);
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1495 }
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1496
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1497 DEFUN ("backward-prefix-chars", Fbackward_prefix_chars, Sbackward_prefix_chars,
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1498 0, 0, 0,
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1499 "Move point backward over any number of chars with prefix syntax.\n\
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1500 This includes chars with \"quote\" or \"prefix\" syntax (' or p).")
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1501 ()
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1502 {
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1517
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1518 SET_PT (pos);
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1519
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1520 return Qnil;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1521 }
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1533 register int from;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1534 int end, targetdepth, stopbefore;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1537 {
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1538 struct lisp_parse_state state;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1539
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1540 register enum syntaxcode code;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1541 struct level { int last, prev; };
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1542 struct level levelstart[100];
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1543 register struct level *curlevel = levelstart;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1546 register int depth; /* Paren depth of current scanning location.
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1547 level - levelstart equals this except
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1548 when the depth becomes negative. */
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1549 int mindepth; /* Lowest DEPTH value seen. */
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1550 int start_quoted = 0; /* Nonzero means starting after a char quote */
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1559
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1560 immediate_quit = 1;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1561 QUIT;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1562
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 163
diff changeset
1563 if (NILP (oldstate))
163
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1564 {
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1565 depth = 0;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1566 state.instring = -1;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1569 }
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1570 else
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1571 {
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1572 tem = Fcar (oldstate);
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 163
diff changeset
1573 if (!NILP (tem))
163
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1574 depth = XINT (tem);
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1575 else
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1576 depth = 0;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1577
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1578 oldstate = Fcdr (oldstate);
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1579 oldstate = Fcdr (oldstate);
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1580 oldstate = Fcdr (oldstate);
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1581 tem = Fcar (oldstate);
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 163
diff changeset
1582 state.instring = !NILP (tem) ? XINT (tem) : -1;
163
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1583
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1584 oldstate = Fcdr (oldstate);
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1585 tem = Fcar (oldstate);
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 163
diff changeset
1586 state.incomment = !NILP (tem);
163
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1587
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1588 oldstate = Fcdr (oldstate);
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1589 tem = Fcar (oldstate);
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 163
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1598 }
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1599 state.quoted = 0;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1600 mindepth = depth;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1601
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1602 curlevel->prev = -1;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1603 curlevel->last = -1;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1604
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1605 /* Enter the loop at a place appropriate for initial state. */
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1606
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1607 if (state.incomment) goto startincomment;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1608 if (state.instring >= 0)
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1609 {
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1610 if (start_quoted) goto startquotedinstring;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1611 goto startinstring;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1612 }
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1613 if (start_quoted) goto startquoted;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1614
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1615 while (from < end)
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1637 {
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1638 case Sescape:
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1639 case Scharquote:
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1642 startquoted:
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1645 goto symstarted;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1646 /* treat following character as a word constituent */
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1647 case Sword:
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1648 case Ssymbol:
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1651 symstarted:
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1652 while (from < end)
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1655 {
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1656 case Scharquote:
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1657 case Sescape:
17044
f07c36097f33 Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents: 16992
diff changeset
1658 INC_FROM;
163
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1659 if (from == end) goto endquoted;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1660 break;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1661 case Sword:
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1662 case Ssymbol:
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1663 case Squote:
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1664 break;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1665 default:
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1666 goto symdone;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1667 }
17044
f07c36097f33 Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents: 16992
diff changeset
1668 INC_FROM;
163
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1669 }
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1670 symdone:
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1671 curlevel->prev = curlevel->last;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1672 break;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1686 case Scomment:
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1690 while (1)
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1691 {
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1709 }
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1712 break;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1713
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1714 case Sopen:
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1715 if (stopbefore) goto stop; /* this arg means stop at sexp start */
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1716 depth++;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1719 if (++curlevel == endlevel)
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1720 error ("Nesting too deep for parser");
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1721 curlevel->prev = -1;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1724 break;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1725
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1726 case Sclose:
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1727 depth--;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1728 if (depth < mindepth)
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1729 mindepth = depth;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1730 if (curlevel != levelstart)
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1731 curlevel--;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1734 break;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1735
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1736 case Sstring:
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1740 startinstring:
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1741 while (1)
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1749 {
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1750 case Scharquote:
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1751 case Sescape:
17044
f07c36097f33 Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents: 16992
diff changeset
1752 INC_FROM;
163
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1753 startquotedinstring:
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1754 if (from >= end) goto endquoted;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1755 }
17044
f07c36097f33 Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents: 16992
diff changeset
1756 INC_FROM;
163
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1757 }
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1758 state.instring = -1;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1761 break;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1762
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1763 case Smath:
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1764 break;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1765 }
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1766 }
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1767 goto done;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1768
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1771 goto done; /* but return the position before it. */
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1772
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1773 endquoted:
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1774 state.quoted = 1;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1775 done:
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1776 state.depth = depth;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1777 state.mindepth = mindepth;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1778 state.thislevelstart = curlevel->prev;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1779 state.prevlevelstart
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1780 = (curlevel == levelstart) ? -1 : (curlevel - 1)->last;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1781 state.location = from;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1782 immediate_quit = 0;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1785 }
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1786
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1787 /* This comment supplies the doc string for parse-partial-sexp,
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1788 for make-docfile to see. We cannot put this in the real DEFUN
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1789 due to limits in the Unix cpp.
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1792 "Parse Lisp syntax starting at FROM until TO; return status of parse at TO.\n\
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1793 Parsing stops at TO or when certain criteria are met;\n\
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1794 point is set to where parsing stops.\n\
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1795 If fifth arg STATE is omitted or nil,\n\
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
cef07afc1e9e Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 4393
diff changeset
1798 0. depth in parens.\n\
cef07afc1e9e Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 4393
diff changeset
1799 1. character address of start of innermost containing list; nil if none.\n\
cef07afc1e9e Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 4393
diff changeset
1800 2. character address of start of last complete sexp terminated.\n\
cef07afc1e9e Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 4393
diff changeset
1801 3. non-nil if inside a string.\n\
163
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1802 (it is the character that will terminate the string.)\n\
4458
cef07afc1e9e Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 4393
diff changeset
1803 4. t if inside a comment.\n\
cef07afc1e9e Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 4393
diff changeset
1804 5. t if following a quote character.\n\
cef07afc1e9e Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 4393
diff changeset
1805 6. the minimum paren-depth encountered during this scan.\n\
cef07afc1e9e Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 4393
diff changeset
1806 7. t if in a comment of style `b'.\n\
163
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1807 If third arg TARGETDEPTH is non-nil, parsing stops if the depth\n\
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1808 in parentheses becomes equal to TARGETDEPTH.\n\
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1809 Fourth arg STOPBEFORE non-nil means stop when come to\n\
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1810 any character that starts a sexp.\n\
4393
3e20f4e3dbaa Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 4307
diff changeset
1811 Fifth arg STATE is an eight-list like what this function returns.\n\
726
5f08efa38dd0 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 624
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1816 */
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1822 {
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1823 struct lisp_parse_state state;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1824 int target;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1825
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 163
diff changeset
1826 if (!NILP (targetdepth))
163
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1827 {
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1828 CHECK_NUMBER (targetdepth, 3);
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1829 target = XINT (targetdepth);
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1830 }
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1831 else
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1832 target = -100000; /* We won't reach this depth */
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1833
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1838
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1839 SET_PT (state.location);
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1840
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1841 return Fcons (make_number (state.depth),
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1842 Fcons (state.prevlevelstart < 0 ? Qnil : make_number (state.prevlevelstart),
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1843 Fcons (state.thislevelstart < 0 ? Qnil : make_number (state.thislevelstart),
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1844 Fcons (state.instring >= 0 ? make_number (state.instring) : Qnil,
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1845 Fcons (state.incomment ? Qt : Qnil,
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1850 }
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1851
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1852 init_syntax_once ()
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1853 {
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1854 register int i;
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1909 for (i = 0; i < 10; i++)
13144
fd14ccddb85a (describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents: 12894
diff changeset
1910 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, "_-+*/&|<>="[i], temp);
163
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1911
17044
f07c36097f33 Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents: 16992
diff changeset
1912 temp = XVECTOR (Vsyntax_code_object)->contents[(int) Spunct];
163
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1913 for (i = 0; i < 12; i++)
13144
fd14ccddb85a (describe_syntax): Handle new syntax-table data format.
Richard M. Stallman <rms@gnu.org>
parents: 12894
diff changeset
1914 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table, ".,;:?!#@~^'`"[i], temp);
163
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1915 }
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1916
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1917 syms_of_syntax ()
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1918 {
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1919 Qsyntax_table_p = intern ("syntax-table-p");
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1920 staticpro (&Qsyntax_table_p);
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1921
17044
f07c36097f33 Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents: 16992
diff changeset
1922 staticpro (&Vsyntax_code_object);
f07c36097f33 Include charset.h and category.h.
Karl Heuer <kwzh@gnu.org>
parents: 16992
diff changeset
1923
16992
ff7346c31184 (scan_lists): Signal errors using scan-error.
Richard M. Stallman <rms@gnu.org>
parents: 16039
diff changeset
1924 Qscan_error = intern ("scan-error");
ff7346c31184 (scan_lists): Signal errors using scan-error.
Richard M. Stallman <rms@gnu.org>
parents: 16039
diff changeset
1925 staticpro (&Qscan_error);
ff7346c31184 (scan_lists): Signal errors using scan-error.
Richard M. Stallman <rms@gnu.org>
parents: 16039
diff changeset
1926 Fput (Qscan_error, Qerror_conditions,
ff7346c31184 (scan_lists): Signal errors using scan-error.
Richard M. Stallman <rms@gnu.org>
parents: 16039
diff changeset
1927 Fcons (Qerror, Qnil));
ff7346c31184 (scan_lists): Signal errors using scan-error.
Richard M. Stallman <rms@gnu.org>
parents: 16039
diff changeset
1928 Fput (Qscan_error, Qerror_message,
ff7346c31184 (scan_lists): Signal errors using scan-error.
Richard M. Stallman <rms@gnu.org>
parents: 16039
diff changeset
1929 build_string ("Scan error"));
ff7346c31184 (scan_lists): Signal errors using scan-error.
Richard M. Stallman <rms@gnu.org>
parents: 16039
diff changeset
1930
163
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1931 DEFVAR_BOOL ("parse-sexp-ignore-comments", &parse_sexp_ignore_comments,
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1932 "Non-nil means `forward-sexp', etc., should treat comments as whitespace.");
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1933
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1934 words_include_escapes = 0;
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1935 DEFVAR_BOOL ("words-include-escapes", &words_include_escapes,
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1936 "Non-nil means `forward-word', etc., should treat escape chars part of words.");
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1937
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1938 defsubr (&Ssyntax_table_p);
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1939 defsubr (&Ssyntax_table);
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1940 defsubr (&Sstandard_syntax_table);
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1941 defsubr (&Scopy_syntax_table);
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1942 defsubr (&Sset_syntax_table);
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1943 defsubr (&Schar_syntax);
7968
a6372621abd9 (Fmatching_paren): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7924
diff changeset
1944 defsubr (&Smatching_paren);
163
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1945 defsubr (&Smodify_syntax_entry);
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1946 defsubr (&Sdescribe_syntax);
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1947
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1948 defsubr (&Sforward_word);
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1949
1998
656f4297962e (describe_syntax_1): Delete excess arg to describe_vector.
Richard M. Stallman <rms@gnu.org>
parents: 1394
diff changeset
1950 defsubr (&Sforward_comment);
163
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1951 defsubr (&Sscan_lists);
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1952 defsubr (&Sscan_sexps);
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1953 defsubr (&Sbackward_prefix_chars);
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1954 defsubr (&Sparse_partial_sexp);
0f3996cb4ae5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1955 }