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

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

bug#43329: 28.0.50; Incorrect indentation for variables starting with `d


From: Lars Ingebrigtsen
Subject: bug#43329: 28.0.50; Incorrect indentation for variables starting with `def' in let form
Date: Sat, 12 Sep 2020 13:57:05 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Noam Postavsky <npostavs@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





reply via email to

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