GNU bug report logs - #33301
27.0.50; broken elisp indentation for non-definition symbols starting with "def.."

Previous Next

Package: emacs;

Reported by: João Távora <joaotavora <at> gmail.com>

Date: Wed, 7 Nov 2018 13:22:02 UTC

Severity: minor

Tags: confirmed, moreinfo

Merged with 43329

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


View this message in rfc822 format

From: João Távora <joaotavora <at> gmail.com>
To: Noam Postavsky <npostavs <at> gmail.com>
Cc: Michael Heerdegen <michael_heerdegen <at> web.de>, 33301 <at> debbugs.gnu.org
Subject: bug#33301: 27.0.50; broken elisp indentation for non-definition symbols starting with "def.."
Date: Fri, 09 Nov 2018 19:39:16 +0000
Noam Postavsky <npostavs <at> gmail.com> writes:

> Michael Heerdegen <michael_heerdegen <at> web.de> writes:
>
>> João Távora <joaotavora <at> gmail.com> writes:
>>
>>> OK, just add (derived-mode-p 'emacs-lisp-mode), as is done elsewhere
>>> in that file.
>>
>> I think we could do that, but I don't feel qualified to decide.  Maybe
>> Noam can help.
>
> I think it would be acceptable.

OK.  If noone opposes I will commit the patch after my sig in a couple
of days time.

>
>> As far as the example in your bug report is concerned, I think it would
>> also be an improvement if elisp-mode wouldn't try be clever in such a
>> way when indenting branches in a cond or variable associations in a let.
>
> The problem is that we currently don't have any way of specifying
> indentation for subforms of macro arguments, which is also the core
> problem of the other bugs I mentioned about indentation of cl-flet and
> friends.

Well, after some testing with

   (setq lisp-indent-function 'common-lisp-indent-function)

things seem to work as they should.  Though the name is "common lisp",
cl-indent.el's header says it can be used with emacs-lisp-mode, and
indeed it seems to be the case.  In Emacs -Q:

   (setq lisp-indent-function 'common-lisp-indent-function)
    
   (flet ((blablabla
              (correct)
            also-correct))
     ...)
    
   (defmacro deffoo (name args &rest body)
     ;; no indent spec needed
     `(defun ,name ,args ,@body))
    
   (deffoo test
       (correct)
     also-correct)
    
   (defmacro defbla (name args moreargs &rest body)
     (declare (indent 3))
     (frobnicate moreargs)
     `(defun ,name ,args ,@body))
    
   (defbla test
       (correct)
       (also-correct)
     also-also-correct)

   (cond (defoo
          correct))
    
   (let ((defoo
          correct)))

But I don't know if I'm missing anything very important here.  Are there
emacs-lisp indentation tests somewhere?

João

diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el
index afb7cbd1dd..b1a99351ed 100644
--- a/lisp/emacs-lisp/lisp-mode.el
+++ b/lisp/emacs-lisp/lisp-mode.el
@@ -1063,8 +1063,8 @@ lisp-indent-function
 it specifies how to indent.  The property value can be:
 
 * `defun', meaning indent `defun'-style
-  (this is also the case if there is no property and the function
-  has a name that begins with \"def\", and three or more arguments);
+  (this is also the case if there is no property and a macro has
+  a name that begins with \"def\", and three or more arguments);
 
 * an integer N, meaning indent the first N arguments specially
   (like ordinary function arguments), and then indent any further
@@ -1104,7 +1104,9 @@ lisp-indent-function
 	(cond ((or (eq method 'defun)
 		   (and (null method)
 			(> (length function) 3)
-			(string-match "\\`def" function)))
+			(string-match "\\`def" function)
+                        (or (not (derived-mode-p 'emacs-lisp-mode))
+                            (macrop (intern function)))))
 	       (lisp-indent-defform state indent-point))
 	      ((integerp method)
 	       (lisp-indent-specform method state

	    




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.