bug#43329: 28.0.50; Incorrect indentation for variables starting with `def' in let form
In the scratch buffer, enter
and reindent the second line. Emacs will insert an additional space
before `foo' so that the `f' is now below the `e'. This seems to happen
only for variables starting with `def' (but not `def' itself).
In GNU Emacs 28.0.50 (build 90, x86_64-pc-linux-gnu, GTK+ Version 3.24.20, cairo version 1.16.0)
Repository revision: e2391d486e8a97e383db2337fad6a93c2c11656a
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12008000
System Description: Debian GNU/Linux rodete
value of $LANG: en_US.utf8
value of $XMODIFIERS: @im=ibus
Major mode: Lisp Interaction
Minor modes in effect:
Google Germany GmbH
Geschäftsführer: Paul Manicle, Halimah DeLaine Prado
Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg
Diese E-Mail ist vertraulich. Falls Sie diese fälschlicherweise erhalten haben
sollten, leiten Sie diese bitte nicht an jemand anderes weiter, löschen Sie
alle Kopien und Anhänge davon und lassen Sie mich bitte wissen, dass die E-Mail
an die falsche Person gesendet wurde.
This e-mail is confidential. If you received this communication by mistake,
please don’t forward it to anyone else, please erase all copies and
attachments, and please let me know that it has gone to the wrong person.
> In the scratch buffer, enter
> (let ((defa
> and reindent the second line. Emacs will insert an additional space
> before `foo' so that the `f' is now below the `e'. This seems to happen
> only for variables starting with `def' (but not `def' itself).
Yes, the Emacs Lisp indentation machinery assumes that everything that
starts with "def" is a macro that defines something. That's pretty
quirky, but it's been that way since forever, so it's probably too late
to do something about that now.
It should, however, be possible to do something about this in a `let'
form, you'd think. But I've tried to find the place where this happens
(I was looking at it just the other day!), but my grep skills fail me.
>> 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
> It obviously has the downside of not indenting properly those
> definitions which are not at the very-top level. E.g. definitions
> inside an `eval-when-compile` or other.
That's true. I guess the (def* calls can happen at any level, really.
But the (def* thing is a heuristic, and we could say that we only use
that heuristic at the top level?
We should then mark all the (def* things we have in-tree with explicit
indentation marking (which I think we should do anyway, really).