]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix indent-sexp when called from inside a string (Bug#21343)
authorNoam Postavsky <npostavs@gmail.com>
Sun, 5 Mar 2017 05:53:58 +0000 (00:53 -0500)
committerNoam Postavsky <npostavs@gmail.com>
Mon, 13 Mar 2017 00:08:32 +0000 (20:08 -0400)
* lisp/emacs-lisp/lisp-mode.el (indent-sexp): Get initial syntax parse
state from `syntax-ppss'.

lisp/emacs-lisp/lisp-mode.el

index 5faa6a50ae53e9acfe9a0bbd6448df499092145a..eb07c18b03db70f26ebbd97ca4d79d6d70512f6c 100644 (file)
@@ -1075,10 +1075,14 @@ ENDPOS is encountered."
          ;; 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.