emacs-devel
[Top][All Lists]
Advanced

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

Re: Emacs Lisp code formatting


From: Campbell Barton
Subject: Re: Emacs Lisp code formatting
Date: Thu, 4 Nov 2021 11:31:40 +1100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.1

On 11/4/21 10:59, Lars Ingebrigtsen wrote:
Campbell Barton <ideasman42@gmail.com> writes:

There are a handful of 3rd party lisp formatting tools [0], though, YMMV.

[0]: https://emacs.stackexchange.com/a/55759/2418

Thanks.  I had a look at them, but they seem to have the problem of
being 1) too dependent on the rest of a larger package or 2) having
special code for known constructs (meaning that there'd be a maintenance
burden over the years).

I wonder how far one can get by using the symbol properties (i.e.,
edebug-form-spec/lisp-indent-function/doc-string-elt).  Has anybody
looked into that?  If not, I think I'll take a whack at implementing
something simple based on that -- it seems like it should be possible to
make something general based on that.

You could get quite far, an issue I ran into is function introspection such as `func-arity' depend on the code being loaded into emacs.

You could scan external `require' calls, but this means parsing many files to extract the information you need. If you're OK with loading the code for the purpose of introspection - you could spawn an emacs instance for that purpose. If speed is important (such as running this whenever saving a file) the information could be cached (with a file list to detect when the cache needs to be regenerated).

This is the main sticking point for me, something that would need to be resolved before auto-formatting could be recommended for general use.

Note that I use auto-format on save for all my packages (full auto-formatting, not just auto-indent), and personally find it great, but as far as I know I'm the only person doing this.



reply via email to

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