[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#33301: 27.0.50; broken elisp indentation for non-definition symbols
From: |
João Távora |
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 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) |
Noam Postavsky <npostavs@gmail.com> writes:
> Michael Heerdegen <michael_heerdegen@web.de> writes:
>
>> João Távora <joaotavora@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
- bug#33301: 27.0.50; broken elisp indentation for non-definition symbols starting with "def..", João Távora, 2018/11/07
- bug#33301: 27.0.50; broken elisp indentation for non-definition symbols starting with "def..", Noam Postavsky, 2018/11/07
- bug#33301: 27.0.50; broken elisp indentation for non-definition symbols starting with "def..", Michael Heerdegen, 2018/11/07
- bug#33301: 27.0.50; broken elisp indentation for non-definition symbols starting with "def..", João Távora, 2018/11/08
- bug#33301: 27.0.50; broken elisp indentation for non-definition symbols starting with "def..", Michael Heerdegen, 2018/11/08
- bug#33301: 27.0.50; broken elisp indentation for non-definition symbols starting with "def..", João Távora, 2018/11/08
- bug#33301: 27.0.50; broken elisp indentation for non-definition symbols starting with "def..", Michael Heerdegen, 2018/11/08
- bug#33301: 27.0.50; broken elisp indentation for non-definition symbols starting with "def..", João Távora, 2018/11/09
- bug#33301: 27.0.50; broken elisp indentation for non-definition symbols starting with "def..", Michael Heerdegen, 2018/11/09
- bug#33301: 27.0.50; broken elisp indentation for non-definition symbols starting with "def..", Noam Postavsky, 2018/11/09
- bug#33301: 27.0.50; broken elisp indentation for non-definition symbols starting with "def..",
João Távora <=
- bug#33301: 27.0.50; broken elisp indentation for non-definition symbols starting with "def..", Michael Heerdegen, 2018/11/09
- bug#33301: 27.0.50; broken elisp indentation for non-definition symbols starting with "def..", João Távora, 2018/11/10
- bug#33301: 27.0.50; broken elisp indentation for non-definition symbols starting with "def..", Andreas Schwab, 2018/11/10
- bug#33301: 27.0.50; broken elisp indentation for non-definition symbols starting with "def..", João Távora, 2018/11/10
- bug#33301: 27.0.50; broken elisp indentation for non-definition symbols starting with "def..", Andreas Schwab, 2018/11/10
- bug#33301: 27.0.50; broken elisp indentation for non-definition symbols starting with "def..", João Távora, 2018/11/10
- bug#33301: 27.0.50; broken elisp indentation for non-definition symbols starting with "def..", João Távora, 2018/11/10