bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#30891: 26.0.91; indent of malformed lisp


From: Noam Postavsky
Subject: bug#30891: 26.0.91; indent of malformed lisp
Date: Wed, 24 Oct 2018 19:39:44 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)

Eli Zaretskii <address@hidden> writes:

>> For example, indent-region in a buffer containing:
>> 
>> )
>> (+ 2
>>    3)
>> 
>> gives
>> 
>> Debugger entered--Lisp error: (wrong-type-argument consp nil)

> I'd rather go back to the old code, and let the new Lisp indent
> functions mature on master.  Alternatively, we could leave this
> problem alone and fix it later.  But making all these changes at the
> 95th minute before Emacs 26 is released makes very little sense to me.

Okay to push just the error avoidance part to emacs-26 now?  (I'm not
really sure how useful the
lisp-ppss-open-paren-in-column-0-is-defun-start thing would be anyway,
and we haven't seen any other complaints about this)

>From 823fadf0a29a5cb01559f40faac2a88cd0defeb8 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <address@hidden>
Date: Sat, 17 Mar 2018 21:14:11 -0400
Subject: [PATCH] Don't error when indenting malformed Lisp (Bug#30891)

* lisp/emacs-lisp/lisp-mode.el (lisp-indent-calc-next): If we run out
of indent stack, reset the parse state.
---
 lisp/emacs-lisp/lisp-mode.el | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el
index 205c810b97..13ad06e4ae 100644
--- a/lisp/emacs-lisp/lisp-mode.el
+++ b/lisp/emacs-lisp/lisp-mode.el
@@ -827,6 +827,10 @@ lisp-indent-calc-next
     (prog1
         (let (indent)
           (cond ((= (forward-line 1) 1) nil)
+                ;; Negative depth, probably some kind of syntax error.
+                ((null indent-stack)
+                 ;; Reset state.
+                 (setq ppss (parse-partial-sexp (point) (point))))
                 ((car indent-stack))
                 ((integerp (setq indent (calculate-lisp-indent ppss)))
                  (setf (car indent-stack) indent))
-- 
2.11.0


reply via email to

[Prev in Thread] Current Thread [Next in Thread]