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 #24 received at control <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
tags 21343 patch
quit
npostavs <at> users.sourceforge.net writes:
> 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):
Actually, it turns out using syntax-ppss in the loop is slower, at least
in the case of calling `pp' on a big list (which is a pessimal case for
a cache based parser).
Here is a patch (the first one just simplifies the code).
[v1-0001-lisp-emacs-lisp-lisp-mode.el-indent-sexp-Simplify.patch (text/plain, attachment)]
[v1-0002-Fix-indent-sexp-when-called-from-inside-a-string-.patch (text/x-diff, inline)]
From b318e8c0bdd0f08b49f7f8c635bf886d967bc742 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs <at> gmail.com>
Date: Sun, 5 Mar 2017 00:53:58 -0500
Subject: [PATCH v1 2/2] Fix indent-sexp when called from inside a string
(Bug#21343)
* lisp/emacs-lisp/lisp-mode.el (indent-sexp): Get initial syntax parse
state from `syntax-ppss'.
---
lisp/emacs-lisp/lisp-mode.el | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el
index de0e66039a..ce61c69f3c 100644
--- a/lisp/emacs-lisp/lisp-mode.el
+++ b/lisp/emacs-lisp/lisp-mode.el
@@ -1062,10 +1062,14 @@ indent-sexp
;; since every line we indent is more deeply nested than point is.
(starting-point (save-excursion (if endpos (beginning-of-defun))
(point)))
- (state nil)
- (init-depth 0)
- (next-depth 0)
- (last-depth 0)
+ ;; Use `syntax-ppss' to get initial state so we don't get
+ ;; confused by starting inside a string. We don't use
+ ;; `syntax-ppss' in the loop, because this is measurably
+ ;; slower when we're called on a long list.
+ (state (syntax-ppss))
+ (init-depth (car state))
+ (next-depth init-depth)
+ (last-depth init-depth)
(last-syntax-point (point)))
(unless endpos
;; Get error now if we don't have a complete sexp after point.
--
2.11.1
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.