[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Problems with syntax-ppss: Was [... Apply `comment-depth' text prope
From: |
Stefan Monnier |
Subject: |
Re: Problems with syntax-ppss: Was [... Apply `comment-depth' text properties when calling `back_comment'.] |
Date: |
Thu, 10 Mar 2016 12:34:13 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) |
> Would you please tell me where you've sent it.
In one of the messages of this long thread.
Here it is again.
> Then I can try to break it, thus assissting you in any
> necessary debugging.
Please do. I expected a fair bit of breakage but haven't seen any yet,
so it's still in a very "primitive/naive" shape.
Stefan
diff --git a/src/syntax.c b/src/syntax.c
index 249d0d5..9c5a2a8 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -570,9 +570,6 @@ dec_bytepos (ptrdiff_t bytepos)
/* Return a defun-start position before POS and not too far before.
It should be the last one before POS, or nearly the last.
- When open_paren_in_column_0_is_defun_start is nonzero,
- only the beginning of the buffer is treated as a defun-start.
-
We record the information about where the scan started
and what its result was, so that another call in the same area
can return the same value very quickly.
@@ -597,7 +594,27 @@ find_defun_start (ptrdiff_t pos, ptrdiff_t pos_byte)
&& MODIFF == find_start_modiff)
return find_start_value;
- if (!open_paren_in_column_0_is_defun_start)
+ if (!NILP (Vcomment_use_syntax_ppss))
+ {
+ EMACS_INT modiffs = CHARS_MODIFF;
+ Lisp_Object ppss = call1 (Qsyntax_ppss, make_number (pos));
+ if (modiffs != CHARS_MODIFF)
+ error ("syntax-ppss modified the buffer!");
+ TEMP_SET_PT_BOTH (opoint, opoint_byte);
+ Lisp_Object boc = Fnth (make_number (8), ppss);
+ if (NUMBERP (boc))
+ {
+ find_start_value = XINT (boc);
+ find_start_value_byte = CHAR_TO_BYTE (find_start_value);
+ }
+ else
+ {
+ find_start_value = pos;
+ find_start_value_byte = pos_byte;
+ }
+ goto found;
+ }
+ if (NILP (Vopen_paren_in_column_0_is_defun_start))
{
find_start_value = BEGV;
find_start_value_byte = BEGV_BYTE;
@@ -863,7 +880,7 @@ back_comment (ptrdiff_t from, ptrdiff_t from_byte,
ptrdiff_t stop,
case Sopen:
/* Assume a defun-start point is outside of strings. */
- if (open_paren_in_column_0_is_defun_start
+ if (EQ (Vopen_paren_in_column_0_is_defun_start, Qt)
&& (from == stop
|| (temp_byte = dec_bytepos (from_byte),
FETCH_CHAR (temp_byte) == '\n')))
@@ -3647,6 +3664,11 @@ void
syms_of_syntax (void)
{
DEFSYM (Qsyntax_table_p, "syntax-table-p");
+ DEFSYM (Qsyntax_ppss, "syntax-ppss");
+ DEFVAR_LISP ("comment-use-syntax-ppss",
+ Vcomment_use_syntax_ppss,
+ doc: /* Non-nil means `forward-comment' can use `syntax-ppss'
internally. */);
+ Vcomment_use_syntax_ppss = Qt;
staticpro (&Vsyntax_code_object);
@@ -3687,10 +3709,10 @@ See the info node `(elisp)Syntax Properties' for a
description of the
doc: /* Non-nil means `scan-sexps' treats all multibyte
characters as symbol. */);
multibyte_syntax_as_symbol = 0;
- DEFVAR_BOOL ("open-paren-in-column-0-is-defun-start",
- open_paren_in_column_0_is_defun_start,
+ DEFVAR_LISP ("open-paren-in-column-0-is-defun-start",
+ Vopen_paren_in_column_0_is_defun_start,
doc: /* Non-nil means an open paren in column 0 denotes the
start of a defun. */);
- open_paren_in_column_0_is_defun_start = 1;
+ Vopen_paren_in_column_0_is_defun_start = Qt;
DEFVAR_LISP ("find-word-boundary-function-table",
- Re: Problems with syntax-ppss: Was [... Apply `comment-depth' text properties when calling `back_comment'.], (continued)
- Re: Problems with syntax-ppss: Was [... Apply `comment-depth' text properties when calling `back_comment'.], Alan Mackenzie, 2016/03/09
- Re: Problems with syntax-ppss: Was [... Apply `comment-depth' text properties when calling `back_comment'.], Stefan Monnier, 2016/03/09
- Re: Problems with syntax-ppss: Was [... Apply `comment-depth' text properties when calling `back_comment'.], Clément Pit--Claudel, 2016/03/09
- Re: Problems with syntax-ppss: Was [... Apply `comment-depth' text properties when calling `back_comment'.], Alan Mackenzie, 2016/03/09
- Re: Problems with syntax-ppss: Was [... Apply `comment-depth' text properties when calling `back_comment'.], Stefan Monnier, 2016/03/09
- Re: Problems with syntax-ppss: Was [... Apply `comment-depth' text properties when calling `back_comment'.], Alan Mackenzie, 2016/03/10
- Re: Problems with syntax-ppss: Was [... Apply `comment-depth' text properties when calling `back_comment'.], Stefan Monnier, 2016/03/10
- Re: Problems with syntax-ppss: Was [... Apply `comment-depth' text properties when calling `back_comment'.], Alan Mackenzie, 2016/03/10
- Re: Problems with syntax-ppss: Was [... Apply `comment-depth' text properties when calling `back_comment'.], Stefan Monnier, 2016/03/10
- Re: Problems with syntax-ppss: Was [... Apply `comment-depth' text properties when calling `back_comment'.], Alan Mackenzie, 2016/03/10
- Re: Problems with syntax-ppss: Was [... Apply `comment-depth' text properties when calling `back_comment'.],
Stefan Monnier <=
- Re: Problems with syntax-ppss: Was [... Apply `comment-depth' text properties when calling `back_comment'.], Alan Mackenzie, 2016/03/10
- Re: Problems with syntax-ppss: Was [... Apply `comment-depth' text properties when calling `back_comment'.], Stefan Monnier, 2016/03/10
- Re: Problems with syntax-ppss: Was [... Apply `comment-depth' text properties when calling `back_comment'.], Stefan Monnier, 2016/03/11
- Re: Problems with syntax-ppss: Was [... Apply `comment-depth' text properties when calling `back_comment'.], Alan Mackenzie, 2016/03/11
- Re: Problems with syntax-ppss: Was [... Apply `comment-depth' text properties when calling `back_comment'.], Stefan Monnier, 2016/03/11
- Re: Problems with syntax-ppss: Was [... Apply `comment-depth' text properties when calling `back_comment'.], Alan Mackenzie, 2016/03/11
- Re: Problems with syntax-ppss: Was [... Apply `comment-depth' text properties when calling `back_comment'.], Clément Pit--Claudel, 2016/03/11
- Re: Problems with syntax-ppss: Was [... Apply `comment-depth' text properties when calling `back_comment'.], Stefan Monnier, 2016/03/11
- Re: Problems with syntax-ppss: Was [... Apply `comment-depth' text properties when calling `back_comment'.], John Wiegley, 2016/03/10
- Re: Problems with syntax-ppss: Was [... Apply `comment-depth' text properties when calling `back_comment'.], Clément Pit--Claudel, 2016/03/10