GNU bug report logs - #37045
lisp-indent-region hangs in lisp-indent-calc-next when indenting the three characters "|#\n"

Previous Next

Package: emacs;

Reported by: eschulte <at> grammatech.com

Date: Fri, 16 Aug 2019 04:50:03 UTC

Severity: normal

Tags: fixed, patch

Found in version 26.1

Fixed in version 26.3

Done: Noam Postavsky <npostavs <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


Message #12 received at control <at> debbugs.gnu.org (full text, mbox):

From: Noam Postavsky <npostavs <at> gmail.com>
To: eschulte <at> grammatech.com
Cc: 37045 <at> debbugs.gnu.org
Subject: Re: 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
[Message part 1 (text/plain, inline)]
found 37045 26.1
tags 37045 + patch
quit

eschulte <at> 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 (text/plain, attachment)]

This bug report was last modified 5 years and 273 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.