annotate src/syntax.c @ 88823:61df12ee934b

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