emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[debbugs-tracker] bug#16247: closed (syntax-ppss returns incorrect state


From: GNU bug Tracking System
Subject: [debbugs-tracker] bug#16247: closed (syntax-ppss returns incorrect state)
Date: Fri, 03 Jan 2014 22:41:01 +0000

Your message dated Fri, 03 Jan 2014 17:40:05 -0500
with message-id <address@hidden>
and subject line Re: bug#16247: syntax-ppss returns incorrect state
has caused the debbugs.gnu.org bug report #16247,
regarding syntax-ppss returns incorrect state
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden)


-- 
16247: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16247
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: syntax-ppss returns incorrect state Date: Tue, 24 Dec 2013 18:00:58 -0500
Let /tmp/get-syntax.el :

  (defun get-syntax ()
    (interactive)
    (message "%s" (syntax-ppss (point))))

Run Emacs from trunk:

  ./src/emacs -Q lisp/progmodes/cc-engine.el --load /tmp/get-syntax.el

Insert this in Emacs:

diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index 973ed91..882c4f5 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -134,7 +134,7 @@
 ;;   cc-awk.el.
 
 ;;; Code:
-
+(
 (eval-when-compile
   (let ((load-path
         (if (and (boundp 'byte-compile-dest-file)

Go a couple lines down, | indicates point:

(
(eval-when-compile
|  (let ((load-path
        (if (and (boundp 'byte-compile-dest-file)

Execute M-x get-syntax and see:

  (2 5705 5706 nil nil nil 0 nil nil (5703 5705))

Looks ok. Move down in buffer, | indicates point:

;; Included in the mode line to indicate the active submodes.
;; (defvar c-submode-indicators nil)
;; (make-variable-buffer-local 'c-submode-indicators)
|
(defun c-calculate-state (arg prevstate)
  ;; Calculate the new state of PREVSTATE, t or nil, based on arg. If
  ;; arg is nil or zero, toggle the state. If arg is negative, turn
  ;; the state off, and if arg is positive, turn the state on
  (if (or (not arg)
      (zerop (setq arg (prefix-numeric-value arg))))
      (not prevstate)
    (> arg 0)))

M-x get-syntax:

  (0 nil 7000 nil nil nil 0 nil nil nil)

Expected the depth to be 1, not 0. For good measure, go back to the
same position of the first get-syntax call and do it again:

  (1 5705 5706 nil nil nil 0 nil nil (5705))

Why did the same buffer position change from depth 2 to depth 1, even
though the buffer didn't change between the get-syntax calls?



--- End Message ---
--- Begin Message --- Subject: Re: bug#16247: syntax-ppss returns incorrect state Date: Fri, 03 Jan 2014 17:40:05 -0500 User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)
> (
> (eval-when-compile
> |  (let ((load-path
>         (if (and (boundp 'byte-compile-dest-file)
[...]
> Why did the same buffer position change from depth 2 to depth 1, even
> though the buffer didn't change between the get-syntax calls?

That's because of syntax-begin-function, which in Lisp buffers assumes
than an open-paren in column 0 is necessarily outside of anything
(parens, comments, strings, ...).  And then syntax-ppss sometimes uses
this assumption and sometimes not, depending on the distance of the
previous call to syntax-ppss and the nearest beginning of defun (aka
open-paren in column 0).

I just installed a change to leave syntax-begin-function nil in
Lisp buffers.  The performance impact should be negligible.


        Stefan


--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]