GNU bug report logs -
#21343
24.5; parse-partial-sexp mistakes string for a comment
Previous Next
Reported by: Oleh Krehel <ohwoeowho <at> gmail.com>
Date: Tue, 25 Aug 2015 13:11:01 UTC
Severity: normal
Tags: confirmed, fixed, patch
Found in version 24.5
Fixed in version 26.1
Done: npostavs <at> users.sourceforge.net
Bug is archived. No further changes may be made.
Full log
Message #19 received at control <at> debbugs.gnu.org (full text, mbox):
tags 21343 confirmed
quit
Oleh Krehel <ohwoeowho <at> gmail.com> writes:
>> Am 25.08.2015 um 15:11 schrieb Oleh Krehel:
>>> To reproduce, paste this code into *scratch*, "|" is the point:
>>>
>>> ("|foo"
>>> ";; (bar)")
>>>
>>> M-x indent-sexp will result in " ;" being inserted after the sexp.
>
> `parse-partial-sexp' will detect comment on line 2 only when called in a
> sequence that `indent-sexp' calls it, i.e. with the previous pps data
> passed to the second pps call.
In fact, the problem already occurs on the 1st line: calling
`parse-partial-sexp' from within a string gives wrong results, since it
doesn't look at the starting quote. You can reproduce the bug with just
"|;"
A solution could be to use syntax-ppss to go to start of string before
parsing (though I wonder if syntax-ppss should be used more for the
parsing itself in that case, it seems like there's a lot of work going
that probably duplicates what's already being done):
diff --git c/lisp/emacs-lisp/lisp-mode.el i/lisp/emacs-lisp/lisp-mode.el
index a277d7a..8b5efa3 100644
--- c/lisp/emacs-lisp/lisp-mode.el
+++ i/lisp/emacs-lisp/lisp-mode.el
@@ -1070,6 +1070,10 @@ indent-sexp
;; Get error now if we don't have a complete sexp after point.
(save-excursion (forward-sexp 1)))
(save-excursion
+ (let ((syn-start (nth 8 (syntax-ppss))))
+ (when syn-start
+ (unless endpos (setq starting-point syn-start))
+ (goto-char syn-start)))
(setq outer-loop-done nil)
(while (if endpos (< (point) endpos)
(not outer-loop-done))
This bug report was last modified 8 years and 78 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.