* bug#16247: syntax-ppss returns incorrect state
@ 2013-12-24 23:00 Barry OReilly
2014-01-03 22:40 ` Stefan Monnier
0 siblings, 1 reply; 2+ messages in thread
From: Barry OReilly @ 2013-12-24 23:00 UTC (permalink / raw)
To: 16247
[-- Attachment #1: Type: text/plain, Size: 1688 bytes --]
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?
[-- Attachment #2: Type: text/html, Size: 1952 bytes --]
^ permalink raw reply related [flat|nested] 2+ messages in thread
* bug#16247: syntax-ppss returns incorrect state
2013-12-24 23:00 bug#16247: syntax-ppss returns incorrect state Barry OReilly
@ 2014-01-03 22:40 ` Stefan Monnier
0 siblings, 0 replies; 2+ messages in thread
From: Stefan Monnier @ 2014-01-03 22:40 UTC (permalink / raw)
To: Barry OReilly; +Cc: 16247-done
> (
> (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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-01-03 22:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-24 23:00 bug#16247: syntax-ppss returns incorrect state Barry OReilly
2014-01-03 22:40 ` Stefan Monnier
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).