How does your claim apply to this? https://www.gnu.org/software/emacs/manual/html_node/elisp/In...
For example, how should this Emacs Lisp code be formatted?
(foo
bar
baz
quux)
According to Emacs (definitely a "Lisp-aware editor"), it depends on the definition of `foo`! If `foo` is a macro, it can use `(declare (indent ...))` to specify how its use-sites should be indented. If `foo` happens to be a function, or a macro which doesn't use `(declare (indent ...))`, then Emacs will indent it as above. However, if it's defined like this: (defmacro foo (&rest args)
"Does foo to ARGS."
(declare (indent 2))
(blah))
Then Emacs will indent it as: (foo
bar
baz
quux)
So, at the very least, a "Lisp-aware" formatter would need to resolve names, traverse load paths, etc. to find out whether each call is actually a macro, and whether the definition of such a macro declares an indent rule.But it gets worse! Since we can also do:
(defmacro foo (&rest args)
"Does foo to ARGS."
(declare (indent 'uh-oh))
(blah))
With a definition like that, Emacs will choose how much indentation to use by calling the `uh-oh` function! That makes indentation of Emacs Lisp undecidable!
That specific example would always be
Once we separate even the first argument on its own line, we have made clear that that is where the division is, and given up on more detail: it's some kind of operator with arguments.If the list is quoted then:
The ambiguity is if you have this: If foo is a function If it is a macro with a trailing body of forms ("implicit progn" in CL parlance) then we don't know, without the macro definition, how many of the initial arguments are not part of those forms: or or A good solution to all this is parinfer: specifically indent -> parens mode. That is to say, manually or semi-automatically control indent, and let parentheses be inferred.The above issues are all symptoms of the assumption that the programmer controls parentheses, leaving the indentation to be figured out.
But parentheses are the aspect of the code that can only be one way, whereas indentation has latitudes that mean nothing to the machine but visually indicate semantics.
So, switch roles: let the machine deal with the parentheses. Then there is no problem to be solved whatsoever that requires declaration info or execution of functions.
The downside is that if we have a correct inference from parentheses to indentation, it can help to spot errors. For instance, if you write:
and the indentation jumps to this: then you have an instant reminder that you forgot to write the expression to be analyzed by the pattern, causing your first body form to be interpreted as that.To me, that is minor, and I'm willing to throw it under the bus by controlling indentation.
Parens inference from indentation is not perfect, though! This is illustrated best by cond. If you have a cond clause like this:
parinfer wants to do this: because the forms are indented, they are assumed to be constituents of the condition expression. The fix for that is to just learn to embrace: Only problem with that is working with your legacy code where you have the indentation.