[Top][All Lists]

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

Re: Indentation of def*

From: Richard Stallman
Subject: Re: Indentation of def*
Date: Sat, 23 Oct 2021 19:26:34 -0400

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > But, regardless, is it not so that there are various grades of
  > change here?

  > a - do nothing
  > b - keep heuristic but only for macros, delete for everything else.
  > c - delete heuristic entirely

The heuristic defines the default way of indenting calls to entities
when they have no specific indentation rule to override that default.
The question is which default is better.

Following the heuristic by default will lead to better indentation in
some cases, and worse in some cases.  An ugly indentation due to
following the heuristic (when it is wrong) is no worse than an ugly
indentation due to not following it (when it is right).  In either
case, we know what to do to make that problem go away.

So unless we find that the heuristic causes more bad than good, we
should keep it.

I expect it gives us a lot of good and only a little bad.  Though I
have no way of actually measuring this.

  > If you want the data, it's there in the Emacs tree.  Look at all
  > functions/macros named def* with/without indent specs, examine what they
  > are, and count.

This would count the number of constructs which have the potential to
be indented well due to the heuristic, or the potential to be indented
badly due to the heuristic.  But that's the wrong way to evaluate the
amount of good and bad done by the heuristic.

Consider for example this function:

  > Or wrongly -- functions like `default-boundp' are indented wrongly using
  > that heuristic.

Indeed, if you break the line right after `(default-boundp', it
indents one extra space.  That indentation is not bad or confusing,
only slightly different.

But I conjecture it will almost never happen anyway -- that people
break the line there so rarely that it hardly qualifies as a problem.

To evaluate how well the heuristic works, we should look for the cases
which are more likely to occur and would indent in a truly annoying or
misleading way, either due to the heuristic or due to its absence.

  > I don't see what makes these macros special.  You have the same problem
  > with macros like `with-*' and `when-let' -- these also indent wrongly if
  > you haven't loaded their definitions.

That's true.  The convention of macros called `with-...' macros
started in the 1990s, I think.

I suggest we look at adding a few more indentation heuristics.
We could start with `with-...'

Normally the first sexp is the one that should be indented specially.
Are there any `with-...' macros that don't follow that general pattern?
Are there any other function/macros named `with-...'?

Dr Richard Stallman (https://stallman.org)
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)

reply via email to

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