annotate src/syntax.c @ 21003:fd244f615d9d

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