1 /* GNU Emacs routines to deal with syntax tables; also word and list parsing.
2 Copyright (C) 1985, 1987, 1993, 1994, 1995, 1997, 1998, 1999, 2002,
3 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
5 This file is part of GNU Emacs.
7 GNU Emacs is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GNU Emacs is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU Emacs; see the file COPYING. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA. */
32 /* Make syntax table lookup grant data in gl_state. */
33 #define SYNTAX_ENTRY_VIA_PROPERTY
36 #include "intervals.h"
38 /* We use these constants in place for comment-style and
39 string-ender-char to distinguish comments/strings started by
40 comment_fence and string_fence codes. */
42 #define ST_COMMENT_STYLE (256 + 1)
43 #define ST_STRING_STYLE (256 + 2)
46 Lisp_Object Qsyntax_table_p
, Qsyntax_table
, Qscan_error
;
48 int words_include_escapes
;
49 int parse_sexp_lookup_properties
;
51 /* Nonzero means `scan-sexps' treat all multibyte characters as symbol. */
52 int multibyte_syntax_as_symbol
;
54 /* Used as a temporary in SYNTAX_ENTRY and other macros in syntax.h,
55 if not compiled with GCC. No need to mark it, since it is used
56 only very temporarily. */
57 Lisp_Object syntax_temp
;
59 /* Non-zero means an open parenthesis in column 0 is always considered
60 to be the start of a defun. Zero means an open parenthesis in
61 column 0 has no special meaning. */
63 int open_paren_in_column_0_is_defun_start
;
65 /* This is the internal form of the parse state used in parse-partial-sexp. */
67 struct lisp_parse_state
69 int depth
; /* Depth at end of parsing. */
70 int instring
; /* -1 if not within string, else desired terminator. */
71 int incomment
; /* -1 if in unnestable comment else comment nesting */
72 int comstyle
; /* comment style a=0, or b=1, or ST_COMMENT_STYLE. */
73 int quoted
; /* Nonzero if just after an escape char at end of parsing */
74 int thislevelstart
; /* Char number of most recent start-of-expression at current level */
75 int prevlevelstart
; /* Char number of start of containing expression */
76 int location
; /* Char number at which parsing stopped. */
77 int mindepth
; /* Minimum depth seen while scanning. */
78 int comstr_start
; /* Position just after last comment/string starter. */
79 Lisp_Object levelstarts
; /* Char numbers of starts-of-expression
80 of levels (starting from outermost). */
83 /* These variables are a cache for finding the start of a defun.
84 find_start_pos is the place for which the defun start was found.
85 find_start_value is the defun start position found for it.
86 find_start_value_byte is the corresponding byte position.
87 find_start_buffer is the buffer it was found in.
88 find_start_begv is the BEGV value when it was found.
89 find_start_modiff is the value of MODIFF when it was found. */
91 static int find_start_pos
;
92 static int find_start_value
;
93 static int find_start_value_byte
;
94 static struct buffer
*find_start_buffer
;
95 static int find_start_begv
;
96 static int find_start_modiff
;
99 static int find_defun_start
P_ ((int, int));
100 static int back_comment
P_ ((EMACS_INT
, EMACS_INT
, EMACS_INT
, int, int,
101 EMACS_INT
*, EMACS_INT
*));
102 static int char_quoted
P_ ((int, int));
103 static Lisp_Object skip_chars
P_ ((int, int, Lisp_Object
, Lisp_Object
, int));
104 static Lisp_Object scan_lists
P_ ((EMACS_INT
, EMACS_INT
, EMACS_INT
, int));
105 static void scan_sexps_forward
P_ ((struct lisp_parse_state
*,
107 int, Lisp_Object
, int));
108 static int in_classes
P_ ((int, Lisp_Object
));
111 struct gl_state_s gl_state
; /* Global state of syntax parser. */
113 INTERVAL
interval_of ();
114 #define INTERVALS_AT_ONCE 10 /* 1 + max-number of intervals
115 to scan to property-change. */
117 /* Update gl_state to an appropriate interval which contains CHARPOS. The
118 sign of COUNT give the relative position of CHARPOS wrt the previously
119 valid interval. If INIT, only [be]_property fields of gl_state are
120 valid at start, the rest is filled basing on OBJECT.
122 `gl_state.*_i' are the intervals, and CHARPOS is further in the search
123 direction than the intervals - or in an interval. We update the
124 current syntax-table basing on the property of this interval, and
125 update the interval to start further than CHARPOS - or be
126 NULL_INTERVAL. We also update lim_property to be the next value of
127 charpos to call this subroutine again - or be before/after the
128 start/end of OBJECT. */
131 update_syntax_table (charpos
, count
, init
, object
)
132 int charpos
, count
, init
;
135 Lisp_Object tmp_table
;
136 int cnt
= 0, invalidate
= 1;
141 gl_state
.old_prop
= Qnil
;
142 gl_state
.start
= gl_state
.b_property
;
143 gl_state
.stop
= gl_state
.e_property
;
144 i
= interval_of (charpos
, object
);
145 gl_state
.backward_i
= gl_state
.forward_i
= i
;
147 if (NULL_INTERVAL_P (i
))
149 /* interval_of updates only ->position of the return value, so
150 update the parents manually to speed up update_interval. */
151 while (!NULL_PARENT (i
))
153 if (AM_RIGHT_CHILD (i
))
154 INTERVAL_PARENT (i
)->position
= i
->position
155 - LEFT_TOTAL_LENGTH (i
) + TOTAL_LENGTH (i
) /* right end */
156 - TOTAL_LENGTH (INTERVAL_PARENT (i
))
157 + LEFT_TOTAL_LENGTH (INTERVAL_PARENT (i
));
159 INTERVAL_PARENT (i
)->position
= i
->position
- LEFT_TOTAL_LENGTH (i
)
161 i
= INTERVAL_PARENT (i
);
163 i
= gl_state
.forward_i
;
164 gl_state
.b_property
= i
->position
- gl_state
.offset
;
165 gl_state
.e_property
= INTERVAL_LAST_POS (i
) - gl_state
.offset
;
168 i
= count
> 0 ? gl_state
.forward_i
: gl_state
.backward_i
;
170 /* We are guaranteed to be called with CHARPOS either in i,
172 if (NULL_INTERVAL_P (i
))
173 error ("Error in syntax_table logic for to-the-end intervals");
174 else if (charpos
< i
->position
) /* Move left. */
177 error ("Error in syntax_table logic for intervals <-");
178 /* Update the interval. */
179 i
= update_interval (i
, charpos
);
180 if (INTERVAL_LAST_POS (i
) != gl_state
.b_property
)
183 gl_state
.forward_i
= i
;
184 gl_state
.e_property
= INTERVAL_LAST_POS (i
) - gl_state
.offset
;
187 else if (charpos
>= INTERVAL_LAST_POS (i
)) /* Move right. */
190 error ("Error in syntax_table logic for intervals ->");
191 /* Update the interval. */
192 i
= update_interval (i
, charpos
);
193 if (i
->position
!= gl_state
.e_property
)
196 gl_state
.backward_i
= i
;
197 gl_state
.b_property
= i
->position
- gl_state
.offset
;
202 tmp_table
= textget (i
->plist
, Qsyntax_table
);
205 invalidate
= !EQ (tmp_table
, gl_state
.old_prop
); /* Need to invalidate? */
207 if (invalidate
) /* Did not get to adjacent interval. */
208 { /* with the same table => */
209 /* invalidate the old range. */
212 gl_state
.backward_i
= i
;
213 gl_state
.b_property
= i
->position
- gl_state
.offset
;
217 gl_state
.forward_i
= i
;
218 gl_state
.e_property
= INTERVAL_LAST_POS (i
) - gl_state
.offset
;
222 if (!EQ (tmp_table
, gl_state
.old_prop
))
224 gl_state
.current_syntax_table
= tmp_table
;
225 gl_state
.old_prop
= tmp_table
;
226 if (EQ (Fsyntax_table_p (tmp_table
), Qt
))
228 gl_state
.use_global
= 0;
230 else if (CONSP (tmp_table
))
232 gl_state
.use_global
= 1;
233 gl_state
.global_code
= tmp_table
;
237 gl_state
.use_global
= 0;
238 gl_state
.current_syntax_table
= current_buffer
->syntax_table
;
242 while (!NULL_INTERVAL_P (i
))
244 if (cnt
&& !EQ (tmp_table
, textget (i
->plist
, Qsyntax_table
)))
248 gl_state
.e_property
= i
->position
- gl_state
.offset
;
249 gl_state
.forward_i
= i
;
254 = i
->position
+ LENGTH (i
) - gl_state
.offset
;
255 gl_state
.backward_i
= i
;
259 else if (cnt
== INTERVALS_AT_ONCE
)
264 = i
->position
+ LENGTH (i
) - gl_state
.offset
265 /* e_property at EOB is not set to ZV but to ZV+1, so that
266 we can do INC(from);UPDATE_SYNTAX_TABLE_FORWARD without
267 having to check eob between the two. */
268 + (NULL_INTERVAL_P (next_interval (i
)) ? 1 : 0);
269 gl_state
.forward_i
= i
;
273 gl_state
.b_property
= i
->position
- gl_state
.offset
;
274 gl_state
.backward_i
= i
;
279 i
= count
> 0 ? next_interval (i
) : previous_interval (i
);
281 eassert (NULL_INTERVAL_P (i
)); /* This property goes to the end. */
283 gl_state
.e_property
= gl_state
.stop
;
285 gl_state
.b_property
= gl_state
.start
;
288 /* Returns TRUE if char at CHARPOS is quoted.
289 Global syntax-table data should be set up already to be good at CHARPOS
290 or after. On return global syntax data is good for lookup at CHARPOS. */
293 char_quoted (charpos
, bytepos
)
294 register int charpos
, bytepos
;
296 register enum syntaxcode code
;
297 register int beg
= BEGV
;
298 register int quoted
= 0;
301 DEC_BOTH (charpos
, bytepos
);
303 while (charpos
>= beg
)
307 UPDATE_SYNTAX_TABLE_BACKWARD (charpos
);
308 c
= FETCH_CHAR (bytepos
);
310 if (! (code
== Scharquote
|| code
== Sescape
))
313 DEC_BOTH (charpos
, bytepos
);
317 UPDATE_SYNTAX_TABLE (orig
);
321 /* Return the bytepos one character after BYTEPOS.
322 We assume that BYTEPOS is not at the end of the buffer. */
325 inc_bytepos (bytepos
)
328 if (NILP (current_buffer
->enable_multibyte_characters
))
335 /* Return the bytepos one character before BYTEPOS.
336 We assume that BYTEPOS is not at the start of the buffer. */
339 dec_bytepos (bytepos
)
342 if (NILP (current_buffer
->enable_multibyte_characters
))
349 /* Return a defun-start position before before POS and not too far before.
350 It should be the last one before POS, or nearly the last.
352 When open_paren_in_column_0_is_defun_start is nonzero,
353 only the beginning of the buffer is treated as a defun-start.
355 We record the information about where the scan started
356 and what its result was, so that another call in the same area
357 can return the same value very quickly.
359 There is no promise at which position the global syntax data is
360 valid on return from the subroutine, so the caller should explicitly
361 update the global data. */
364 find_defun_start (pos
, pos_byte
)
367 int opoint
= PT
, opoint_byte
= PT_BYTE
;
369 if (!open_paren_in_column_0_is_defun_start
)
371 find_start_value_byte
= BEGV_BYTE
;
375 /* Use previous finding, if it's valid and applies to this inquiry. */
376 if (current_buffer
== find_start_buffer
377 /* Reuse the defun-start even if POS is a little farther on.
378 POS might be in the next defun, but that's ok.
379 Our value may not be the best possible, but will still be usable. */
380 && pos
<= find_start_pos
+ 1000
381 && pos
>= find_start_value
382 && BEGV
== find_start_begv
383 && MODIFF
== find_start_modiff
)
384 return find_start_value
;
386 /* Back up to start of line. */
387 scan_newline (pos
, pos_byte
, BEGV
, BEGV_BYTE
, -1, 1);
389 /* We optimize syntax-table lookup for rare updates. Thus we accept
390 only those `^\s(' which are good in global _and_ text-property
392 gl_state
.current_syntax_table
= current_buffer
->syntax_table
;
393 gl_state
.use_global
= 0;
398 /* Open-paren at start of line means we may have found our
400 c
= FETCH_CHAR (PT_BYTE
);
401 if (SYNTAX (c
) == Sopen
)
403 SETUP_SYNTAX_TABLE (PT
+ 1, -1); /* Try again... */
404 c
= FETCH_CHAR (PT_BYTE
);
405 if (SYNTAX (c
) == Sopen
)
407 /* Now fallback to the default value. */
408 gl_state
.current_syntax_table
= current_buffer
->syntax_table
;
409 gl_state
.use_global
= 0;
411 /* Move to beg of previous line. */
412 scan_newline (PT
, PT_BYTE
, BEGV
, BEGV_BYTE
, -2, 1);
415 /* Record what we found, for the next try. */
416 find_start_value
= PT
;
417 find_start_value_byte
= PT_BYTE
;
418 find_start_buffer
= current_buffer
;
419 find_start_modiff
= MODIFF
;
420 find_start_begv
= BEGV
;
421 find_start_pos
= pos
;
423 TEMP_SET_PT_BOTH (opoint
, opoint_byte
);
425 return find_start_value
;
428 /* Return the SYNTAX_COMEND_FIRST of the character before POS, POS_BYTE. */
431 prev_char_comend_first (pos
, pos_byte
)
436 DEC_BOTH (pos
, pos_byte
);
437 UPDATE_SYNTAX_TABLE_BACKWARD (pos
);
438 c
= FETCH_CHAR (pos_byte
);
439 val
= SYNTAX_COMEND_FIRST (c
);
440 UPDATE_SYNTAX_TABLE_FORWARD (pos
+ 1);
444 /* Return the SYNTAX_COMSTART_FIRST of the character before POS, POS_BYTE. */
447 * prev_char_comstart_first (pos, pos_byte)
452 * DEC_BOTH (pos, pos_byte);
453 * UPDATE_SYNTAX_TABLE_BACKWARD (pos);
454 * c = FETCH_CHAR (pos_byte);
455 * val = SYNTAX_COMSTART_FIRST (c);
456 * UPDATE_SYNTAX_TABLE_FORWARD (pos + 1);
460 /* Checks whether charpos FROM is at the end of a comment.
461 FROM_BYTE is the bytepos corresponding to FROM.
462 Do not move back before STOP.
464 Return a positive value if we find a comment ending at FROM/FROM_BYTE;
467 If successful, store the charpos of the comment's beginning
468 into *CHARPOS_PTR, and the bytepos into *BYTEPOS_PTR.
470 Global syntax data remains valid for backward search starting at
471 the returned value (or at FROM, if the search was not successful). */
474 back_comment (from
, from_byte
, stop
, comnested
, comstyle
, charpos_ptr
, bytepos_ptr
)
475 EMACS_INT from
, from_byte
, stop
;
476 int comnested
, comstyle
;
477 EMACS_INT
*charpos_ptr
, *bytepos_ptr
;
479 /* Look back, counting the parity of string-quotes,
480 and recording the comment-starters seen.
481 When we reach a safe place, assume that's not in a string;
482 then step the main scan to the earliest comment-starter seen
483 an even number of string quotes away from the safe place.
485 OFROM[I] is position of the earliest comment-starter seen
486 which is I+2X quotes from the comment-end.
487 PARITY is current parity of quotes from the comment end. */
488 int string_style
= -1; /* Presumed outside of any string. */
489 int string_lossage
= 0;
490 /* Not a real lossage: indicates that we have passed a matching comment
491 starter plus a non-matching comment-ender, meaning that any matching
492 comment-starter we might see later could be a false positive (hidden
493 inside another comment).
494 Test case: { a (* b } c (* d *) */
495 int comment_lossage
= 0;
496 int comment_end
= from
;
497 int comment_end_byte
= from_byte
;
498 int comstart_pos
= 0;
500 /* Place where the containing defun starts,
501 or 0 if we didn't come across it yet. */
503 int defun_start_byte
= 0;
504 register enum syntaxcode code
;
505 int nesting
= 1; /* current comment nesting */
509 /* FIXME: A }} comment-ender style leads to incorrect behavior
510 in the case of {{ c }}} because we ignore the last two chars which are
511 assumed to be comment-enders although they aren't. */
513 /* At beginning of range to scan, we're outside of strings;
514 that determines quote parity to the comment-end. */
517 int temp_byte
, prev_syntax
;
518 int com2start
, com2end
;
520 /* Move back and examine a character. */
521 DEC_BOTH (from
, from_byte
);
522 UPDATE_SYNTAX_TABLE_BACKWARD (from
);
524 prev_syntax
= syntax
;
525 c
= FETCH_CHAR (from_byte
);
526 syntax
= SYNTAX_WITH_FLAGS (c
);
529 /* Check for 2-char comment markers. */
530 com2start
= (SYNTAX_FLAGS_COMSTART_FIRST (syntax
)
531 && SYNTAX_FLAGS_COMSTART_SECOND (prev_syntax
)
532 && comstyle
== SYNTAX_FLAGS_COMMENT_STYLE (prev_syntax
)
533 && (SYNTAX_FLAGS_COMMENT_NESTED (prev_syntax
)
534 || SYNTAX_FLAGS_COMMENT_NESTED (syntax
)) == comnested
);
535 com2end
= (SYNTAX_FLAGS_COMEND_FIRST (syntax
)
536 && SYNTAX_FLAGS_COMEND_SECOND (prev_syntax
));
538 /* Nasty cases with overlapping 2-char comment markers:
539 - snmp-mode: -- c -- foo -- c --
547 /* If a 2-char comment sequence partly overlaps with another,
548 we don't try to be clever. */
549 if (from
> stop
&& (com2end
|| com2start
))
551 int next
= from
, next_byte
= from_byte
, next_c
, next_syntax
;
552 DEC_BOTH (next
, next_byte
);
553 UPDATE_SYNTAX_TABLE_BACKWARD (next
);
554 next_c
= FETCH_CHAR (next_byte
);
555 next_syntax
= SYNTAX_WITH_FLAGS (next_c
);
556 if (((com2start
|| comnested
)
557 && SYNTAX_FLAGS_COMEND_SECOND (syntax
)
558 && SYNTAX_FLAGS_COMEND_FIRST (next_syntax
))
559 || ((com2end
|| comnested
)
560 && SYNTAX_FLAGS_COMSTART_SECOND (syntax
)
561 && comstyle
== SYNTAX_FLAGS_COMMENT_STYLE (syntax
)
562 && SYNTAX_FLAGS_COMSTART_FIRST (next_syntax
)))
564 /* UPDATE_SYNTAX_TABLE_FORWARD (next + 1); */
567 if (com2start
&& comstart_pos
== 0)
568 /* We're looking at a comment starter. But it might be a comment
569 ender as well (see snmp-mode). The first time we see one, we
570 need to consider it as a comment starter,
571 and the subsequent times as a comment ender. */
574 /* Turn a 2-char comment sequences into the appropriate syntax. */
579 /* Ignore comment starters of a different style. */
580 else if (code
== Scomment
581 && (comstyle
!= SYNTAX_FLAGS_COMMENT_STYLE (syntax
)
582 || SYNTAX_FLAGS_COMMENT_NESTED (syntax
) != comnested
))
585 /* Ignore escaped characters, except comment-enders. */
586 if (code
!= Sendcomment
&& char_quoted (from
, from_byte
))
593 c
= (code
== Sstring_fence
? ST_STRING_STYLE
: ST_COMMENT_STYLE
);
595 /* Track parity of quotes. */
596 if (string_style
== -1)
597 /* Entering a string. */
599 else if (string_style
== c
)
600 /* Leaving the string. */
603 /* If we have two kinds of string delimiters.
604 There's no way to grok this scanning backwards. */
609 /* We've already checked that it is the relevant comstyle. */
610 if (string_style
!= -1 || comment_lossage
|| string_lossage
)
611 /* There are odd string quotes involved, so let's be careful.
612 Test case in Pascal: " { " a { " } */
617 /* Record best comment-starter so far. */
619 comstart_byte
= from_byte
;
621 else if (--nesting
<= 0)
622 /* nested comments have to be balanced, so we don't need to
623 keep looking for earlier ones. We use here the same (slightly
624 incorrect) reasoning as below: since it is followed by uniform
625 paired string quotes, this comment-start has to be outside of
626 strings, else the comment-end itself would be inside a string. */
631 if (SYNTAX_FLAGS_COMMENT_STYLE (syntax
) == comstyle
632 && ((com2end
&& SYNTAX_FLAGS_COMMENT_NESTED (prev_syntax
))
633 || SYNTAX_FLAGS_COMMENT_NESTED (syntax
)) == comnested
)
634 /* This is the same style of comment ender as ours. */
639 /* Anything before that can't count because it would match
640 this comment-ender rather than ours. */
641 from
= stop
; /* Break out of the loop. */
643 else if (comstart_pos
!= 0 || c
!= '\n')
644 /* We're mixing comment styles here, so we'd better be careful.
645 The (comstart_pos != 0 || c != '\n') check is not quite correct
646 (we should just always set comment_lossage), but removing it
647 would imply that any multiline comment in C would go through
648 lossage, which seems overkill.
649 The failure should only happen in the rare cases such as
655 /* Assume a defun-start point is outside of strings. */
656 if (open_paren_in_column_0_is_defun_start
658 || (temp_byte
= dec_bytepos (from_byte
),
659 FETCH_CHAR (temp_byte
) == '\n')))
662 defun_start_byte
= from_byte
;
663 from
= stop
; /* Break out of the loop. */
672 if (comstart_pos
== 0)
675 from_byte
= comment_end_byte
;
676 UPDATE_SYNTAX_TABLE_FORWARD (comment_end
- 1);
678 /* If comstart_pos is set and we get here (ie. didn't jump to `lossage'
679 or `done'), then we've found the beginning of the non-nested comment. */
680 else if (1) /* !comnested */
683 from_byte
= comstart_byte
;
684 UPDATE_SYNTAX_TABLE_FORWARD (from
- 1);
688 struct lisp_parse_state state
;
690 /* We had two kinds of string delimiters mixed up
691 together. Decode this going forwards.
692 Scan fwd from a known safe place (beginning-of-defun)
693 to the one in question; this records where we
694 last passed a comment starter. */
695 /* If we did not already find the defun start, find it now. */
696 if (defun_start
== 0)
698 defun_start
= find_defun_start (comment_end
, comment_end_byte
);
699 defun_start_byte
= find_start_value_byte
;
703 scan_sexps_forward (&state
,
704 defun_start
, defun_start_byte
,
705 comment_end
, -10000, 0, Qnil
, 0);
706 defun_start
= comment_end
;
707 if (state
.incomment
== (comnested
? 1 : -1)
708 && state
.comstyle
== comstyle
)
709 from
= state
.comstr_start
;
714 /* If comment_end is inside some other comment, maybe ours
715 is nested, so we need to try again from within the
716 surrounding comment. Example: { a (* " *) */
718 /* FIXME: We should advance by one or two chars. */
719 defun_start
= state
.comstr_start
+ 2;
720 defun_start_byte
= CHAR_TO_BYTE (defun_start
);
723 } while (defun_start
< comment_end
);
725 from_byte
= CHAR_TO_BYTE (from
);
726 UPDATE_SYNTAX_TABLE_FORWARD (from
- 1);
731 *bytepos_ptr
= from_byte
;
733 return (from
== comment_end
) ? -1 : from
;
736 DEFUN ("syntax-table-p", Fsyntax_table_p
, Ssyntax_table_p
, 1, 1, 0,
737 doc
: /* Return t if OBJECT is a syntax table.
738 Currently, any char-table counts as a syntax table. */)
742 if (CHAR_TABLE_P (object
)
743 && EQ (XCHAR_TABLE (object
)->purpose
, Qsyntax_table
))
749 check_syntax_table (obj
)
752 CHECK_TYPE (CHAR_TABLE_P (obj
) && EQ (XCHAR_TABLE (obj
)->purpose
, Qsyntax_table
),
753 Qsyntax_table_p
, obj
);
756 DEFUN ("syntax-table", Fsyntax_table
, Ssyntax_table
, 0, 0, 0,
757 doc
: /* Return the current syntax table.
758 This is the one specified by the current buffer. */)
761 return current_buffer
->syntax_table
;
764 DEFUN ("standard-syntax-table", Fstandard_syntax_table
,
765 Sstandard_syntax_table
, 0, 0, 0,
766 doc
: /* Return the standard syntax table.
767 This is the one used for new buffers. */)
770 return Vstandard_syntax_table
;
773 DEFUN ("copy-syntax-table", Fcopy_syntax_table
, Scopy_syntax_table
, 0, 1, 0,
774 doc
: /* Construct a new syntax table and return it.
775 It is a copy of the TABLE, which defaults to the standard syntax table. */)
782 check_syntax_table (table
);
784 table
= Vstandard_syntax_table
;
786 copy
= Fcopy_sequence (table
);
788 /* Only the standard syntax table should have a default element.
789 Other syntax tables should inherit from parents instead. */
790 XCHAR_TABLE (copy
)->defalt
= Qnil
;
792 /* Copied syntax tables should all have parents.
793 If we copied one with no parent, such as the standard syntax table,
794 use the standard syntax table as the copy's parent. */
795 if (NILP (XCHAR_TABLE (copy
)->parent
))
796 Fset_char_table_parent (copy
, Vstandard_syntax_table
);
800 DEFUN ("set-syntax-table", Fset_syntax_table
, Sset_syntax_table
, 1, 1, 0,
801 doc
: /* Select a new syntax table for the current buffer.
802 One argument, a syntax table. */)
807 check_syntax_table (table
);
808 current_buffer
->syntax_table
= table
;
809 /* Indicate that this buffer now has a specified syntax table. */
810 idx
= PER_BUFFER_VAR_IDX (syntax_table
);
811 SET_PER_BUFFER_VALUE_P (current_buffer
, idx
, 1);
815 /* Convert a letter which signifies a syntax code
816 into the code it signifies.
817 This is used by modify-syntax-entry, and other things. */
819 unsigned char syntax_spec_code
[0400] =
820 { 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377,
821 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377,
822 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377,
823 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377,
824 (char) Swhitespace
, (char) Scomment_fence
, (char) Sstring
, 0377,
825 (char) Smath
, 0377, 0377, (char) Squote
,
826 (char) Sopen
, (char) Sclose
, 0377, 0377,
827 0377, (char) Swhitespace
, (char) Spunct
, (char) Scharquote
,
828 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377,
829 0377, 0377, 0377, 0377,
830 (char) Scomment
, 0377, (char) Sendcomment
, 0377,
831 (char) Sinherit
, 0377, 0377, 0377, 0377, 0377, 0377, 0377, /* @, A ... */
832 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377,
833 0377, 0377, 0377, 0377, 0377, 0377, 0377, (char) Sword
,
834 0377, 0377, 0377, 0377, (char) Sescape
, 0377, 0377, (char) Ssymbol
,
835 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377, /* `, a, ... */
836 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377,
837 0377, 0377, 0377, 0377, 0377, 0377, 0377, (char) Sword
,
838 0377, 0377, 0377, 0377, (char) Sstring_fence
, 0377, 0377, 0377
841 /* Indexed by syntax code, give the letter that describes it. */
843 char syntax_code_spec
[16] =
845 ' ', '.', 'w', '_', '(', ')', '\'', '\"', '$', '\\', '/', '<', '>', '@',
849 /* Indexed by syntax code, give the object (cons of syntax code and
850 nil) to be stored in syntax table. Since these objects can be
851 shared among syntax tables, we generate them in advance. By
852 sharing objects, the function `describe-syntax' can give a more
854 static Lisp_Object Vsyntax_code_object
;
857 /* Look up the value for CHARACTER in syntax table TABLE's parent
858 and its parents. SYNTAX_ENTRY calls this, when TABLE itself has nil
859 for CHARACTER. It's actually used only when not compiled with GCC. */
862 syntax_parent_lookup (table
, character
)
870 table
= XCHAR_TABLE (table
)->parent
;
874 value
= XCHAR_TABLE (table
)->contents
[character
];
880 DEFUN ("char-syntax", Fchar_syntax
, Schar_syntax
, 1, 1, 0,
881 doc
: /* Return the syntax code of CHARACTER, described by a character.
882 For example, if CHARACTER is a word constituent,
883 the character `w' is returned.
884 The characters that correspond to various syntax codes
885 are listed in the documentation of `modify-syntax-entry'. */)
887 Lisp_Object character
;
890 gl_state
.current_syntax_table
= current_buffer
->syntax_table
;
892 gl_state
.use_global
= 0;
893 CHECK_NUMBER (character
);
894 char_int
= XINT (character
);
895 return make_number (syntax_code_spec
[(int) SYNTAX (char_int
)]);
898 DEFUN ("matching-paren", Fmatching_paren
, Smatching_paren
, 1, 1, 0,
899 doc
: /* Return the matching parenthesis of CHARACTER, or nil if none. */)
901 Lisp_Object character
;
904 gl_state
.current_syntax_table
= current_buffer
->syntax_table
;
905 gl_state
.use_global
= 0;
906 CHECK_NUMBER (character
);
907 char_int
= XINT (character
);
908 code
= SYNTAX (char_int
);
909 if (code
== Sopen
|| code
== Sclose
)
910 return SYNTAX_MATCH (char_int
);
914 DEFUN ("string-to-syntax", Fstring_to_syntax
, Sstring_to_syntax
, 1, 1, 0,
915 doc
: /* Convert a syntax specification STRING into syntax cell form.
916 STRING should be a string as it is allowed as argument of
917 `modify-syntax-entry'. Value is the equivalent cons cell
918 (CODE . MATCHING-CHAR) that can be used as value of a `syntax-table'
923 register const unsigned char *p
;
924 register enum syntaxcode code
;
928 CHECK_STRING (string
);
931 code
= (enum syntaxcode
) syntax_spec_code
[*p
++];
932 if (((int) code
& 0377) == 0377)
933 error ("Invalid syntax description letter: %c", p
[-1]);
935 if (code
== Sinherit
)
941 int character
= (STRING_CHAR_AND_LENGTH
942 (p
, SBYTES (string
) - 1, len
));
943 XSETINT (match
, character
);
944 if (XFASTINT (match
) == ' ')
984 if (val
< XVECTOR (Vsyntax_code_object
)->size
&& NILP (match
))
985 return XVECTOR (Vsyntax_code_object
)->contents
[val
];
987 /* Since we can't use a shared object, let's make a new one. */
988 return Fcons (make_number (val
), match
);
991 /* I really don't know why this is interactive
992 help-form should at least be made useful whilst reading the second arg. */
993 DEFUN ("modify-syntax-entry", Fmodify_syntax_entry
, Smodify_syntax_entry
, 2, 3,
994 "cSet syntax for character: \nsSet syntax for %s to: ",
995 doc
: /* Set syntax for character CHAR according to string NEWENTRY.
996 The syntax is changed only for table SYNTAX-TABLE, which defaults to
997 the current buffer's syntax table.
998 The first character of NEWENTRY should be one of the following:
999 Space or - whitespace syntax. w word constituent.
1000 _ symbol constituent. . punctuation.
1001 ( open-parenthesis. ) close-parenthesis.
1002 " string quote. \\ escape.
1003 $ paired delimiter. ' expression quote or prefix operator.
1004 < comment starter. > comment ender.
1005 / character-quote. @ inherit from `standard-syntax-table'.
1006 | generic string fence. ! generic comment fence.
1008 Only single-character comment start and end sequences are represented thus.
1009 Two-character sequences are represented as described below.
1010 The second character of NEWENTRY is the matching parenthesis,
1011 used only if the first character is `(' or `)'.
1012 Any additional characters are flags.
1013 Defined flags are the characters 1, 2, 3, 4, b, p, and n.
1014 1 means CHAR is the start of a two-char comment start sequence.
1015 2 means CHAR is the second character of such a sequence.
1016 3 means CHAR is the start of a two-char comment end sequence.
1017 4 means CHAR is the second character of such a sequence.
1019 There can be up to two orthogonal comment sequences. This is to support
1020 language modes such as C++. By default, all comment sequences are of style
1021 a, but you can set the comment sequence style to b (on the second character
1022 of a comment-start, or the first character of a comment-end sequence) using
1024 b means CHAR is part of comment sequence b.
1025 n means CHAR is part of a nestable comment sequence.
1027 p means CHAR is a prefix character for `backward-prefix-chars';
1028 such characters are treated as whitespace when they occur
1029 between expressions.
1030 usage: (modify-syntax-entry CHAR NEWENTRY &optional SYNTAX-TABLE) */)
1031 (c
, newentry
, syntax_table
)
1032 Lisp_Object c
, newentry
, syntax_table
;
1036 if (NILP (syntax_table
))
1037 syntax_table
= current_buffer
->syntax_table
;
1039 check_syntax_table (syntax_table
);
1041 SET_RAW_SYNTAX_ENTRY (syntax_table
, XINT (c
), Fstring_to_syntax (newentry
));
1045 /* Dump syntax table to buffer in human-readable format */
1047 DEFUN ("internal-describe-syntax-value", Finternal_describe_syntax_value
,
1048 Sinternal_describe_syntax_value
, 1, 1, 0,
1049 doc
: /* Insert a description of the internal syntax description SYNTAX at point. */)
1053 register enum syntaxcode code
;
1054 char desc
, start1
, start2
, end1
, end2
, prefix
, comstyle
, comnested
;
1056 Lisp_Object first
, match_lisp
, value
= syntax
;
1060 insert_string ("default");
1064 if (CHAR_TABLE_P (value
))
1066 insert_string ("deeper char-table ...");
1072 insert_string ("invalid");
1076 first
= XCAR (value
);
1077 match_lisp
= XCDR (value
);
1079 if (!INTEGERP (first
) || !(NILP (match_lisp
) || INTEGERP (match_lisp
)))
1081 insert_string ("invalid");
1085 code
= (enum syntaxcode
) (XINT (first
) & 0377);
1086 start1
= (XINT (first
) >> 16) & 1;
1087 start2
= (XINT (first
) >> 17) & 1;
1088 end1
= (XINT (first
) >> 18) & 1;
1089 end2
= (XINT (first
) >> 19) & 1;
1090 prefix
= (XINT (first
) >> 20) & 1;
1091 comstyle
= (XINT (first
) >> 21) & 1;
1092 comnested
= (XINT (first
) >> 22) & 1;
1094 if ((int) code
< 0 || (int) code
>= (int) Smax
)
1096 insert_string ("invalid");
1099 desc
= syntax_code_spec
[(int) code
];
1101 str
[0] = desc
, str
[1] = 0;
1104 if (NILP (match_lisp
))
1107 insert_char (XINT (match_lisp
));
1126 insert_string ("\twhich means: ");
1128 switch (SWITCH_ENUM_CAST (code
))
1131 insert_string ("whitespace"); break;
1133 insert_string ("punctuation"); break;
1135 insert_string ("word"); break;
1137 insert_string ("symbol"); break;
1139 insert_string ("open"); break;
1141 insert_string ("close"); break;
1143 insert_string ("prefix"); break;
1145 insert_string ("string"); break;
1147 insert_string ("math"); break;
1149 insert_string ("escape"); break;
1151 insert_string ("charquote"); break;
1153 insert_string ("comment"); break;
1155 insert_string ("endcomment"); break;
1157 insert_string ("inherit"); break;
1158 case Scomment_fence
:
1159 insert_string ("comment fence"); break;
1161 insert_string ("string fence"); break;
1163 insert_string ("invalid");
1167 if (!NILP (match_lisp
))
1169 insert_string (", matches ");
1170 insert_char (XINT (match_lisp
));
1174 insert_string (",\n\t is the first character of a comment-start sequence");
1176 insert_string (",\n\t is the second character of a comment-start sequence");
1179 insert_string (",\n\t is the first character of a comment-end sequence");
1181 insert_string (",\n\t is the second character of a comment-end sequence");
1183 insert_string (" (comment style b)");
1185 insert_string (" (nestable)");
1188 insert_string (",\n\t is a prefix character for `backward-prefix-chars'");
1193 int parse_sexp_ignore_comments
;
1195 /* Return the position across COUNT words from FROM.
1196 If that many words cannot be found before the end of the buffer, return 0.
1197 COUNT negative means scan backward and stop at word beginning. */
1200 scan_words (from
, count
)
1201 register int from
, count
;
1203 register int beg
= BEGV
;
1204 register int end
= ZV
;
1205 register int from_byte
= CHAR_TO_BYTE (from
);
1206 register enum syntaxcode code
;
1212 SETUP_SYNTAX_TABLE (from
, count
);
1223 UPDATE_SYNTAX_TABLE_FORWARD (from
);
1224 ch0
= FETCH_CHAR (from_byte
);
1225 code
= SYNTAX (ch0
);
1226 INC_BOTH (from
, from_byte
);
1227 if (words_include_escapes
1228 && (code
== Sescape
|| code
== Scharquote
))
1233 /* Now CH0 is a character which begins a word and FROM is the
1234 position of the next character. */
1237 if (from
== end
) break;
1238 UPDATE_SYNTAX_TABLE_FORWARD (from
);
1239 ch1
= FETCH_CHAR (from_byte
);
1240 code
= SYNTAX (ch1
);
1241 if (!(words_include_escapes
1242 && (code
== Sescape
|| code
== Scharquote
)))
1243 if (code
!= Sword
|| WORD_BOUNDARY_P (ch0
, ch1
))
1245 INC_BOTH (from
, from_byte
);
1259 DEC_BOTH (from
, from_byte
);
1260 UPDATE_SYNTAX_TABLE_BACKWARD (from
);
1261 ch1
= FETCH_CHAR (from_byte
);
1262 code
= SYNTAX (ch1
);
1263 if (words_include_escapes
1264 && (code
== Sescape
|| code
== Scharquote
))
1269 /* Now CH1 is a character which ends a word and FROM is the
1277 temp_byte
= dec_bytepos (from_byte
);
1278 UPDATE_SYNTAX_TABLE_BACKWARD (from
);
1279 ch0
= FETCH_CHAR (temp_byte
);
1280 code
= SYNTAX (ch0
);
1281 if (!(words_include_escapes
1282 && (code
== Sescape
|| code
== Scharquote
)))
1283 if (code
!= Sword
|| WORD_BOUNDARY_P (ch0
, ch1
))
1285 DEC_BOTH (from
, from_byte
);
1296 DEFUN ("forward-word", Fforward_word
, Sforward_word
, 0, 1, "p",
1297 doc
: /* Move point forward ARG words (backward if ARG is negative).
1299 If an edge of the buffer or a field boundary is reached, point is left there
1300 and the function returns nil. Field boundaries are not noticed if
1301 `inhibit-field-text-motion' is non-nil. */)
1309 XSETFASTINT (arg
, 1);
1313 val
= orig_val
= scan_words (PT
, XINT (arg
));
1315 val
= XINT (arg
) > 0 ? ZV
: BEGV
;
1317 /* Avoid jumping out of an input field. */
1318 tmp
= Fconstrain_to_field (make_number (val
), make_number (PT
),
1320 val
= XFASTINT (tmp
);
1323 return val
== orig_val
? Qt
: Qnil
;
1326 Lisp_Object
skip_chars ();
1328 DEFUN ("skip-chars-forward", Fskip_chars_forward
, Sskip_chars_forward
, 1, 2, 0,
1329 doc
: /* Move point forward, stopping before a char not in STRING, or at pos LIM.
1330 STRING is like the inside of a `[...]' in a regular expression
1331 except that `]' is never special and `\\' quotes `^', `-' or `\\'
1332 (but not as the end of a range; quoting is never needed there).
1333 Thus, with arg "a-zA-Z", this skips letters stopping before first nonletter.
1334 With arg "^a-zA-Z", skips nonletters stopping before first letter.
1335 Char classes, e.g. `[:alpha:]', are supported.
1337 Returns the distance traveled, either zero or positive. */)
1339 Lisp_Object string
, lim
;
1341 return skip_chars (1, 0, string
, lim
, 1);
1344 DEFUN ("skip-chars-backward", Fskip_chars_backward
, Sskip_chars_backward
, 1, 2, 0,
1345 doc
: /* Move point backward, stopping after a char not in STRING, or at pos LIM.
1346 See `skip-chars-forward' for details.
1347 Returns the distance traveled, either zero or negative. */)
1349 Lisp_Object string
, lim
;
1351 return skip_chars (0, 0, string
, lim
, 1);
1354 DEFUN ("skip-syntax-forward", Fskip_syntax_forward
, Sskip_syntax_forward
, 1, 2, 0,
1355 doc
: /* Move point forward across chars in specified syntax classes.
1356 SYNTAX is a string of syntax code characters.
1357 Stop before a char whose syntax is not in SYNTAX, or at position LIM.
1358 If SYNTAX starts with ^, skip characters whose syntax is NOT in SYNTAX.
1359 This function returns the distance traveled, either zero or positive. */)
1361 Lisp_Object syntax
, lim
;
1363 return skip_chars (1, 1, syntax
, lim
, 0);
1366 DEFUN ("skip-syntax-backward", Fskip_syntax_backward
, Sskip_syntax_backward
, 1, 2, 0,
1367 doc
: /* Move point backward across chars in specified syntax classes.
1368 SYNTAX is a string of syntax code characters.
1369 Stop on reaching a char whose syntax is not in SYNTAX, or at position LIM.
1370 If SYNTAX starts with ^, skip characters whose syntax is NOT in SYNTAX.
1371 This function returns the distance traveled, either zero or negative. */)
1373 Lisp_Object syntax
, lim
;
1375 return skip_chars (0, 1, syntax
, lim
, 0);
1379 skip_chars (forwardp
, syntaxp
, string
, lim
, handle_iso_classes
)
1380 int forwardp
, syntaxp
;
1381 Lisp_Object string
, lim
;
1382 int handle_iso_classes
;
1384 register unsigned int c
;
1385 unsigned char fastmap
[0400];
1386 /* If SYNTAXP is 0, STRING may contain multi-byte form of characters
1387 of which codes don't fit in FASTMAP. In that case, set the
1388 ranges of characters in CHAR_RANGES. */
1390 int n_char_ranges
= 0;
1392 register int i
, i_byte
;
1393 int multibyte
= !NILP (current_buffer
->enable_multibyte_characters
);
1394 int string_multibyte
;
1396 const unsigned char *str
;
1398 Lisp_Object iso_classes
;
1400 CHECK_STRING (string
);
1401 char_ranges
= (int *) alloca (SCHARS (string
) * (sizeof (int)) * 2);
1402 string_multibyte
= STRING_MULTIBYTE (string
);
1403 str
= SDATA (string
);
1404 size_byte
= SBYTES (string
);
1407 /* Adjust the multibyteness of the string to that of the buffer. */
1408 if (multibyte
!= string_multibyte
)
1413 nbytes
= count_size_as_multibyte (SDATA (string
),
1416 nbytes
= SCHARS (string
);
1417 if (nbytes
!= size_byte
)
1419 unsigned char *tmp
= (unsigned char *) alloca (nbytes
);
1420 copy_text (SDATA (string
), tmp
, size_byte
,
1421 string_multibyte
, multibyte
);
1428 XSETINT (lim
, forwardp
? ZV
: BEGV
);
1430 CHECK_NUMBER_COERCE_MARKER (lim
);
1432 /* In any case, don't allow scan outside bounds of buffer. */
1433 if (XINT (lim
) > ZV
)
1434 XSETFASTINT (lim
, ZV
);
1435 if (XINT (lim
) < BEGV
)
1436 XSETFASTINT (lim
, BEGV
);
1438 bzero (fastmap
, sizeof fastmap
);
1442 if (i_byte
< size_byte
1443 && SREF (string
, 0) == '^')
1445 negate
= 1; i_byte
++;
1448 /* Find the characters specified and set their elements of fastmap.
1449 If syntaxp, each character counts as itself.
1450 Otherwise, handle backslashes and ranges specially. */
1452 while (i_byte
< size_byte
)
1454 c
= STRING_CHAR_AND_LENGTH (str
+ i_byte
, size_byte
- i_byte
, len
);
1458 fastmap
[syntax_spec_code
[c
& 0377]] = 1;
1461 if (handle_iso_classes
&& c
== '['
1462 && i_byte
< size_byte
1463 && STRING_CHAR (str
+ i_byte
, size_byte
- i_byte
) == ':')
1465 const unsigned char *class_beg
= str
+ i_byte
+ 1;
1466 const unsigned char *class_end
= class_beg
;
1467 const unsigned char *class_limit
= str
+ size_byte
- 2;
1468 /* Leave room for the null. */
1469 unsigned char class_name
[CHAR_CLASS_MAX_LENGTH
+ 1];
1472 if (class_limit
- class_beg
> CHAR_CLASS_MAX_LENGTH
)
1473 class_limit
= class_beg
+ CHAR_CLASS_MAX_LENGTH
;
1475 while (class_end
< class_limit
1476 && *class_end
>= 'a' && *class_end
<= 'z')
1479 if (class_end
== class_beg
1480 || *class_end
!= ':' || class_end
[1] != ']')
1481 goto not_a_class_name
;
1483 bcopy (class_beg
, class_name
, class_end
- class_beg
);
1484 class_name
[class_end
- class_beg
] = 0;
1486 cc
= re_wctype (class_name
);
1488 error ("Invalid ISO C character class");
1490 iso_classes
= Fcons (make_number (cc
), iso_classes
);
1492 i_byte
= class_end
+ 2 - str
;
1499 if (i_byte
== size_byte
)
1502 c
= STRING_CHAR_AND_LENGTH (str
+ i_byte
,
1503 size_byte
- i_byte
, len
);
1506 /* Treat `-' as range character only if another character
1508 if (i_byte
+ 1 < size_byte
1509 && str
[i_byte
] == '-')
1513 /* Skip over the dash. */
1516 /* Get the end of the range. */
1517 c2
= STRING_CHAR_AND_LENGTH (str
+ i_byte
,
1518 size_byte
- i_byte
, len
);
1521 if (SINGLE_BYTE_CHAR_P (c
))
1523 if (! SINGLE_BYTE_CHAR_P (c2
))
1525 /* Handle a range starting with a character of
1526 less than 256, and ending with a character of
1527 not less than 256. Split that into two
1528 ranges, the low one ending at 0377, and the
1529 high one starting at the smallest character
1530 in the charset of C2 and ending at C2. */
1531 int charset
= CHAR_CHARSET (c2
);
1532 int c1
= MAKE_CHAR (charset
, 0, 0);
1534 char_ranges
[n_char_ranges
++] = c1
;
1535 char_ranges
[n_char_ranges
++] = c2
;
1544 else if (c
<= c2
) /* Both C and C2 are multibyte char. */
1546 char_ranges
[n_char_ranges
++] = c
;
1547 char_ranges
[n_char_ranges
++] = c2
;
1552 if (SINGLE_BYTE_CHAR_P (c
))
1556 char_ranges
[n_char_ranges
++] = c
;
1557 char_ranges
[n_char_ranges
++] = c
;
1563 /* If ^ was the first character, complement the fastmap. */
1565 for (i
= 0; i
< sizeof fastmap
; i
++)
1569 int start_point
= PT
;
1571 int pos_byte
= PT_BYTE
;
1572 unsigned char *p
= PT_ADDR
, *endp
, *stop
;
1576 endp
= (XINT (lim
) == GPT
) ? GPT_ADDR
: CHAR_POS_ADDR (XINT (lim
));
1577 stop
= (pos
< GPT
&& GPT
< XINT (lim
)) ? GPT_ADDR
: endp
;
1581 endp
= CHAR_POS_ADDR (XINT (lim
));
1582 stop
= (pos
>= GPT
&& GPT
> XINT (lim
)) ? GAP_END_ADDR
: endp
;
1588 SETUP_SYNTAX_TABLE (pos
, forwardp
? 1 : -1);
1603 c
= STRING_CHAR_AND_LENGTH (p
, MAX_MULTIBYTE_LENGTH
, nbytes
);
1604 if (! fastmap
[(int) SYNTAX (c
)])
1606 p
+= nbytes
, pos
++, pos_byte
+= nbytes
;
1607 UPDATE_SYNTAX_TABLE_FORWARD (pos
);
1619 if (! fastmap
[(int) SYNTAX (*p
)])
1622 UPDATE_SYNTAX_TABLE_FORWARD (pos
);
1630 unsigned char *prev_p
;
1641 while (--p
>= stop
&& ! CHAR_HEAD_P (*p
));
1642 PARSE_MULTIBYTE_SEQ (p
, MAX_MULTIBYTE_LENGTH
, nbytes
);
1643 if (prev_p
- p
> nbytes
)
1644 p
= prev_p
- 1, c
= *p
, nbytes
= 1;
1646 c
= STRING_CHAR (p
, MAX_MULTIBYTE_LENGTH
);
1647 pos
--, pos_byte
-= nbytes
;
1648 UPDATE_SYNTAX_TABLE_BACKWARD (pos
);
1649 if (! fastmap
[(int) SYNTAX (c
)])
1666 if (! fastmap
[(int) SYNTAX (p
[-1])])
1669 UPDATE_SYNTAX_TABLE_BACKWARD (pos
- 1);
1689 c
= STRING_CHAR_AND_LENGTH (p
, MAX_MULTIBYTE_LENGTH
, nbytes
);
1691 if (! NILP (iso_classes
) && in_classes (c
, iso_classes
))
1699 if (SINGLE_BYTE_CHAR_P (c
))
1706 /* If we are looking at a multibyte character,
1707 we must look up the character in the table
1708 CHAR_RANGES. If there's no data in the
1709 table, that character is not what we want to
1712 /* The following code do the right thing even if
1713 n_char_ranges is zero (i.e. no data in
1715 for (i
= 0; i
< n_char_ranges
; i
+= 2)
1716 if (c
>= char_ranges
[i
] && c
<= char_ranges
[i
+ 1])
1718 if (!(negate
^ (i
< n_char_ranges
)))
1722 p
+= nbytes
, pos
++, pos_byte
+= nbytes
;
1735 if (!NILP (iso_classes
) && in_classes (*p
, iso_classes
))
1740 goto fwd_unibyte_ok
;
1754 unsigned char *prev_p
;
1765 while (--p
>= stop
&& ! CHAR_HEAD_P (*p
));
1766 PARSE_MULTIBYTE_SEQ (p
, MAX_MULTIBYTE_LENGTH
, nbytes
);
1767 if (prev_p
- p
> nbytes
)
1768 p
= prev_p
- 1, c
= *p
, nbytes
= 1;
1770 c
= STRING_CHAR (p
, MAX_MULTIBYTE_LENGTH
);
1772 if (! NILP (iso_classes
) && in_classes (c
, iso_classes
))
1780 if (SINGLE_BYTE_CHAR_P (c
))
1787 /* See the comment in the previous similar code. */
1788 for (i
= 0; i
< n_char_ranges
; i
+= 2)
1789 if (c
>= char_ranges
[i
] && c
<= char_ranges
[i
+ 1])
1791 if (!(negate
^ (i
< n_char_ranges
)))
1795 pos
--, pos_byte
-= nbytes
;
1808 if (! NILP (iso_classes
) && in_classes (p
[-1], iso_classes
))
1813 goto back_unibyte_ok
;
1816 if (!fastmap
[p
[-1]])
1824 #if 0 /* Not needed now that a position in mid-character
1825 cannot be specified in Lisp. */
1827 /* INC_POS or DEC_POS might have moved POS over LIM. */
1828 && (forwardp
? (pos
> XINT (lim
)) : (pos
< XINT (lim
))))
1835 SET_PT_BOTH (pos
, pos_byte
);
1838 return make_number (PT
- start_point
);
1842 /* Return 1 if character C belongs to one of the ISO classes
1843 in the list ISO_CLASSES. Each class is represented by an
1844 integer which is its type according to re_wctype. */
1847 in_classes (c
, iso_classes
)
1849 Lisp_Object iso_classes
;
1853 while (! NILP (iso_classes
))
1856 elt
= XCAR (iso_classes
);
1857 iso_classes
= XCDR (iso_classes
);
1859 if (re_iswctype (c
, XFASTINT (elt
)))
1866 /* Jump over a comment, assuming we are at the beginning of one.
1867 FROM is the current position.
1868 FROM_BYTE is the bytepos corresponding to FROM.
1869 Do not move past STOP (a charpos).
1870 The comment over which we have to jump is of style STYLE
1871 (either SYNTAX_COMMENT_STYLE(foo) or ST_COMMENT_STYLE).
1872 NESTING should be positive to indicate the nesting at the beginning
1873 for nested comments and should be zero or negative else.
1874 ST_COMMENT_STYLE cannot be nested.
1875 PREV_SYNTAX is the SYNTAX_WITH_FLAGS of the previous character
1876 (or 0 If the search cannot start in the middle of a two-character).
1878 If successful, return 1 and store the charpos of the comment's end
1879 into *CHARPOS_PTR and the corresponding bytepos into *BYTEPOS_PTR.
1880 Else, return 0 and store the charpos STOP into *CHARPOS_PTR, the
1881 corresponding bytepos into *BYTEPOS_PTR and the current nesting
1882 (as defined for state.incomment) in *INCOMMENT_PTR.
1884 The comment end is the last character of the comment rather than the
1885 character just after the comment.
1887 Global syntax data is assumed to initially be valid for FROM and
1888 remains valid for forward search starting at the returned position. */
1891 forw_comment (from
, from_byte
, stop
, nesting
, style
, prev_syntax
,
1892 charpos_ptr
, bytepos_ptr
, incomment_ptr
)
1893 EMACS_INT from
, from_byte
, stop
;
1894 int nesting
, style
, prev_syntax
;
1895 EMACS_INT
*charpos_ptr
, *bytepos_ptr
;
1899 register enum syntaxcode code
;
1900 register int syntax
;
1902 if (nesting
<= 0) nesting
= -1;
1904 /* Enter the loop in the middle so that we find
1905 a 2-char comment ender if we start in the middle of it. */
1906 syntax
= prev_syntax
;
1907 if (syntax
!= 0) goto forw_incomment
;
1913 *incomment_ptr
= nesting
;
1914 *charpos_ptr
= from
;
1915 *bytepos_ptr
= from_byte
;
1918 c
= FETCH_CHAR (from_byte
);
1919 syntax
= SYNTAX_WITH_FLAGS (c
);
1920 code
= syntax
& 0xff;
1921 if (code
== Sendcomment
1922 && SYNTAX_FLAGS_COMMENT_STYLE (syntax
) == style
1923 && (SYNTAX_FLAGS_COMMENT_NESTED (syntax
) ?
1924 (nesting
> 0 && --nesting
== 0) : nesting
< 0))
1925 /* we have encountered a comment end of the same style
1926 as the comment sequence which began this comment
1929 if (code
== Scomment_fence
1930 && style
== ST_COMMENT_STYLE
)
1931 /* we have encountered a comment end of the same style
1932 as the comment sequence which began this comment
1937 && SYNTAX_FLAGS_COMMENT_NESTED (syntax
)
1938 && SYNTAX_FLAGS_COMMENT_STYLE (syntax
) == style
)
1939 /* we have encountered a nested comment of the same style
1940 as the comment sequence which began this comment section */
1942 INC_BOTH (from
, from_byte
);
1943 UPDATE_SYNTAX_TABLE_FORWARD (from
);
1946 if (from
< stop
&& SYNTAX_FLAGS_COMEND_FIRST (syntax
)
1947 && SYNTAX_FLAGS_COMMENT_STYLE (syntax
) == style
1948 && (c1
= FETCH_CHAR (from_byte
),
1949 SYNTAX_COMEND_SECOND (c1
))
1950 && ((SYNTAX_FLAGS_COMMENT_NESTED (syntax
) ||
1951 SYNTAX_COMMENT_NESTED (c1
)) ? nesting
> 0 : nesting
< 0))
1954 /* we have encountered a comment end of the same style
1955 as the comment sequence which began this comment
1960 INC_BOTH (from
, from_byte
);
1961 UPDATE_SYNTAX_TABLE_FORWARD (from
);
1966 && SYNTAX_FLAGS_COMSTART_FIRST (syntax
)
1967 && (c1
= FETCH_CHAR (from_byte
),
1968 SYNTAX_COMMENT_STYLE (c1
) == style
1969 && SYNTAX_COMSTART_SECOND (c1
))
1970 && (SYNTAX_FLAGS_COMMENT_NESTED (syntax
) ||
1971 SYNTAX_COMMENT_NESTED (c1
)))
1972 /* we have encountered a nested comment of the same style
1973 as the comment sequence which began this comment
1976 INC_BOTH (from
, from_byte
);
1977 UPDATE_SYNTAX_TABLE_FORWARD (from
);
1981 *charpos_ptr
= from
;
1982 *bytepos_ptr
= from_byte
;
1986 DEFUN ("forward-comment", Fforward_comment
, Sforward_comment
, 1, 1, 0,
1988 Move forward across up to COUNT comments. If COUNT is negative, move backward.
1989 Stop scanning if we find something other than a comment or whitespace.
1990 Set point to where scanning stops.
1991 If COUNT comments are found as expected, with nothing except whitespace
1992 between them, return t; otherwise return nil. */)
1996 register EMACS_INT from
;
1997 EMACS_INT from_byte
;
1998 register EMACS_INT stop
;
2000 register enum syntaxcode code
;
2001 int comstyle
= 0; /* style of comment encountered */
2002 int comnested
= 0; /* whether the comment is nestable or not */
2005 EMACS_INT out_charpos
, out_bytepos
;
2008 CHECK_NUMBER (count
);
2009 count1
= XINT (count
);
2010 stop
= count1
> 0 ? ZV
: BEGV
;
2016 from_byte
= PT_BYTE
;
2018 SETUP_SYNTAX_TABLE (from
, count1
);
2027 SET_PT_BOTH (from
, from_byte
);
2031 c
= FETCH_CHAR (from_byte
);
2033 comstart_first
= SYNTAX_COMSTART_FIRST (c
);
2034 comnested
= SYNTAX_COMMENT_NESTED (c
);
2035 comstyle
= SYNTAX_COMMENT_STYLE (c
);
2036 INC_BOTH (from
, from_byte
);
2037 UPDATE_SYNTAX_TABLE_FORWARD (from
);
2038 if (from
< stop
&& comstart_first
2039 && (c1
= FETCH_CHAR (from_byte
),
2040 SYNTAX_COMSTART_SECOND (c1
)))
2042 /* We have encountered a comment start sequence and we
2043 are ignoring all text inside comments. We must record
2044 the comment style this sequence begins so that later,
2045 only a comment end of the same style actually ends
2046 the comment section. */
2048 comstyle
= SYNTAX_COMMENT_STYLE (c1
);
2049 comnested
= comnested
|| SYNTAX_COMMENT_NESTED (c1
);
2050 INC_BOTH (from
, from_byte
);
2051 UPDATE_SYNTAX_TABLE_FORWARD (from
);
2054 while (code
== Swhitespace
|| (code
== Sendcomment
&& c
== '\n'));
2056 if (code
== Scomment_fence
)
2057 comstyle
= ST_COMMENT_STYLE
;
2058 else if (code
!= Scomment
)
2061 DEC_BOTH (from
, from_byte
);
2062 SET_PT_BOTH (from
, from_byte
);
2065 /* We're at the start of a comment. */
2066 found
= forw_comment (from
, from_byte
, stop
, comnested
, comstyle
, 0,
2067 &out_charpos
, &out_bytepos
, &dummy
);
2068 from
= out_charpos
; from_byte
= out_bytepos
;
2072 SET_PT_BOTH (from
, from_byte
);
2075 INC_BOTH (from
, from_byte
);
2076 UPDATE_SYNTAX_TABLE_FORWARD (from
);
2077 /* We have skipped one comment. */
2089 SET_PT_BOTH (BEGV
, BEGV_BYTE
);
2094 DEC_BOTH (from
, from_byte
);
2095 /* char_quoted does UPDATE_SYNTAX_TABLE_BACKWARD (from). */
2096 quoted
= char_quoted (from
, from_byte
);
2097 c
= FETCH_CHAR (from_byte
);
2100 comnested
= SYNTAX_COMMENT_NESTED (c
);
2101 if (code
== Sendcomment
)
2102 comstyle
= SYNTAX_COMMENT_STYLE (c
);
2103 if (from
> stop
&& SYNTAX_COMEND_SECOND (c
)
2104 && prev_char_comend_first (from
, from_byte
)
2105 && !char_quoted (from
- 1, dec_bytepos (from_byte
)))
2107 /* We must record the comment style encountered so that
2108 later, we can match only the proper comment begin
2109 sequence of the same style. */
2110 DEC_BOTH (from
, from_byte
);
2112 /* Calling char_quoted, above, set up global syntax position
2113 at the new value of FROM. */
2114 c1
= FETCH_CHAR (from_byte
);
2115 comstyle
= SYNTAX_COMMENT_STYLE (c1
);
2116 comnested
= comnested
|| SYNTAX_COMMENT_NESTED (c1
);
2119 if (code
== Scomment_fence
)
2121 /* Skip until first preceding unquoted comment_fence. */
2122 int found
= 0, ini
= from
, ini_byte
= from_byte
;
2126 DEC_BOTH (from
, from_byte
);
2127 UPDATE_SYNTAX_TABLE_BACKWARD (from
);
2128 c
= FETCH_CHAR (from_byte
);
2129 if (SYNTAX (c
) == Scomment_fence
2130 && !char_quoted (from
, from_byte
))
2135 else if (from
== stop
)
2140 from
= ini
; /* Set point to ini + 1. */
2141 from_byte
= ini_byte
;
2145 /* We have skipped one comment. */
2148 else if (code
== Sendcomment
)
2150 found
= back_comment (from
, from_byte
, stop
, comnested
, comstyle
,
2151 &out_charpos
, &out_bytepos
);
2155 /* This end-of-line is not an end-of-comment.
2156 Treat it like a whitespace.
2157 CC-mode (and maybe others) relies on this behavior. */
2161 /* Failure: we should go back to the end of this
2162 not-quite-endcomment. */
2163 if (SYNTAX(c
) != code
)
2164 /* It was a two-char Sendcomment. */
2165 INC_BOTH (from
, from_byte
);
2171 /* We have skipped one comment. */
2172 from
= out_charpos
, from_byte
= out_bytepos
;
2176 else if (code
!= Swhitespace
|| quoted
)
2180 INC_BOTH (from
, from_byte
);
2181 SET_PT_BOTH (from
, from_byte
);
2189 SET_PT_BOTH (from
, from_byte
);
2194 /* Return syntax code of character C if C is a single byte character
2195 or `multibyte_symbol_p' is zero. Otherwise, return Ssymbol. */
2197 #define SYNTAX_WITH_MULTIBYTE_CHECK(c) \
2198 ((SINGLE_BYTE_CHAR_P (c) || !multibyte_symbol_p) \
2199 ? SYNTAX (c) : Ssymbol)
2202 scan_lists (from
, count
, depth
, sexpflag
)
2203 register EMACS_INT from
;
2204 EMACS_INT count
, depth
;
2208 register EMACS_INT stop
= count
> 0 ? ZV
: BEGV
;
2213 register enum syntaxcode code
, temp_code
;
2214 int min_depth
= depth
; /* Err out if depth gets less than this. */
2215 int comstyle
= 0; /* style of comment encountered */
2216 int comnested
= 0; /* whether the comment is nestable or not */
2218 EMACS_INT last_good
= from
;
2220 EMACS_INT from_byte
;
2221 EMACS_INT out_bytepos
, out_charpos
;
2223 int multibyte_symbol_p
= sexpflag
&& multibyte_syntax_as_symbol
;
2225 if (depth
> 0) min_depth
= 0;
2227 if (from
> ZV
) from
= ZV
;
2228 if (from
< BEGV
) from
= BEGV
;
2230 from_byte
= CHAR_TO_BYTE (from
);
2235 SETUP_SYNTAX_TABLE (from
, count
);
2240 int comstart_first
, prefix
;
2241 UPDATE_SYNTAX_TABLE_FORWARD (from
);
2242 c
= FETCH_CHAR (from_byte
);
2243 code
= SYNTAX_WITH_MULTIBYTE_CHECK (c
);
2244 comstart_first
= SYNTAX_COMSTART_FIRST (c
);
2245 comnested
= SYNTAX_COMMENT_NESTED (c
);
2246 comstyle
= SYNTAX_COMMENT_STYLE (c
);
2247 prefix
= SYNTAX_PREFIX (c
);
2248 if (depth
== min_depth
)
2250 INC_BOTH (from
, from_byte
);
2251 UPDATE_SYNTAX_TABLE_FORWARD (from
);
2252 if (from
< stop
&& comstart_first
2253 && (c
= FETCH_CHAR (from_byte
), SYNTAX_COMSTART_SECOND (c
))
2254 && parse_sexp_ignore_comments
)
2256 /* we have encountered a comment start sequence and we
2257 are ignoring all text inside comments. We must record
2258 the comment style this sequence begins so that later,
2259 only a comment end of the same style actually ends
2260 the comment section */
2262 c1
= FETCH_CHAR (from_byte
);
2263 comstyle
= SYNTAX_COMMENT_STYLE (c1
);
2264 comnested
= comnested
|| SYNTAX_COMMENT_NESTED (c1
);
2265 INC_BOTH (from
, from_byte
);
2266 UPDATE_SYNTAX_TABLE_FORWARD (from
);
2272 switch (SWITCH_ENUM_CAST (code
))
2276 if (from
== stop
) goto lose
;
2277 INC_BOTH (from
, from_byte
);
2278 /* treat following character as a word constituent */
2281 if (depth
|| !sexpflag
) break;
2282 /* This word counts as a sexp; return at end of it. */
2285 UPDATE_SYNTAX_TABLE_FORWARD (from
);
2287 /* Some compilers can't handle this inside the switch. */
2288 c
= FETCH_CHAR (from_byte
);
2289 temp
= SYNTAX_WITH_MULTIBYTE_CHECK (c
);
2294 INC_BOTH (from
, from_byte
);
2295 if (from
== stop
) goto lose
;
2304 INC_BOTH (from
, from_byte
);
2308 case Scomment_fence
:
2309 comstyle
= ST_COMMENT_STYLE
;
2312 if (!parse_sexp_ignore_comments
) break;
2313 UPDATE_SYNTAX_TABLE_FORWARD (from
);
2314 found
= forw_comment (from
, from_byte
, stop
,
2315 comnested
, comstyle
, 0,
2316 &out_charpos
, &out_bytepos
, &dummy
);
2317 from
= out_charpos
, from_byte
= out_bytepos
;
2324 INC_BOTH (from
, from_byte
);
2325 UPDATE_SYNTAX_TABLE_FORWARD (from
);
2331 if (from
!= stop
&& c
== FETCH_CHAR (from_byte
))
2333 INC_BOTH (from
, from_byte
);
2343 if (!++depth
) goto done
;
2348 if (!--depth
) goto done
;
2349 if (depth
< min_depth
)
2350 xsignal3 (Qscan_error
,
2351 build_string ("Containing expression ends prematurely"),
2352 make_number (last_good
), make_number (from
));
2357 temp_pos
= dec_bytepos (from_byte
);
2358 stringterm
= FETCH_CHAR (temp_pos
);
2361 if (from
>= stop
) goto lose
;
2362 UPDATE_SYNTAX_TABLE_FORWARD (from
);
2363 c
= FETCH_CHAR (from_byte
);
2366 && SYNTAX_WITH_MULTIBYTE_CHECK (c
) == Sstring
)
2367 : SYNTAX_WITH_MULTIBYTE_CHECK (c
) == Sstring_fence
)
2370 /* Some compilers can't handle this inside the switch. */
2371 temp
= SYNTAX_WITH_MULTIBYTE_CHECK (c
);
2376 INC_BOTH (from
, from_byte
);
2378 INC_BOTH (from
, from_byte
);
2380 INC_BOTH (from
, from_byte
);
2381 if (!depth
&& sexpflag
) goto done
;
2384 /* Ignore whitespace, punctuation, quote, endcomment. */
2389 /* Reached end of buffer. Error if within object, return nil if between */
2390 if (depth
) goto lose
;
2395 /* End of object reached */
2404 DEC_BOTH (from
, from_byte
);
2405 UPDATE_SYNTAX_TABLE_BACKWARD (from
);
2406 c
= FETCH_CHAR (from_byte
);
2407 code
= SYNTAX_WITH_MULTIBYTE_CHECK (c
);
2408 if (depth
== min_depth
)
2411 comnested
= SYNTAX_COMMENT_NESTED (c
);
2412 if (code
== Sendcomment
)
2413 comstyle
= SYNTAX_COMMENT_STYLE (c
);
2414 if (from
> stop
&& SYNTAX_COMEND_SECOND (c
)
2415 && prev_char_comend_first (from
, from_byte
)
2416 && parse_sexp_ignore_comments
)
2418 /* We must record the comment style encountered so that
2419 later, we can match only the proper comment begin
2420 sequence of the same style. */
2421 DEC_BOTH (from
, from_byte
);
2422 UPDATE_SYNTAX_TABLE_BACKWARD (from
);
2424 c1
= FETCH_CHAR (from_byte
);
2425 comstyle
= SYNTAX_COMMENT_STYLE (c1
);
2426 comnested
= comnested
|| SYNTAX_COMMENT_NESTED (c1
);
2429 /* Quoting turns anything except a comment-ender
2430 into a word character. Note that this cannot be true
2431 if we decremented FROM in the if-statement above. */
2432 if (code
!= Sendcomment
&& char_quoted (from
, from_byte
))
2434 DEC_BOTH (from
, from_byte
);
2437 else if (SYNTAX_PREFIX (c
))
2440 switch (SWITCH_ENUM_CAST (code
))
2446 if (depth
|| !sexpflag
) break;
2447 /* This word counts as a sexp; count object finished
2448 after passing it. */
2451 temp_pos
= from_byte
;
2452 if (! NILP (current_buffer
->enable_multibyte_characters
))
2456 UPDATE_SYNTAX_TABLE_BACKWARD (from
- 1);
2457 c1
= FETCH_CHAR (temp_pos
);
2458 temp_code
= SYNTAX_WITH_MULTIBYTE_CHECK (c1
);
2459 /* Don't allow comment-end to be quoted. */
2460 if (temp_code
== Sendcomment
)
2462 quoted
= char_quoted (from
- 1, temp_pos
);
2465 DEC_BOTH (from
, from_byte
);
2466 temp_pos
= dec_bytepos (temp_pos
);
2467 UPDATE_SYNTAX_TABLE_BACKWARD (from
- 1);
2469 c1
= FETCH_CHAR (temp_pos
);
2470 temp_code
= SYNTAX_WITH_MULTIBYTE_CHECK (c1
);
2471 if (! (quoted
|| temp_code
== Sword
2472 || temp_code
== Ssymbol
2473 || temp_code
== Squote
))
2475 DEC_BOTH (from
, from_byte
);
2482 temp_pos
= dec_bytepos (from_byte
);
2483 UPDATE_SYNTAX_TABLE_BACKWARD (from
- 1);
2484 if (from
!= stop
&& c
== FETCH_CHAR (temp_pos
))
2485 DEC_BOTH (from
, from_byte
);
2494 if (!++depth
) goto done2
;
2499 if (!--depth
) goto done2
;
2500 if (depth
< min_depth
)
2501 xsignal3 (Qscan_error
,
2502 build_string ("Containing expression ends prematurely"),
2503 make_number (last_good
), make_number (from
));
2507 if (!parse_sexp_ignore_comments
)
2509 found
= back_comment (from
, from_byte
, stop
, comnested
, comstyle
,
2510 &out_charpos
, &out_bytepos
);
2511 /* FIXME: if found == -1, then it really wasn't a comment-end.
2512 For single-char Sendcomment, we can't do much about it apart
2513 from skipping the char.
2514 For 2-char endcomments, we could try again, taking both
2515 chars as separate entities, but it's a lot of trouble
2516 for very little gain, so we don't bother either. -sm */
2518 from
= out_charpos
, from_byte
= out_bytepos
;
2521 case Scomment_fence
:
2525 if (from
== stop
) goto lose
;
2526 DEC_BOTH (from
, from_byte
);
2527 UPDATE_SYNTAX_TABLE_BACKWARD (from
);
2528 if (!char_quoted (from
, from_byte
)
2529 && (c
= FETCH_CHAR (from_byte
),
2530 SYNTAX_WITH_MULTIBYTE_CHECK (c
) == code
))
2533 if (code
== Sstring_fence
&& !depth
&& sexpflag
) goto done2
;
2537 stringterm
= FETCH_CHAR (from_byte
);
2540 if (from
== stop
) goto lose
;
2541 DEC_BOTH (from
, from_byte
);
2542 UPDATE_SYNTAX_TABLE_BACKWARD (from
);
2543 if (!char_quoted (from
, from_byte
)
2544 && stringterm
== (c
= FETCH_CHAR (from_byte
))
2545 && SYNTAX_WITH_MULTIBYTE_CHECK (c
) == Sstring
)
2548 if (!depth
&& sexpflag
) goto done2
;
2551 /* Ignore whitespace, punctuation, quote, endcomment. */
2556 /* Reached start of buffer. Error if within object, return nil if between */
2557 if (depth
) goto lose
;
2568 XSETFASTINT (val
, from
);
2572 xsignal3 (Qscan_error
,
2573 build_string ("Unbalanced parentheses"),
2574 make_number (last_good
), make_number (from
));
2577 DEFUN ("scan-lists", Fscan_lists
, Sscan_lists
, 3, 3, 0,
2578 doc
: /* Scan from character number FROM by COUNT lists.
2579 Returns the character number of the position thus found.
2581 If DEPTH is nonzero, paren depth begins counting from that value,
2582 only places where the depth in parentheses becomes zero
2583 are candidates for stopping; COUNT such places are counted.
2584 Thus, a positive value for DEPTH means go out levels.
2586 Comments are ignored if `parse-sexp-ignore-comments' is non-nil.
2588 If the beginning or end of (the accessible part of) the buffer is reached
2589 and the depth is wrong, an error is signaled.
2590 If the depth is right but the count is not used up, nil is returned. */)
2591 (from
, count
, depth
)
2592 Lisp_Object from
, count
, depth
;
2594 CHECK_NUMBER (from
);
2595 CHECK_NUMBER (count
);
2596 CHECK_NUMBER (depth
);
2598 return scan_lists (XINT (from
), XINT (count
), XINT (depth
), 0);
2601 DEFUN ("scan-sexps", Fscan_sexps
, Sscan_sexps
, 2, 2, 0,
2602 doc
: /* Scan from character number FROM by COUNT balanced expressions.
2603 If COUNT is negative, scan backwards.
2604 Returns the character number of the position thus found.
2606 Comments are ignored if `parse-sexp-ignore-comments' is non-nil.
2608 If the beginning or end of (the accessible part of) the buffer is reached
2609 in the middle of a parenthetical grouping, an error is signaled.
2610 If the beginning or end is reached between groupings
2611 but before count is used up, nil is returned. */)
2613 Lisp_Object from
, count
;
2615 CHECK_NUMBER (from
);
2616 CHECK_NUMBER (count
);
2618 return scan_lists (XINT (from
), XINT (count
), 0, 1);
2621 DEFUN ("backward-prefix-chars", Fbackward_prefix_chars
, Sbackward_prefix_chars
,
2623 doc
: /* Move point backward over any number of chars with prefix syntax.
2624 This includes chars with "quote" or "prefix" syntax (' or p). */)
2629 int opoint_byte
= PT_BYTE
;
2631 int pos_byte
= PT_BYTE
;
2636 SET_PT_BOTH (opoint
, opoint_byte
);
2641 SETUP_SYNTAX_TABLE (pos
, -1);
2643 DEC_BOTH (pos
, pos_byte
);
2645 while (!char_quoted (pos
, pos_byte
)
2646 /* Previous statement updates syntax table. */
2647 && ((c
= FETCH_CHAR (pos_byte
), SYNTAX (c
) == Squote
)
2648 || SYNTAX_PREFIX (c
)))
2651 opoint_byte
= pos_byte
;
2654 DEC_BOTH (pos
, pos_byte
);
2657 SET_PT_BOTH (opoint
, opoint_byte
);
2662 /* Parse forward from FROM / FROM_BYTE to END,
2663 assuming that FROM has state OLDSTATE (nil means FROM is start of function),
2664 and return a description of the state of the parse at END.
2665 If STOPBEFORE is nonzero, stop at the start of an atom.
2666 If COMMENTSTOP is 1, stop at the start of a comment.
2667 If COMMENTSTOP is -1, stop at the start or end of a comment,
2668 after the beginning of a string, or after the end of a string. */
2671 scan_sexps_forward (stateptr
, from
, from_byte
, end
, targetdepth
,
2672 stopbefore
, oldstate
, commentstop
)
2673 struct lisp_parse_state
*stateptr
;
2675 int end
, targetdepth
, stopbefore
, from_byte
;
2676 Lisp_Object oldstate
;
2679 struct lisp_parse_state state
;
2681 register enum syntaxcode code
;
2684 struct level
{ int last
, prev
; };
2685 struct level levelstart
[100];
2686 register struct level
*curlevel
= levelstart
;
2687 struct level
*endlevel
= levelstart
+ 100;
2688 register int depth
; /* Paren depth of current scanning location.
2689 level - levelstart equals this except
2690 when the depth becomes negative. */
2691 int mindepth
; /* Lowest DEPTH value seen. */
2692 int start_quoted
= 0; /* Nonzero means starting after a char quote */
2694 int prev_from
; /* Keep one character before FROM. */
2696 int prev_from_syntax
;
2697 int boundary_stop
= commentstop
== -1;
2700 EMACS_INT out_bytepos
, out_charpos
;
2704 prev_from_byte
= from_byte
;
2706 DEC_BOTH (prev_from
, prev_from_byte
);
2708 /* Use this macro instead of `from++'. */
2710 do { prev_from = from; \
2711 prev_from_byte = from_byte; \
2712 temp = FETCH_CHAR (prev_from_byte); \
2713 prev_from_syntax = SYNTAX_WITH_FLAGS (temp); \
2714 INC_BOTH (from, from_byte); \
2716 UPDATE_SYNTAX_TABLE_FORWARD (from); \
2722 if (NILP (oldstate
))
2725 state
.instring
= -1;
2726 state
.incomment
= 0;
2727 state
.comstyle
= 0; /* comment style a by default. */
2728 state
.comstr_start
= -1; /* no comment/string seen. */
2732 tem
= Fcar (oldstate
);
2738 oldstate
= Fcdr (oldstate
);
2739 oldstate
= Fcdr (oldstate
);
2740 oldstate
= Fcdr (oldstate
);
2741 tem
= Fcar (oldstate
);
2742 /* Check whether we are inside string_fence-style string: */
2743 state
.instring
= (!NILP (tem
)
2744 ? (INTEGERP (tem
) ? XINT (tem
) : ST_STRING_STYLE
)
2747 oldstate
= Fcdr (oldstate
);
2748 tem
= Fcar (oldstate
);
2749 state
.incomment
= (!NILP (tem
)
2750 ? (INTEGERP (tem
) ? XINT (tem
) : -1)
2753 oldstate
= Fcdr (oldstate
);
2754 tem
= Fcar (oldstate
);
2755 start_quoted
= !NILP (tem
);
2757 /* if the eighth element of the list is nil, we are in comment
2758 style a. If it is non-nil, we are in comment style b */
2759 oldstate
= Fcdr (oldstate
);
2760 oldstate
= Fcdr (oldstate
);
2761 tem
= Fcar (oldstate
);
2762 state
.comstyle
= NILP (tem
) ? 0 : (EQ (tem
, Qsyntax_table
)
2763 ? ST_COMMENT_STYLE
: 1);
2765 oldstate
= Fcdr (oldstate
);
2766 tem
= Fcar (oldstate
);
2767 state
.comstr_start
= NILP (tem
) ? -1 : XINT (tem
) ;
2768 oldstate
= Fcdr (oldstate
);
2769 tem
= Fcar (oldstate
);
2770 while (!NILP (tem
)) /* >= second enclosing sexps. */
2772 /* curlevel++->last ran into compiler bug on Apollo */
2773 curlevel
->last
= XINT (Fcar (tem
));
2774 if (++curlevel
== endlevel
)
2775 curlevel
--; /* error ("Nesting too deep for parser"); */
2776 curlevel
->prev
= -1;
2777 curlevel
->last
= -1;
2784 curlevel
->prev
= -1;
2785 curlevel
->last
= -1;
2787 SETUP_SYNTAX_TABLE (prev_from
, 1);
2788 temp
= FETCH_CHAR (prev_from_byte
);
2789 prev_from_syntax
= SYNTAX_WITH_FLAGS (temp
);
2790 UPDATE_SYNTAX_TABLE_FORWARD (from
);
2792 /* Enter the loop at a place appropriate for initial state. */
2794 if (state
.incomment
)
2795 goto startincomment
;
2796 if (state
.instring
>= 0)
2798 nofence
= state
.instring
!= ST_STRING_STYLE
;
2800 goto startquotedinstring
;
2803 else if (start_quoted
)
2809 code
= prev_from_syntax
& 0xff;
2812 && SYNTAX_FLAGS_COMSTART_FIRST (prev_from_syntax
)
2813 && (c1
= FETCH_CHAR (from_byte
),
2814 SYNTAX_COMSTART_SECOND (c1
)))
2815 /* Duplicate code to avoid a complex if-expression
2816 which causes trouble for the SGI compiler. */
2818 /* Record the comment style we have entered so that only
2819 the comment-end sequence of the same style actually
2820 terminates the comment section. */
2821 state
.comstyle
= SYNTAX_COMMENT_STYLE (c1
);
2822 comnested
= SYNTAX_FLAGS_COMMENT_NESTED (prev_from_syntax
);
2823 comnested
= comnested
|| SYNTAX_COMMENT_NESTED (c1
);
2824 state
.incomment
= comnested
? 1 : -1;
2825 state
.comstr_start
= prev_from
;
2829 else if (code
== Scomment_fence
)
2831 /* Record the comment style we have entered so that only
2832 the comment-end sequence of the same style actually
2833 terminates the comment section. */
2834 state
.comstyle
= ST_COMMENT_STYLE
;
2835 state
.incomment
= -1;
2836 state
.comstr_start
= prev_from
;
2839 else if (code
== Scomment
)
2841 state
.comstyle
= SYNTAX_FLAGS_COMMENT_STYLE (prev_from_syntax
);
2842 state
.incomment
= (SYNTAX_FLAGS_COMMENT_NESTED (prev_from_syntax
) ?
2844 state
.comstr_start
= prev_from
;
2847 if (SYNTAX_FLAGS_PREFIX (prev_from_syntax
))
2849 switch (SWITCH_ENUM_CAST (code
))
2853 if (stopbefore
) goto stop
; /* this arg means stop at sexp start */
2854 curlevel
->last
= prev_from
;
2856 if (from
== end
) goto endquoted
;
2859 /* treat following character as a word constituent */
2862 if (stopbefore
) goto stop
; /* this arg means stop at sexp start */
2863 curlevel
->last
= prev_from
;
2867 /* Some compilers can't handle this inside the switch. */
2868 temp
= FETCH_CHAR (from_byte
);
2869 temp
= SYNTAX (temp
);
2875 if (from
== end
) goto endquoted
;
2887 curlevel
->prev
= curlevel
->last
;
2890 case Scomment_fence
: /* Can't happen because it's handled above. */
2892 if (commentstop
|| boundary_stop
) goto done
;
2894 /* The (from == BEGV) test was to enter the loop in the middle so
2895 that we find a 2-char comment ender even if we start in the
2896 middle of it. We don't want to do that if we're just at the
2897 beginning of the comment (think of (*) ... (*)). */
2898 found
= forw_comment (from
, from_byte
, end
,
2899 state
.incomment
, state
.comstyle
,
2900 (from
== BEGV
|| from
< state
.comstr_start
+ 3)
2901 ? 0 : prev_from_syntax
,
2902 &out_charpos
, &out_bytepos
, &state
.incomment
);
2903 from
= out_charpos
; from_byte
= out_bytepos
;
2904 /* Beware! prev_from and friends are invalid now.
2905 Luckily, the `done' doesn't use them and the INC_FROM
2906 sets them to a sane value without looking at them. */
2907 if (!found
) goto done
;
2909 state
.incomment
= 0;
2910 state
.comstyle
= 0; /* reset the comment style */
2911 if (boundary_stop
) goto done
;
2915 if (stopbefore
) goto stop
; /* this arg means stop at sexp start */
2917 /* curlevel++->last ran into compiler bug on Apollo */
2918 curlevel
->last
= prev_from
;
2919 if (++curlevel
== endlevel
)
2920 curlevel
--; /* error ("Nesting too deep for parser"); */
2921 curlevel
->prev
= -1;
2922 curlevel
->last
= -1;
2923 if (targetdepth
== depth
) goto done
;
2928 if (depth
< mindepth
)
2930 if (curlevel
!= levelstart
)
2932 curlevel
->prev
= curlevel
->last
;
2933 if (targetdepth
== depth
) goto done
;
2938 state
.comstr_start
= from
- 1;
2939 if (stopbefore
) goto stop
; /* this arg means stop at sexp start */
2940 curlevel
->last
= prev_from
;
2941 state
.instring
= (code
== Sstring
2942 ? (FETCH_CHAR (prev_from_byte
))
2944 if (boundary_stop
) goto done
;
2947 nofence
= state
.instring
!= ST_STRING_STYLE
;
2953 if (from
>= end
) goto done
;
2954 c
= FETCH_CHAR (from_byte
);
2955 /* Some compilers can't handle this inside the switch. */
2958 /* Check TEMP here so that if the char has
2959 a syntax-table property which says it is NOT
2960 a string character, it does not end the string. */
2961 if (nofence
&& c
== state
.instring
&& temp
== Sstring
)
2967 if (!nofence
) goto string_end
;
2972 startquotedinstring
:
2973 if (from
>= end
) goto endquoted
;
2979 state
.instring
= -1;
2980 curlevel
->prev
= curlevel
->last
;
2982 if (boundary_stop
) goto done
;
2986 /* FIXME: We should do something with it. */
2989 /* Ignore whitespace, punctuation, quote, endcomment. */
2995 stop
: /* Here if stopping before start of sexp. */
2996 from
= prev_from
; /* We have just fetched the char that starts it; */
2997 goto done
; /* but return the position before it. */
3002 state
.depth
= depth
;
3003 state
.mindepth
= mindepth
;
3004 state
.thislevelstart
= curlevel
->prev
;
3005 state
.prevlevelstart
3006 = (curlevel
== levelstart
) ? -1 : (curlevel
- 1)->last
;
3007 state
.location
= from
;
3008 state
.levelstarts
= Qnil
;
3009 while (--curlevel
>= levelstart
)
3010 state
.levelstarts
= Fcons (make_number (curlevel
->last
),
3017 DEFUN ("parse-partial-sexp", Fparse_partial_sexp
, Sparse_partial_sexp
, 2, 6, 0,
3018 doc
: /* Parse Lisp syntax starting at FROM until TO; return status of parse at TO.
3019 Parsing stops at TO or when certain criteria are met;
3020 point is set to where parsing stops.
3021 If fifth arg OLDSTATE is omitted or nil,
3022 parsing assumes that FROM is the beginning of a function.
3023 Value is a list of elements describing final state of parsing:
3025 1. character address of start of innermost containing list; nil if none.
3026 2. character address of start of last complete sexp terminated.
3027 3. non-nil if inside a string.
3028 (it is the character that will terminate the string,
3029 or t if the string should be terminated by a generic string delimiter.)
3030 4. nil if outside a comment, t if inside a non-nestable comment,
3031 else an integer (the current comment nesting).
3032 5. t if following a quote character.
3033 6. the minimum paren-depth encountered during this scan.
3034 7. t if in a comment of style b; symbol `syntax-table' if the comment
3035 should be terminated by a generic comment delimiter.
3036 8. character address of start of comment or string; nil if not in one.
3037 9. Intermediate data for continuation of parsing (subject to change).
3038 If third arg TARGETDEPTH is non-nil, parsing stops if the depth
3039 in parentheses becomes equal to TARGETDEPTH.
3040 Fourth arg STOPBEFORE non-nil means stop when come to
3041 any character that starts a sexp.
3042 Fifth arg OLDSTATE is a list like what this function returns.
3043 It is used to initialize the state of the parse. Elements number 1, 2, 6
3044 and 8 are ignored; you can leave off element 8 (the last) entirely.
3045 Sixth arg COMMENTSTOP non-nil means stop at the start of a comment.
3046 If it is symbol `syntax-table', stop after the start of a comment or a
3047 string, or after end of a comment or a string. */)
3048 (from
, to
, targetdepth
, stopbefore
, oldstate
, commentstop
)
3049 Lisp_Object from
, to
, targetdepth
, stopbefore
, oldstate
, commentstop
;
3051 struct lisp_parse_state state
;
3054 if (!NILP (targetdepth
))
3056 CHECK_NUMBER (targetdepth
);
3057 target
= XINT (targetdepth
);
3060 target
= -100000; /* We won't reach this depth */
3062 validate_region (&from
, &to
);
3063 scan_sexps_forward (&state
, XINT (from
), CHAR_TO_BYTE (XINT (from
)),
3065 target
, !NILP (stopbefore
), oldstate
,
3067 ? 0 : (EQ (commentstop
, Qsyntax_table
) ? -1 : 1)));
3069 SET_PT (state
.location
);
3071 return Fcons (make_number (state
.depth
),
3072 Fcons (state
.prevlevelstart
< 0 ? Qnil
: make_number (state
.prevlevelstart
),
3073 Fcons (state
.thislevelstart
< 0 ? Qnil
: make_number (state
.thislevelstart
),
3074 Fcons (state
.instring
>= 0
3075 ? (state
.instring
== ST_STRING_STYLE
3076 ? Qt
: make_number (state
.instring
)) : Qnil
,
3077 Fcons (state
.incomment
< 0 ? Qt
:
3078 (state
.incomment
== 0 ? Qnil
:
3079 make_number (state
.incomment
)),
3080 Fcons (state
.quoted
? Qt
: Qnil
,
3081 Fcons (make_number (state
.mindepth
),
3082 Fcons ((state
.comstyle
3083 ? (state
.comstyle
== ST_COMMENT_STYLE
3084 ? Qsyntax_table
: Qt
) :
3086 Fcons (((state
.incomment
3087 || (state
.instring
>= 0))
3088 ? make_number (state
.comstr_start
)
3090 Fcons (state
.levelstarts
, Qnil
))))))))));
3099 /* This has to be done here, before we call Fmake_char_table. */
3100 Qsyntax_table
= intern ("syntax-table");
3101 staticpro (&Qsyntax_table
);
3103 /* Intern this now in case it isn't already done.
3104 Setting this variable twice is harmless.
3105 But don't staticpro it here--that is done in alloc.c. */
3106 Qchar_table_extra_slots
= intern ("char-table-extra-slots");
3108 /* Create objects which can be shared among syntax tables. */
3109 Vsyntax_code_object
= Fmake_vector (make_number (Smax
), Qnil
);
3110 for (i
= 0; i
< XVECTOR (Vsyntax_code_object
)->size
; i
++)
3111 XVECTOR (Vsyntax_code_object
)->contents
[i
]
3112 = Fcons (make_number (i
), Qnil
);
3114 /* Now we are ready to set up this property, so we can
3115 create syntax tables. */
3116 Fput (Qsyntax_table
, Qchar_table_extra_slots
, make_number (0));
3118 temp
= XVECTOR (Vsyntax_code_object
)->contents
[(int) Swhitespace
];
3120 Vstandard_syntax_table
= Fmake_char_table (Qsyntax_table
, temp
);
3122 /* Control characters should not be whitespace. */
3123 temp
= XVECTOR (Vsyntax_code_object
)->contents
[(int) Spunct
];
3124 for (i
= 0; i
<= ' ' - 1; i
++)
3125 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table
, i
, temp
);
3126 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table
, 0177, temp
);
3128 /* Except that a few really are whitespace. */
3129 temp
= XVECTOR (Vsyntax_code_object
)->contents
[(int) Swhitespace
];
3130 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table
, ' ', temp
);
3131 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table
, '\t', temp
);
3132 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table
, '\n', temp
);
3133 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table
, 015, temp
);
3134 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table
, 014, temp
);
3136 temp
= XVECTOR (Vsyntax_code_object
)->contents
[(int) Sword
];
3137 for (i
= 'a'; i
<= 'z'; i
++)
3138 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table
, i
, temp
);
3139 for (i
= 'A'; i
<= 'Z'; i
++)
3140 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table
, i
, temp
);
3141 for (i
= '0'; i
<= '9'; i
++)
3142 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table
, i
, temp
);
3144 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table
, '$', temp
);
3145 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table
, '%', temp
);
3147 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table
, '(',
3148 Fcons (make_number (Sopen
), make_number (')')));
3149 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table
, ')',
3150 Fcons (make_number (Sclose
), make_number ('(')));
3151 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table
, '[',
3152 Fcons (make_number (Sopen
), make_number (']')));
3153 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table
, ']',
3154 Fcons (make_number (Sclose
), make_number ('[')));
3155 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table
, '{',
3156 Fcons (make_number (Sopen
), make_number ('}')));
3157 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table
, '}',
3158 Fcons (make_number (Sclose
), make_number ('{')));
3159 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table
, '"',
3160 Fcons (make_number ((int) Sstring
), Qnil
));
3161 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table
, '\\',
3162 Fcons (make_number ((int) Sescape
), Qnil
));
3164 temp
= XVECTOR (Vsyntax_code_object
)->contents
[(int) Ssymbol
];
3165 for (i
= 0; i
< 10; i
++)
3167 c
= "_-+*/&|<>="[i
];
3168 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table
, c
, temp
);
3171 temp
= XVECTOR (Vsyntax_code_object
)->contents
[(int) Spunct
];
3172 for (i
= 0; i
< 12; i
++)
3174 c
= ".,;:?!#@~^'`"[i
];
3175 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table
, c
, temp
);
3178 /* All multibyte characters have syntax `word' by default. */
3179 temp
= XVECTOR (Vsyntax_code_object
)->contents
[(int) Sword
];
3180 for (i
= CHAR_TABLE_SINGLE_BYTE_SLOTS
; i
< CHAR_TABLE_ORDINARY_SLOTS
; i
++)
3181 XCHAR_TABLE (Vstandard_syntax_table
)->contents
[i
] = temp
;
3187 Qsyntax_table_p
= intern ("syntax-table-p");
3188 staticpro (&Qsyntax_table_p
);
3190 staticpro (&Vsyntax_code_object
);
3192 staticpro (&gl_state
.object
);
3193 staticpro (&gl_state
.global_code
);
3194 staticpro (&gl_state
.current_syntax_table
);
3195 staticpro (&gl_state
.old_prop
);
3197 /* Defined in regex.c */
3198 staticpro (&re_match_object
);
3200 Qscan_error
= intern ("scan-error");
3201 staticpro (&Qscan_error
);
3202 Fput (Qscan_error
, Qerror_conditions
,
3203 Fcons (Qscan_error
, Fcons (Qerror
, Qnil
)));
3204 Fput (Qscan_error
, Qerror_message
,
3205 build_string ("Scan error"));
3207 DEFVAR_BOOL ("parse-sexp-ignore-comments", &parse_sexp_ignore_comments
,
3208 doc
: /* Non-nil means `forward-sexp', etc., should treat comments as whitespace. */);
3210 DEFVAR_BOOL ("parse-sexp-lookup-properties", &parse_sexp_lookup_properties
,
3211 doc
: /* Non-nil means `forward-sexp', etc., obey `syntax-table' property.
3212 Otherwise, that text property is simply ignored.
3213 See the info node `(elisp)Syntax Properties' for a description of the
3214 `syntax-table' property. */);
3216 words_include_escapes
= 0;
3217 DEFVAR_BOOL ("words-include-escapes", &words_include_escapes
,
3218 doc
: /* Non-nil means `forward-word', etc., should treat escape chars part of words. */);
3220 DEFVAR_BOOL ("multibyte-syntax-as-symbol", &multibyte_syntax_as_symbol
,
3221 doc
: /* Non-nil means `scan-sexps' treats all multibyte characters as symbol. */);
3222 multibyte_syntax_as_symbol
= 0;
3224 DEFVAR_BOOL ("open-paren-in-column-0-is-defun-start",
3225 &open_paren_in_column_0_is_defun_start
,
3226 doc
: /* *Non-nil means an open paren in column 0 denotes the start of a defun. */);
3227 open_paren_in_column_0_is_defun_start
= 1;
3229 defsubr (&Ssyntax_table_p
);
3230 defsubr (&Ssyntax_table
);
3231 defsubr (&Sstandard_syntax_table
);
3232 defsubr (&Scopy_syntax_table
);
3233 defsubr (&Sset_syntax_table
);
3234 defsubr (&Schar_syntax
);
3235 defsubr (&Smatching_paren
);
3236 defsubr (&Sstring_to_syntax
);
3237 defsubr (&Smodify_syntax_entry
);
3238 defsubr (&Sinternal_describe_syntax_value
);
3240 defsubr (&Sforward_word
);
3242 defsubr (&Sskip_chars_forward
);
3243 defsubr (&Sskip_chars_backward
);
3244 defsubr (&Sskip_syntax_forward
);
3245 defsubr (&Sskip_syntax_backward
);
3247 defsubr (&Sforward_comment
);
3248 defsubr (&Sscan_lists
);
3249 defsubr (&Sscan_sexps
);
3250 defsubr (&Sbackward_prefix_chars
);
3251 defsubr (&Sparse_partial_sexp
);
3254 /* arch-tag: 3e297b9f-088e-4b64-8f4c-fb0b3443e412
3255 (do not change this comment) */