all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Noam Postavsky <npostavs@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 30891@debbugs.gnu.org
Subject: bug#30891: 26.0.91; indent of malformed lisp
Date: Wed, 24 Oct 2018 19:39:44 -0400	[thread overview]
Message-ID: <8736sunccf.fsf@gmail.com> (raw)
In-Reply-To: <83d0zxly66.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 21 Mar 2018 08:50:41 +0200")

[-- Attachment #1: Type: text/plain, Size: 700 bytes --]

Eli Zaretskii <eliz@gnu.org> 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)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 1099 bytes --]

From 823fadf0a29a5cb01559f40faac2a88cd0defeb8 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@gmail.com>
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


  parent reply	other threads:[~2018-10-24 23:39 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-21  1:19 bug#30891: 26.0.91; indent of malformed lisp Noam Postavsky
2018-03-21  6:50 ` Eli Zaretskii
2018-03-21 11:50   ` Noam Postavsky
2018-10-24 23:39   ` Noam Postavsky [this message]
2018-10-25 14:53     ` Eli Zaretskii
2018-10-25 22:04       ` Noam Postavsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8736sunccf.fsf@gmail.com \
    --to=npostavs@gmail.com \
    --cc=30891@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.