annotate src/font-lock.c @ 442:abe6d1db359e r21-2-36

Import from CVS: tag r21-2-36
author cvs
date Mon, 13 Aug 2007 11:35:02 +0200
parents 8de8e3f6228a
children 223736d75acb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 /* Routines to compute the current syntactic context, for font-lock mode.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2 Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3 Copyright (C) 1995 Sun Microsystems, Inc.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5 This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 XEmacs is free software; you can redistribute it and/or modify it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 Free Software Foundation; either version 2, or (at your option) any
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10 later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15 for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 along with XEmacs; see the file COPYING. If not, write to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20 Boston, MA 02111-1307, USA. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 /* Synched up with: Not in FSF. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24 /* This code computes the syntactic context of the current point, that is,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25 whether point is within a comment, a string, what have you. It does
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 this by picking a point "known" to be outside of any syntactic constructs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27 and moving forward, examining the syntax of each character.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29 Two caches are used: one caches the last point computed, and the other
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 caches the last point at the beginning of a line. This makes there
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31 be little penalty for moving left-to-right on a line a character at a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 time; makes starting over on a line be cheap; and makes random-accessing
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33 within a line relatively cheap.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 When we move to a different line farther down in the file (but within the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 current top-level form) we simply continue computing forward. If we move
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37 backward more than a line, or move beyond the end of the current tlf, or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 switch buffers, then we call `beginning-of-defun' and start over from
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 there.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41 #### We should really rewrite this to keep extents over the buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 that hold the current syntactic information. This would be a big win.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43 This way there would be no guessing or incorrect results.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46 #include <config.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 #include "lisp.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 #include "buffer.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 #include "insdel.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51 #include "syntax.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 Lisp_Object Qcomment;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 Lisp_Object Qblock_comment;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 Lisp_Object Qbeginning_of_defun;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 enum syntactic_context
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 context_none,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 context_string,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 context_comment,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 context_block_comment
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 enum block_comment_context
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 ccontext_none,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 ccontext_start1,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 ccontext_start2,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70 ccontext_end1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 enum comment_style
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75 comment_style_none,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76 comment_style_a,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77 comment_style_b
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 struct context_cache
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 Bufpos start_point; /* beginning of defun */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 Bufpos cur_point; /* cache location */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 Bufpos end_point; /* end of defun */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 struct buffer *buffer; /* does this need to be staticpro'd? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 enum syntactic_context context; /* single-char-syntax state */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 enum block_comment_context ccontext; /* block-comment state */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 enum comment_style style; /* which comment group */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 Emchar scontext; /* active string delimiter */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 int depth; /* depth in parens */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 int backslash_p; /* just read a backslash */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 int needs_its_head_reexamined; /* we're apparently outside of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 a top level form, and far away
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 from it. This is a bad situation
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 because it will lead to constant
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 slowness as we keep going way
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 back to that form and moving
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 forward again. In this case,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 we try to compute a "pseudo-
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 top-level-form" where the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 depth is 0 and the context
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 is none at both ends. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 /* We have two caches; one for the current point and one for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 the beginning of line. We used to rely on the caller to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 tell us when to invalidate them, but now we do it ourselves;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 it lets us be smarter. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 static struct context_cache context_cache;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 static struct context_cache bol_context_cache;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114 int font_lock_debug;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 #define reset_context_cache(cc) memset (cc, 0, sizeof (struct context_cache))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 /* This function is called from signal_after_change() to tell us when
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 textual changes are made so we can flush our caches when necessary.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 We make the following somewhat heuristic assumptions:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123 (remember that current_point is always >= start_point, but may be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124 less than or greater than end_point (we might not be inside any
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 top-level form)).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 1) Textual changes before the beginning of the current top-level form
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 don't affect anything; all we need to do is offset the caches
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 appropriately.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 2) Textual changes right at the beginning of the current
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131 top-level form messes things up and requires that we flush
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 the caches.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133 3) Textual changes after the beginning of the current top-level form
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134 and before one or both or the caches invalidates the corresponding
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135 cache(s).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136 4) Textual changes after the caches and before the end of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137 current top-level form don't affect anything; all we need to do is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138 offset the caches appropriately.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139 5) Textual changes right at the end of the current top-level form
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 necessitate recomputing that end value.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141 6) Textual changes after the end of the current top-level form
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 are ignored. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146 font_lock_maybe_update_syntactic_caches (struct buffer *buf, Bufpos start,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 Bufpos orig_end, Bufpos new_end)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 /* Note: either both context_cache and bol_context_cache are valid and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 point to the same buffer, or both are invalid. If we have to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151 invalidate just context_cache, we recopy it from bol_context_cache.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 if (context_cache.buffer != buf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154 /* caches don't apply */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 /* NOTE: The order of the if statements below is important. If you
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 change them around unthinkingly, you will probably break something. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 if (orig_end <= context_cache.start_point - 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 /* case 1: before the beginning of the current top-level form */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 Charcount diff = new_end - orig_end;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 if (font_lock_debug)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 stderr_out ("font-lock; Case 1\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164 context_cache.start_point += diff;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 context_cache.cur_point += diff;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 context_cache.end_point += diff;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 bol_context_cache.start_point += diff;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 bol_context_cache.cur_point += diff;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 bol_context_cache.end_point += diff;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 else if (start <= context_cache.start_point)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 if (font_lock_debug)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174 stderr_out ("font-lock; Case 2\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 /* case 2: right at the current top-level form (paren that starts
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 top level form got deleted or moved away from the newline it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177 was touching) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 reset_context_cache (&context_cache);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 reset_context_cache (&bol_context_cache);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 /* OK, now we know that the start is after the beginning of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 current top-level form. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 else if (start < bol_context_cache.cur_point)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 if (font_lock_debug)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186 stderr_out ("font-lock; Case 3 (1)\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 /* case 3: after the beginning of the current top-level form
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 and before both of the caches */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 reset_context_cache (&context_cache);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 reset_context_cache (&bol_context_cache);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 else if (start < context_cache.cur_point)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194 if (font_lock_debug)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 stderr_out ("font-lock; Case 3 (2)\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 /* case 3: but only need to invalidate one cache */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 context_cache = bol_context_cache;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199 /* OK, now we know that the start is after the caches. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200 else if (start >= context_cache.end_point)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202 if (font_lock_debug)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 stderr_out ("font-lock; Case 6\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204 /* case 6: after the end of the current top-level form
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 and after the caches. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 else if (orig_end <= context_cache.end_point - 2)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 /* case 4: after the caches and before the end of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 current top-level form */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 Charcount diff = new_end - orig_end;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 if (font_lock_debug)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 stderr_out ("font-lock; Case 4\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 context_cache.end_point += diff;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 bol_context_cache.end_point += diff;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219 if (font_lock_debug)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220 stderr_out ("font-lock; Case 5\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221 /* case 5: right at the end of the current top-level form */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222 context_cache.end_point = context_cache.start_point - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223 bol_context_cache.end_point = context_cache.start_point - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227 /* This function is called from Fkill_buffer(). */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230 font_lock_buffer_was_killed (struct buffer *buf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 if (context_cache.buffer == buf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234 reset_context_cache (&context_cache);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235 reset_context_cache (&bol_context_cache);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
239 static Bufpos
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240 beginning_of_defun (struct buffer *buf, Bufpos pt)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242 /* This function can GC */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243 Bufpos opt = BUF_PT (buf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244 if (pt == BUF_BEGV (buf))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245 return pt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246 BUF_SET_PT (buf, pt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247 /* There used to be some kludginess to call c++-beginning-of-defun
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248 if we're in C++ mode. There's no point in this any more;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249 we're using cc-mode. If you really want to get the old c++
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250 mode working, fix it rather than the C code. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251 call0_in_buffer (buf, Qbeginning_of_defun);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252 pt = BUF_PT (buf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253 BUF_SET_PT (buf, opt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254 return pt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257 static Bufpos
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258 end_of_defun (struct buffer *buf, Bufpos pt)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 Lisp_Object retval = scan_lists (buf, pt, 1, 0, 0, 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261 if (NILP (retval))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262 return BUF_ZV (buf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 return XINT (retval);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267 /* Set up context_cache for attempting to determine the syntactic context
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268 in buffer BUF at point PT. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 setup_context_cache (struct buffer *buf, Bufpos pt)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273 int recomputed_start_point = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
274 /* This function can GC */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275 if (context_cache.buffer != buf || pt < context_cache.start_point)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 start_over:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 if (font_lock_debug)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279 stderr_out ("reset context cache\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280 /* OK, completely invalid. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281 reset_context_cache (&context_cache);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282 reset_context_cache (&bol_context_cache);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 if (!context_cache.buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286 /* Need to recompute the start point. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287 if (font_lock_debug)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288 stderr_out ("recompute start\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 context_cache.start_point = beginning_of_defun (buf, pt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290 recomputed_start_point = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291 bol_context_cache.start_point = context_cache.start_point;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292 bol_context_cache.buffer = context_cache.buffer = buf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
293 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294 if (context_cache.end_point < context_cache.start_point)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
296 /* Need to recompute the end point. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
297 if (font_lock_debug)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 stderr_out ("recompute end\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299 context_cache.end_point = end_of_defun (buf, context_cache.start_point);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300 bol_context_cache.end_point = context_cache.end_point;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302 if (bol_context_cache.cur_point == 0 ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303 pt < bol_context_cache.cur_point)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305 if (font_lock_debug)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306 stderr_out ("reset to start\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307 if (pt > context_cache.end_point
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308 /* 3000 is some arbitrary delta but seems reasonable;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309 about the size of a reasonable function */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310 && pt - context_cache.end_point > 3000)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311 /* If we're far past the end of the top level form,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312 don't trust it; recompute it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314 /* But don't get in an infinite loop doing this.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315 If we're really far past the end of the top level
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
316 form, try to compute a pseudo-top-level form. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317 if (recomputed_start_point)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
318 context_cache.needs_its_head_reexamined = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320 /* force recomputation */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321 goto start_over;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
323 /* Go to the nearest end of the top-level form that's before
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324 us. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325 if (pt > context_cache.end_point)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326 pt = context_cache.end_point;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328 pt = context_cache.start_point;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
329 /* Reset current point to start of buffer. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
330 context_cache.cur_point = pt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331 context_cache.context = context_none;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
332 context_cache.ccontext = ccontext_none;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
333 context_cache.style = comment_style_none;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
334 context_cache.scontext = '\000';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335 context_cache.depth = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
336 context_cache.backslash_p = ((pt > 1) &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337 (BUF_FETCH_CHAR (buf, pt - 1) == '\\'));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
338 /* Note that the BOL context cache may not be at the beginning
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
339 of the line, but that should be OK, nobody's checking. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340 bol_context_cache = context_cache;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343 else if (pt < context_cache.cur_point)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
344 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
345 if (font_lock_debug)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
346 stderr_out ("reset to bol\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347 /* bol cache is OK but current_cache is not. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348 context_cache = bol_context_cache;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351 else if (pt <= context_cache.end_point)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353 if (font_lock_debug)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354 stderr_out ("everything is OK\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355 /* in same top-level form. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359 /* OK, we're past the end of the top-level form. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360 Bufpos maxpt = max (context_cache.end_point, context_cache.cur_point);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
361 #if 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
362 int shortage;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
363 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365 if (font_lock_debug)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366 stderr_out ("past end\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367 if (pt <= maxpt)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368 /* OK, fine. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370 #if 0
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
371 /* This appears to cause huge slowdowns in files which have no
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
372 top-level forms.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374 In any case, it's not really necessary that we know for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375 sure the top-level form we're in; if we're in a form
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376 but the form we have recorded is the previous one,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377 it will be OK. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
379 scan_buffer (buf, '\n', maxpt, pt, 1, &shortage, 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
380 if (!shortage)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381 /* If there was a newline in the region past the known universe,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382 we might be inside another top-level form, so start over.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383 Otherwise, we're outside of any top-level forms and we know
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
384 the one directly before us, so it's OK. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
385 goto start_over;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
386 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
387 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
388 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
389
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
390 #define SYNTAX_START_STYLE(table, c1, c2) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
391 (SYNTAX_STYLES_MATCH_START_P (table, c1, c2, SYNTAX_COMMENT_STYLE_A) ? \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
392 comment_style_a : \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
393 SYNTAX_STYLES_MATCH_START_P (table, c1, c2, SYNTAX_COMMENT_STYLE_B) ? \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
394 comment_style_b : \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
395 comment_style_none)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
396
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397 #define SYNTAX_END_STYLE(table, c1, c2) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398 (SYNTAX_STYLES_MATCH_END_P (table, c1, c2, SYNTAX_COMMENT_STYLE_A) ? \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399 comment_style_a : \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 SYNTAX_STYLES_MATCH_END_P (table, c1, c2, SYNTAX_COMMENT_STYLE_B) ? \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
401 comment_style_b : \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
402 comment_style_none)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
403
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404 #define SINGLE_SYNTAX_STYLE(table, c) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
405 (SYNTAX_STYLES_MATCH_1CHAR_P (table, c, SYNTAX_COMMENT_STYLE_A) ? \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406 comment_style_a : \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
407 SYNTAX_STYLES_MATCH_1CHAR_P (table, c, SYNTAX_COMMENT_STYLE_B) ? \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
408 comment_style_b : \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
409 comment_style_none)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
410
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
411 /* Set up context_cache for position PT in BUF. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
413 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
414 find_context (struct buffer *buf, Bufpos pt)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
415 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
416 /* This function can GC */
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
417 Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418 Lisp_Object syntaxtab = buf->syntax_table;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
419 Emchar prev_c, c;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
420 Bufpos target = pt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421 setup_context_cache (buf, pt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422 pt = context_cache.cur_point;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
423
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
424 if (pt > BUF_BEGV (buf))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
425 c = BUF_FETCH_CHAR (buf, pt - 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
426 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
427 c = '\n'; /* to get bol_context_cache at point-min */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429 for (; pt < target; pt++, context_cache.cur_point = pt)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431 if (context_cache.needs_its_head_reexamined)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
433 if (context_cache.depth == 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434 && context_cache.context == context_none)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
435 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
436 /* We've found an anchor spot.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
437 Try to put the start of defun within 6000 chars of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438 the target, and the end of defun as close as possible.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
439 6000 is also arbitrary but tries to strike a balance
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
440 between two conflicting pulls when dealing with a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
441 file that has lots of stuff sitting outside of a top-
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
442 level form:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
443
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
444 a) If you move past the start of defun, you will
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
445 have to recompute defun, which in this case
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
446 means that start of defun goes all the way back
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
447 to the beginning of the file; so you want
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
448 to set start of defun a ways back from the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
449 current point.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
450 b) If you move a line backwards but within start of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451 defun, you have to move back to start of defun;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452 so you don't want start of defun too far from
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453 the current point.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
454 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
455 if (target - context_cache.start_point > 6000)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
456 context_cache.start_point = pt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
457 context_cache.end_point = pt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
458 bol_context_cache = context_cache;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
459 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
460 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
461
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
462 prev_c = c;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
463 c = BUF_FETCH_CHAR (buf, pt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465 if (prev_c == '\n')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
466 bol_context_cache = context_cache;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
467
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468 if (context_cache.backslash_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
469 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
470 context_cache.backslash_p = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
471 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
472 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
473
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
474 switch (SYNTAX (mirrortab, c))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
475 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
476 case Sescape:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
477 context_cache.backslash_p = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
478 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
479
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
480 case Sopen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
481 if (context_cache.context == context_none)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
482 context_cache.depth++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
483 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
484
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
485 case Sclose:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
486 if (context_cache.context == context_none)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
487 context_cache.depth--;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490 case Scomment:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491 if (context_cache.context == context_none)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
493 context_cache.context = context_comment;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
494 context_cache.ccontext = ccontext_none;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495 context_cache.style = SINGLE_SYNTAX_STYLE (mirrortab, c);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496 if (context_cache.style == comment_style_none) abort ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
498 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
499
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
500 case Sendcomment:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
501 if (context_cache.style != SINGLE_SYNTAX_STYLE (mirrortab, c))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
502 ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503 else if (context_cache.context == context_comment)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505 context_cache.context = context_none;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506 context_cache.style = comment_style_none;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
507 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
508 else if (context_cache.context == context_block_comment &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
509 (context_cache.ccontext == ccontext_start2 ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
510 context_cache.ccontext == ccontext_end1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
511 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
512 context_cache.context = context_none;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
513 context_cache.ccontext = ccontext_none;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
514 context_cache.style = comment_style_none;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
515 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
516 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
517
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
518 case Sstring:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
519 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
520 if (context_cache.context == context_string &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
521 context_cache.scontext == c)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
522 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
523 context_cache.context = context_none;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
524 context_cache.scontext = '\000';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
525 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
526 else if (context_cache.context == context_none)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
527 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
528 Lisp_Object stringtermobj = syntax_match (syntaxtab, c);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
529 Emchar stringterm;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
530
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
531 if (CHARP (stringtermobj))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
532 stringterm = XCHAR (stringtermobj);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
533 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
534 stringterm = c;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
535 context_cache.context = context_string;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536 context_cache.scontext = stringterm;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
537 context_cache.ccontext = ccontext_none;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
538 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
539 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
541 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
542 ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
543 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
544
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
545 /* That takes care of the characters with manifest syntax.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
546 Now we've got to hack multi-char sequences that start
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
547 and end block comments.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
548 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
549 if ((SYNTAX_COMMENT_BITS (mirrortab, c) &
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
550 SYNTAX_SECOND_CHAR_START) &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
551 context_cache.context == context_none &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
552 context_cache.ccontext == ccontext_start1 &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
553 SYNTAX_START_P (mirrortab, prev_c, c) /* the two chars match */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
555 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
556 context_cache.ccontext = ccontext_start2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
557 context_cache.style = SYNTAX_START_STYLE (mirrortab, prev_c, c);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
558 if (context_cache.style == comment_style_none) abort ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
559 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
560 else if ((SYNTAX_COMMENT_BITS (mirrortab, c) &
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
561 SYNTAX_FIRST_CHAR_START) &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
562 context_cache.context == context_none &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
563 (context_cache.ccontext == ccontext_none ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
564 context_cache.ccontext == ccontext_start1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
565 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
566 context_cache.ccontext = ccontext_start1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
567 context_cache.style = comment_style_none; /* should be this already*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
568 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
569 else if ((SYNTAX_COMMENT_BITS (mirrortab, c) &
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
570 SYNTAX_SECOND_CHAR_END) &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
571 context_cache.context == context_block_comment &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
572 context_cache.ccontext == ccontext_end1 &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
573 SYNTAX_END_P (mirrortab, prev_c, c) &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
574 /* the two chars match */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
575 context_cache.style ==
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
576 SYNTAX_END_STYLE (mirrortab, prev_c, c)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
577 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
578 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
579 context_cache.context = context_none;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
580 context_cache.ccontext = ccontext_none;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
581 context_cache.style = comment_style_none;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
582 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
583 else if ((SYNTAX_COMMENT_BITS (mirrortab, c) &
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
584 SYNTAX_FIRST_CHAR_END) &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
585 context_cache.context == context_block_comment &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
586 (context_cache.style ==
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
587 SYNTAX_END_STYLE (mirrortab, c,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
588 BUF_FETCH_CHAR (buf, pt+1))) &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
589 (context_cache.ccontext == ccontext_start2 ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
590 context_cache.ccontext == ccontext_end1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
591 /* #### is it right to check for end1 here?? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
592 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
593 if (context_cache.style == comment_style_none) abort ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
594 context_cache.ccontext = ccontext_end1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
595 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
596
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
597 else if (context_cache.ccontext == ccontext_start1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
598 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
599 if (context_cache.context != context_none) abort ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
600 context_cache.ccontext = ccontext_none;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
601 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
602 else if (context_cache.ccontext == ccontext_end1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
603 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
604 if (context_cache.context != context_block_comment) abort ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
605 context_cache.context = context_none;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
606 context_cache.ccontext = ccontext_start2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
607 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
608
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
609 if (context_cache.ccontext == ccontext_start2 &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
610 context_cache.context == context_none)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
611 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
612 context_cache.context = context_block_comment;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
613 if (context_cache.style == comment_style_none) abort ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
614 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
615 else if (context_cache.ccontext == ccontext_none &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
616 context_cache.context == context_block_comment)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
617 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
618 context_cache.context = context_none;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
619 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
620 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
621
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
622 context_cache.needs_its_head_reexamined = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
623 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
624
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
625 static Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
626 context_to_symbol (enum syntactic_context context)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
627 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
628 switch (context)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
629 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
630 case context_none: return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
631 case context_string: return Qstring;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
632 case context_comment: return Qcomment;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
633 case context_block_comment: return Qblock_comment;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
634 default: abort (); return Qnil; /* suppress compiler warning */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
635 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
636 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
637
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
638 DEFUN ("buffer-syntactic-context", Fbuffer_syntactic_context, 0, 1, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
639 Return the syntactic context of BUFFER at point.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
640 If BUFFER is nil or omitted, the current buffer is assumed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
641 The returned value is one of the following symbols:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
642
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
643 nil ; meaning no special interpretation
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
644 string ; meaning point is within a string
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
645 comment ; meaning point is within a line comment
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
646 block-comment ; meaning point is within a block comment
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
647
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
648 See also the function `buffer-syntactic-context-depth', which returns
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
649 the current nesting-depth within all parenthesis-syntax delimiters
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
650 and the function `syntactically-sectionize', which will map a function
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
651 over each syntactic context in a region.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
652
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
653 WARNING: this may alter match-data.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
654 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
655 (buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
656 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
657 /* This function can GC */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
658 struct buffer *buf = decode_buffer (buffer, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
659 find_context (buf, BUF_PT (buf));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
660 return context_to_symbol (context_cache.context);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
661 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
662
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
663 DEFUN ("buffer-syntactic-context-depth", Fbuffer_syntactic_context_depth,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
664 0, 1, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
665 Return the depth within all parenthesis-syntax delimiters at point.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
666 If BUFFER is nil or omitted, the current buffer is assumed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
667 WARNING: this may alter match-data.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
668 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
669 (buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
670 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
671 /* This function can GC */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
672 struct buffer *buf = decode_buffer (buffer, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
673 find_context (buf, BUF_PT (buf));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
674 return make_int (context_cache.depth);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
675 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
676
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
677
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
678 DEFUN ("syntactically-sectionize", Fsyntactically_sectionize, 3, 4, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
679 Call FUNCTION for each contiguous syntactic context in the region.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
680 Call the given function with four arguments: the start and end of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
681 region, a symbol representing the syntactic context, and the current
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
682 depth (as returned by the functions `buffer-syntactic-context' and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
683 `buffer-syntactic-context-depth'). When this function is called, the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
684 current buffer will be set to BUFFER.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
685
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
686 WARNING: this may alter match-data.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
687 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
688 (function, start, end, buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
689 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
690 /* This function can GC */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
691 Bufpos s, pt, e;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
692 int edepth;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
693 enum syntactic_context this_context;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
694 Lisp_Object extent = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
695 struct gcpro gcpro1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
696 struct buffer *buf = decode_buffer (buffer, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
697
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
698 get_buffer_range_char (buf, start, end, &s, &e, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
699
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
700 pt = s;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
701 find_context (buf, pt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
702
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
703 GCPRO1 (extent);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
704 while (pt < e)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
705 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
706 Bufpos estart, eend;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
707 /* skip over "blank" areas, and bug out at end-of-buffer. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
708 while (context_cache.context == context_none)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
709 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
710 pt++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
711 if (pt >= e) goto DONE_LABEL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
712 find_context (buf, pt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
713 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
714 /* We've found a non-blank area; keep going until we reach its end */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
715 this_context = context_cache.context;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
716 estart = pt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
717
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
718 /* Minor kludge: consider the comment-start character(s) a part of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
719 the comment.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
720 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
721 if (this_context == context_block_comment &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
722 context_cache.ccontext == ccontext_start2)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
723 estart -= 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
724 else if (this_context == context_comment)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
725 estart -= 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
726
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
727 edepth = context_cache.depth;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
728 while (context_cache.context == this_context && pt < e)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
729 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
730 pt++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
731 find_context (buf, pt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
732 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
733
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
734 eend = pt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
735
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
736 /* Minor kludge: consider the character which terminated the comment
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
737 a part of the comment.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
738 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
739 if ((this_context == context_block_comment ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
740 this_context == context_comment)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
741 && pt < e)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
742 eend++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
743
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
744 if (estart == eend)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
745 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
746 /* Make sure not to pass in values that are outside the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
747 actual bounds of this function. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
748 call4_in_buffer (buf, function, make_int (max (s, estart)),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
749 make_int (eend == e ? e : eend - 1),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
750 context_to_symbol (this_context),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
751 make_int (edepth));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
752 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
753 DONE_LABEL:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
754 UNGCPRO;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
755 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
756 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
757
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
758 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
759 syms_of_font_lock (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
760 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
761 defsymbol (&Qcomment, "comment");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
762 defsymbol (&Qblock_comment, "block-comment");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
763 defsymbol (&Qbeginning_of_defun, "beginning-of-defun");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
764
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
765 DEFSUBR (Fbuffer_syntactic_context);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
766 DEFSUBR (Fbuffer_syntactic_context_depth);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
767 DEFSUBR (Fsyntactically_sectionize);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
768 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
769
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
770 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
771 reinit_vars_of_font_lock (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
772 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
773 xzero (context_cache);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
774 xzero (bol_context_cache);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
775 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
776
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
777 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
778 vars_of_font_lock (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
779 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
780 reinit_vars_of_font_lock ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
781 }