summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
authorNoam Postavsky <npostavs@gmail.com>2019-08-16 07:26:40 -0400
committerNoam Postavsky <npostavs@gmail.com>2019-08-17 09:42:34 -0400
commitbcd0115e4db49791a77566b80fabc4384d9ebf57 (patch)
treeeb5024d4e633eb5e21c83f3ca1e50a9dd46ac6f9 /lisp/emacs-lisp
parent5f992d1990d9f351cf907dcf2066f573e0fe9407 (diff)
downloademacs-bcd0115e4db49791a77566b80fabc4384d9ebf57.tar.gz
emacs-bcd0115e4db49791a77566b80fabc4384d9ebf57.tar.bz2
emacs-bcd0115e4db49791a77566b80fabc4384d9ebf57.zip
Fix lisp indent infloop on unfinished strings (Bug#37045)
* lisp/emacs-lisp/lisp-mode.el (lisp-indent-calc-next): Stop trying to skip over strings if we've hit the end of buffer. * test/lisp/emacs-lisp/lisp-mode-tests.el (lisp-indent-unfinished-string): New test.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/lisp-mode.el15
1 files changed, 10 insertions, 5 deletions
diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el
index 74bf0c87c53..bde0a4ea6d9 100644
--- a/lisp/emacs-lisp/lisp-mode.el
+++ b/lisp/emacs-lisp/lisp-mode.el
@@ -810,7 +810,7 @@ by more than one line to cross a string literal."
(setq last-sexp (nth 2 ppss)))
(setq depth (car ppss))
;; Skip over newlines within strings.
- (nth 3 ppss))
+ (and (not (eobp)) (nth 3 ppss)))
(let ((string-start (nth 8 ppss)))
(setq ppss (parse-partial-sexp (point) (point-max)
nil nil ppss 'syntax-table))
@@ -826,17 +826,22 @@ by more than one line to cross a string literal."
indent-stack)))))
(prog1
(let (indent)
- (cond ((= (forward-line 1) 1) nil)
- ;; Negative depth, probably some kind of syntax error.
+ (cond ((= (forward-line 1) 1)
+ ;; Can't move to the next line, apparently end of buffer.
+ nil)
((null indent-stack)
- ;; Reset state.
+ ;; Negative depth, probably some kind of syntax
+ ;; error. Reset the state.
(setq ppss (parse-partial-sexp (point) (point))))
((car indent-stack))
((integerp (setq indent (calculate-lisp-indent ppss)))
(setf (car indent-stack) indent))
((consp indent) ; (COLUMN CONTAINING-SEXP-START)
(car indent))
- ;; This only happens if we're in a string.
+ ;; This only happens if we're in a string, but the
+ ;; loop should always skip over strings (unless we hit
+ ;; end of buffer, which is taken care of by the first
+ ;; clause).
(t (error "This shouldn't happen"))))
(setf (lisp-indent-state-stack state) indent-stack)
(setf (lisp-indent-state-ppss-point state) ppss-point)