logoalt Hacker News

chriswarbo • today at 5:04 PM • 0 replies • view on HN

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!