[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#37045: lisp-indent-region hangs in lisp-indent-calc-next when indent
From: |
Noam Postavsky |
Subject: |
bug#37045: lisp-indent-region hangs in lisp-indent-calc-next when indenting the three characters "|#\n" |
Date: |
Fri, 16 Aug 2019 07:47:20 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.2.90 (gnu/linux) |
found 37045 26.1
tags 37045 + patch
quit
eschulte@grammatech.com writes:
> Indent-region sometimes hangs when indenting a lisp file. A minimal
> example is the file just containing the characters "|#" followed by a
> newline.
It's actually any unfinished string literal (in Common Lisp, |...| is
treated by Emacs as a string literal, though technically it's an escaped
symbol).
> This hang is due to an infinite loop in the while loop in the
> `lisp-indent-calc-next' function. The following version of this
> function fixes this problem, but is certainly not the appropriate
> long-term fix.
I think the right fix is just to check for end of buffer:
@@ -810,7 +810,7 @@ lisp-indent-calc-next
(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))
Full patch with test (and some other comment updates) attached below.
Is this okay for emacs-26? The bug is a regression from Emacs 25.
0001-Fix-lisp-indent-infloop-on-unfinished-strings-Bug-37.patch
Description: patch