Lisp_Object Qsyntax_table_p;
+static void scan_sexps_forward ();
+static int char_quoted ();
+
int words_include_escapes;
/* This is the internal form of the parse state used in parse-partial-sexp. */
table = check_syntax_table (table);
current_buffer->syntax_table = table;
/* Indicate that this buffer now has a specified syntax table. */
- current_buffer->local_var_flags |= buffer_local_flags.syntax_table;
+ current_buffer->local_var_flags
+ |= XFASTINT (buffer_local_flags.syntax_table);
return table;
}
\f
for make-docfile to see. We cannot put this in the real DEFUN
due to limits in the Unix cpp.
-DEFUN ("modify-syntax-entry", foo, bar, 0, 0, 0,
+DEFUN ("modify-syntax-entry", foo, bar, 2, 3, 0,
"Set syntax for character CHAR according to string S.\n\
The syntax is changed only for table TABLE, which defaults to\n\
the current buffer's syntax table.\n\
p means C is a prefix character for `backward-prefix-chars';\n\
such characters are treated as whitespace when they occur\n\
between expressions.")
-
+ (char, s, table)
*/
DEFUN ("modify-syntax-entry", Fmodify_syntax_entry, Smodify_syntax_entry, 2, 3,
\f
/* Dump syntax table to buffer in human-readable format */
+static void
describe_syntax (value)
Lisp_Object value;
{
insert_string ("\n");
}
-Lisp_Object
+static Lisp_Object
describe_syntax_1 (vector)
Lisp_Object vector;
{
\f
DEFUN ("forward-comment", Fforward_comment, Sforward_comment, 1, 1, 0,
"Move forward across up to N comments. If N is negative, move backward.\n\
-Set point to the far end of the last comment found.\n\
Stop scanning if we find something other than a comment or whitespace.\n\
+Set point to where scanning stops.\n\
If N comments are found as expected, with nothing except whitespace\n\
between them, return t; otherwise return nil.")
(count)
QUIT;
from = PT;
- found = from;
while (count1 > 0)
{
- found = from;
stop = ZV;
while (from < stop)
{
if (from == stop)
{
immediate_quit = 0;
- SET_PT (found);
+ SET_PT (from);
return Qnil;
}
c = FETCH_CHAR (from);
/* We have skipped one comment. */
break;
}
- else if (code != Swhitespace)
+ else if (code != Swhitespace && code != Sendcomment)
{
immediate_quit = 0;
- SET_PT (found);
+ SET_PT (from - 1);
return Qnil;
}
}
while (count1 < 0)
{
- found = from;
-
stop = BEGV;
while (from > stop)
{
if (code == Sendcomment && !quoted)
{
+#if 0
if (code != SYNTAX (c))
/* For a two-char comment ender, we can assume
it does end a comment. So scan back in a simple way. */
if (from == stop)
{
immediate_quit = 0;
- SET_PT (found);
+ SET_PT (from);
return Qnil;
}
from--;
}
break;
}
+#endif /* 0 */
/* Look back, counting the parity of string-quotes,
and recording the comment-starters seen.
}
/* If we find another earlier comment-ender,
- any comment-starts earier than that don't count
+ any comment-starts earlier than that don't count
(because they go with the earlier comment-ender). */
if (code == Sendcomment
&& SYNTAX_COMMENT_STYLE (FETCH_CHAR (from)) == comstyle)
last passed a comment starter. */
struct lisp_parse_state state;
scan_sexps_forward (&state, find_defun_start (comment_end),
- comment_end - 1, -10000, 0, Qnil);
+ comment_end - 1, -10000, 0, Qnil, 0);
if (state.incomment)
from = state.comstart;
else
}
}
}
- else if (code != Swhitespace || quoted)
+ else if ((code != Swhitespace && code != Scomment) || quoted)
{
immediate_quit = 0;
- SET_PT (found);
+ SET_PT (from + 1);
return Qnil;
}
}
case Sendcomment:
if (!parse_sexp_ignore_comments)
break;
+#if 0
if (code != SYNTAX (c))
/* For a two-char comment ender, we can assume
it does end a comment. So scan back in a simple way. */
}
break;
}
+#endif /* 0 */
/* Look back, counting the parity of string-quotes,
and recording the comment-starters seen.
}
/* If we find another earlier comment-ender,
- any comment-starts earier than that don't count
+ any comment-starts earlier than that don't count
(because they go with the earlier comment-ender). */
if (code == Sendcomment
&& SYNTAX_COMMENT_STYLE (FETCH_CHAR (from)) == comstyle)
last passed a comment starter. */
struct lisp_parse_state state;
scan_sexps_forward (&state, find_defun_start (comment_end),
- comment_end - 1, -10000, 0, Qnil);
+ comment_end - 1, -10000, 0, Qnil, 0);
if (state.incomment)
from = state.comstart;
else
/* NOTREACHED */
}
+static int
char_quoted (pos)
register int pos;
{
/* Parse forward from FROM to END,
assuming that FROM has state OLDSTATE (nil means FROM is start of function),
and return a description of the state of the parse at END.
- If STOPBEFORE is nonzero, stop at the start of an atom. */
+ If STOPBEFORE is nonzero, stop at the start of an atom.
+ If COMMENTSTOP is nonzero, stop at the start of a comment. */
-scan_sexps_forward (stateptr, from, end, targetdepth, stopbefore, oldstate)
+static void
+scan_sexps_forward (stateptr, from, end, targetdepth,
+ stopbefore, oldstate, commentstop)
struct lisp_parse_state *stateptr;
register int from;
int end, targetdepth, stopbefore;
Lisp_Object oldstate;
+ int commentstop;
{
struct lisp_parse_state state;
{
code = SYNTAX (FETCH_CHAR (from));
from++;
- if (from < end && SYNTAX_COMSTART_FIRST (FETCH_CHAR (from - 1))
- && SYNTAX_COMSTART_SECOND (FETCH_CHAR (from)))
+ if (code == Scomment)
+ state.comstart = from-1;
+
+ else if (from < end && SYNTAX_COMSTART_FIRST (FETCH_CHAR (from - 1))
+ && SYNTAX_COMSTART_SECOND (FETCH_CHAR (from)))
{
/* Record the comment style we have entered so that only
the comment-end sequence of the same style actually
terminates the comment section. */
code = Scomment;
state.comstyle = SYNTAX_COMMENT_STYLE (FETCH_CHAR (from));
+ state.comstart = from-1;
from++;
}
case Scomment:
state.incomment = 1;
- state.comstart = from;
startincomment:
+ if (commentstop)
+ goto done;
while (1)
{
if (from == end) goto done;
for make-docfile to see. We cannot put this in the real DEFUN
due to limits in the Unix cpp.
-DEFUN ("parse-partial-sexp", Ffoo, Sfoo, 2, 5, 0,
+DEFUN ("parse-partial-sexp", Ffoo, Sfoo, 2, 6, 0,
"Parse Lisp syntax starting at FROM until TO; return status of parse at TO.\n\
Parsing stops at TO or when certain criteria are met;\n\
point is set to where parsing stops.\n\
any character that starts a sexp.\n\
Fifth arg STATE is a seven-list like what this function returns.\n\
It is used to initialize the state of the parse. Its second and third
-elements are ignored.")
- (from, to, targetdepth, stopbefore, state)
+elements are ignored.
+Sixth args COMMENTSTOP non-nil means stop at the start of a comment.")
+ (from, to, targetdepth, stopbefore, state, commentstop)
*/
-DEFUN ("parse-partial-sexp", Fparse_partial_sexp, Sparse_partial_sexp, 2, 5, 0,
+DEFUN ("parse-partial-sexp", Fparse_partial_sexp, Sparse_partial_sexp, 2, 6, 0,
0 /* See immediately above */)
- (from, to, targetdepth, stopbefore, oldstate)
- Lisp_Object from, to, targetdepth, stopbefore, oldstate;
+ (from, to, targetdepth, stopbefore, oldstate, commentstop)
+ Lisp_Object from, to, targetdepth, stopbefore, oldstate, commentstop;
{
struct lisp_parse_state state;
int target;
validate_region (&from, &to);
scan_sexps_forward (&state, XINT (from), XINT (to),
- target, !NILP (stopbefore), oldstate);
+ target, !NILP (stopbefore), oldstate,
+ !NILP (commentstop));
SET_PT (state.location);