Fix rustfmt, show log by default

This commit is contained in:
Radon Rosborough 2022-01-02 16:41:20 -08:00
parent 6449a7439e
commit d3304b018c
2 changed files with 30 additions and 5 deletions

View file

@ -10,6 +10,14 @@ The format is based on [Keep a Changelog].
function as a formatter allowing you to plug more powerful function as a formatter allowing you to plug more powerful
formatters into apheleia such as language servers. formatters into apheleia such as language servers.
## Changes
* Stdout and stderr buffers are no longer retained after running a
formatter. Instead, the stderr is appended into an
`*apheleia-whatever-log*` buffer if it fails, or unconditionally if
the new user option `apheleia-verbose` is set to non-nil. See [#64],
[#65]. The log buffer is not hidden by default, and this can be
changed via the new user option `apheleia-hide-log-buffer` ([#69]).
## Bugs fixed ## Bugs fixed
* Allow running the same formatter in multiple buffers in parallel * Allow running the same formatter in multiple buffers in parallel
([#64], [#65]). Previously, when saving a number of files at the ([#64], [#65]). Previously, when saving a number of files at the
@ -18,12 +26,16 @@ The format is based on [Keep a Changelog].
* In some circumstances the error `wrong-type-argument bufferp nil` * In some circumstances the error `wrong-type-argument bufferp nil`
could be reported when running certain formatters under Apheleia. could be reported when running certain formatters under Apheleia.
This has been fixed. This has been fixed.
* Rustfmt is no longer passed the `--unstable-features` and
`--skip-children` flags, since they are not available on all
versions of Rustfmt ([#69]).
[#52]: https://github.com/raxod502/apheleia/issues/52 [#52]: https://github.com/raxod502/apheleia/issues/52
[#60]: https://github.com/raxod502/apheleia/issues/60 [#60]: https://github.com/raxod502/apheleia/issues/60
[#62]: https://github.com/raxod502/apheleia/issues/62 [#62]: https://github.com/raxod502/apheleia/issues/62
[#64]: https://github.com/raxod502/apheleia/issues/64 [#64]: https://github.com/raxod502/apheleia/issues/64
[#65]: https://github.com/raxod502/apheleia/pull/65 [#65]: https://github.com/raxod502/apheleia/pull/65
[#69]: https://github.com/raxod502/apheleia/issues/69
## 1.2 (released 2021-12-27) ## 1.2 (released 2021-12-27)
### Enhancements ### Enhancements

View file

@ -36,6 +36,13 @@
:link '(url-link :tag "GitHub" "https://github.com/raxod502/apheleia") :link '(url-link :tag "GitHub" "https://github.com/raxod502/apheleia")
:link '(emacs-commentary-link :tag "Commentary" "apheleia")) :link '(emacs-commentary-link :tag "Commentary" "apheleia"))
(defcustom apheleia-hide-log-buffer nil
"Non-nil means log buffers will be hidden.
Hidden buffers have names that begin with a space, and do not
appear in `switch-to-buffer' unless you type in a space
manually."
:type 'boolean)
(cl-defun apheleia--edit-distance-table (s1 s2) (cl-defun apheleia--edit-distance-table (s1 s2)
"Align strings S1 and S2 for minimum edit distance. "Align strings S1 and S2 for minimum edit distance.
Return the dynamic programming table as has table which maps cons Return the dynamic programming table as has table which maps cons
@ -283,7 +290,11 @@ command succeeds provided that its exit status is 0."
(stderr (generate-new-buffer (stderr (generate-new-buffer
(format " *apheleia-%s-stderr*" name))) (format " *apheleia-%s-stderr*" name)))
(log (get-buffer-create (log (get-buffer-create
(format " *apheleia-%s-log*" name)))) (format "%s*apheleia-%s-log*"
(if apheleia-hide-log-buffer
" "
"")
name))))
(condition-case-unless-debug e (condition-case-unless-debug e
(progn (progn
(setq apheleia--current-process (setq apheleia--current-process
@ -320,10 +331,13 @@ command succeeds provided that its exit status is 0."
(message (message
(concat (concat
"Failed to run %s: exit status %s " "Failed to run %s: exit status %s "
"(see hidden buffer%s)") "(see %s %s)")
(car command) (car command)
(process-exit-status proc) (process-exit-status proc)
log)) (if (string-prefix-p " " (buffer-name log))
"hidden buffer"
"buffer")
(string-trim (buffer-name log))))
(when ensure (when ensure
(funcall ensure)) (funcall ensure))
(kill-buffer stdout) (kill-buffer stdout)
@ -626,8 +640,7 @@ function: %s" command)))
(latexindent . ("latexindent")) (latexindent . ("latexindent"))
(ocamlformat . ("ocamlformat" "-" "--name" filepath)) (ocamlformat . ("ocamlformat" "-" "--name" filepath))
(prettier . (npx "prettier" "--stdin-filepath" filepath)) (prettier . (npx "prettier" "--stdin-filepath" filepath))
(rustfmt . ("rustfmt" "--unstable-features" "--skip-children" (rustfmt . ("rustfmt" "--quiet" "--emit" "stdout"))
"--quiet" "--emit" "stdout"))
(terraform . ("terraform" "fmt" "-"))) (terraform . ("terraform" "fmt" "-")))
"Alist of code formatting commands. "Alist of code formatting commands.
The keys may be any symbols you want, and the values are The keys may be any symbols you want, and the values are