summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
authorNoam Postavsky <npostavs@gmail.com>2017-03-05 00:53:58 -0500
committerNoam Postavsky <npostavs@gmail.com>2017-03-12 20:08:32 -0400
commitcf670b49a7704d63575863f832426d32bf6a8c3c (patch)
tree8c698967d3e93313d7dc830fed3d3880b566c27a /lisp/emacs-lisp
parent3ee3995d105ff02f0fac540757431d36cb45c6c7 (diff)
downloademacs-cf670b49a7704d63575863f832426d32bf6a8c3c.tar.gz
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'.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/lisp-mode.el12
1 files changed, 8 insertions, 4 deletions
diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el
index 5faa6a50ae5..eb07c18b03d 100644
--- a/lisp/emacs-lisp/lisp-mode.el
+++ b/lisp/emacs-lisp/lisp-mode.el
@@ -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.