GNU bug report logs - #22983
syntax-ppss returns wrong result.

Previous Next

Package: emacs;

Reported by: Alan Mackenzie <acm <at> muc.de>

Date: Fri, 11 Mar 2016 15:13:02 UTC

Severity: normal

Done: Alan Mackenzie <acm <at> muc.de>

Bug is archived. No further changes may be made.

Full log


Message #56 received at 22983 <at> debbugs.gnu.org (full text, mbox):

From: Vitalie Spinu <spinuvit <at> gmail.com>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: Alan Mackenzie <acm <at> muc.de>, 22983 <at> debbugs.gnu.org
Subject: Re: bug#22983: syntax-ppss returns wrong result.
Date: Sun, 20 Mar 2016 00:00:45 +0100
Thanks for this. This is a step in right direction IMHO.

One side note. `parsep-ppss` has a condition-case for args-out-of-range which
could be easily optimized out. You already know that you are calling
parse-partial-sexp with out of range arguments if narrowing is in place. The
current error check obfuscates the logic and makes debugging harder. Would it be
possible for you to have a look once you are on it? Not a big deal though.

Thanks,

  Vitalie

>> On Fri, Mar 18 2016 02:49, Dmitry Gutov wrote:

> On 03/11/2016 05:15 PM, Alan Mackenzie wrote:

> This patch should make ppss-0 and ppss-1 match:

> diff --git a/lisp/emacs-lisp/syntax.el b/lisp/emacs-lisp/syntax.el
> index e20a210..c1b9d84 100644
> --- a/lisp/emacs-lisp/syntax.el
> +++ b/lisp/emacs-lisp/syntax.el
> @@ -371,6 +371,11 @@ syntax-ppss-max-span
>  We try to make sure that cache entries are at least this far apart
>  from each other, to avoid keeping too much useless info.")

> +(defvar syntax-ppss-dont-widen nil
> +  "If non-nil, `syntax-ppss' will work on the non-widened buffer.
> +The code that uses this should create local bindings for
> +`syntax-ppss-cache' and `syntax-ppss-last' too.")
> +
>  (defvar syntax-begin-function nil
>    "Function to move back outside of any comment/string/paren.
>  This function should move the cursor back to some syntactically safe
> @@ -423,12 +428,21 @@ syntax-ppss
>  in the returned list (counting from 0) cannot be relied upon.
>  Point is at POS when this function returns.

> +IF `syntax-ppss-dont-widen' is nil, the buffer is temporarily
> +widened.
> +
>  It is necessary to call `syntax-ppss-flush-cache' explicitly if
>  this function is called while `before-change-functions' is
>  temporarily let-bound, or if the buffer is modified without
>  running the hook."
>    ;; Default values.
>    (unless pos (setq pos (point)))
> +  (save-restriction
> +    (unless syntax-ppss-dont-widen
> +      (widen))
> +    (syntax-pps--at pos)))
> +
> +(defun syntax-ppss--at (pos)
>    (syntax-propertize pos)
>    ;;
>    (let ((old-ppss (cdr syntax-ppss-last))




This bug report was last modified 7 years and 229 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.