lassik/emacs-format-all-the-code

format-all-formatters is not an association list with languages presented as symbols

EmilyGraceSeville7cf opened this issue · 5 comments

Emacs version: 28.1

It is told in C-h v that:

format-all-formatters is a variable defined in ‘format-all.el’.

Its value is
((JSON . prettier)
(YAML . prettier)
(Shell . shfmt)
(Python . black)
(Java . clang-format)
(C# . clang-format))

Rules to select which formatter format-all uses.

The value is an association list.

The first item of each association is the name of a programming
language. (GitHub Linguist names are used.)

The remaining items are one or more formatters to use for that
language. Each formatter is either:

  • a symbol (e.g. black, clang-format, rufo)

  • a list whose first item is that symbol, and any remaining items
    are extra command line arguments to pass to the formatter

If more than one formatter is given for the same language, all of
them are run as a chain, with the code from each formatter passed
to the next. The final code is from the last formatter. In case
any formatter in the chain is missing or fails to format the
code, the entire chain fails and the old code before formatting
is preserved.

You’ll probably want to set this in a ".dir-locals.el" file or
in a hook function. Any number of buffers can share the same
association list. Using ".dir-locals.el" is convenient since
the rules for an entire source tree can be given in one file.

Automatically becomes buffer-local when set.
This variable is safe as a file local variable if its value
satisfies the predicate ‘format-all-valid-formatters-p’.

But when I try to reformat .sh file Emacs requests me to select a formatter. But according to the help above everything is correctly set and must work.

Try without the dots, and with the language names as "strings", i.e.:

(("JSON" prettier)
 ("YAML" prettier)
 ("Shell" shfmt)
 ("Python" black)
 ("Java" clang-format)
 ("C#" clang-format))

I've already tried and it worked. But documentation have to be refreshed. :)

Yes, the documentation sucks. PRs to improve it are welcome.

I would update it myself, but the whole configuration system has bad usability, and that problem should be solved outside Emacs.

I.e. improved documentation will not solve the problem that the current config system still sucks.

I am closing issue due to this reason:

I.e. improved documentation will not solve the problem that the current config system still sucks.