GNU bug report logs - #43329
28.0.50; Incorrect indentation for variables starting with `def' in let form

Previous Next

Package: emacs;

Reported by: Philipp Stephani <p.stephani2 <at> gmail.com>

Date: Fri, 11 Sep 2020 10:11:02 UTC

Severity: minor

Tags: confirmed, moreinfo

Merged with 33301

Found in versions 24.3, 27.0.50, 28.0.50

Fixed in version 29.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Noam Postavsky <npostavs <at> gmail.com>
Cc: Philipp Stephani <p.stephani2 <at> gmail.com>,
 Stefan Monnier <monnier <at> IRO.UMontreal.CA>, 43329 <at> debbugs.gnu.org
Subject: Re: bug#43329: 28.0.50; Incorrect indentation for variables
 starting with `def' in let form
Date: Sat, 12 Sep 2020 13:57:05 +0200
Noam Postavsky <npostavs <at> gmail.com> writes:

> lisp-indent-function (see https://debbugs.gnu.org/33301#15)

Ah, yes, there it is:

(defun lisp-indent-function (indent-point state)
[...]
	(cond ((or (eq method 'defun)
		   (and (null method)
			(> (length function) 3)
			(string-match "\\`def" function)))
	       (lisp-indent-defform state indent-point))

I think the general idea here is to indent everything that starts with
"(def" as a macro, but in

(let ((defa
       foo)))

that's obviously not the case here.

Would something as simple as the following (which fixes this use case)
be the correct fix?  It only indents these forms as macros if they are
top-level...

("make check" signals no errors with the change in place.)

diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el
index 352210f859..a324846336 100644
--- a/lisp/emacs-lisp/lisp-mode.el
+++ b/lisp/emacs-lisp/lisp-mode.el
@@ -1141,6 +1141,7 @@ lisp-indent-function
 	(cond ((or (eq method 'defun)
 		   (and (null method)
 			(> (length function) 3)
+                        (= (syntax-ppss-depth state) 1)
 			(string-match "\\`def" function)))
 	       (lisp-indent-defform state indent-point))
 	      ((integerp method)


-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




This bug report was last modified 3 years and 215 days ago.

Previous Next


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