`haskell-mode-stylish-buffer` cannot work with the fourmolu formatter with custom configuration file
kenranunderscore opened this issue · 2 comments
fourmolu is a formatter forked from ormolu, but with the option to load its configuration from a file. If one chooses to do so (by adding a fourmolu.yaml
to the project root), it outputs a message like Loaded config from fourmolu.yaml
to stderr
.
Now haskell-buffer-apply-command
- which is called by haskell-mode-stylish-buffer
- never checks the error code (which is 0
here in my case, as the buffer can successfully be formatted), but only the contents of the error file, containing the above message.
I've created an issue with fourmolu (fourmolu/fourmolu#110) to maybe suppress this message altogether, but I feel like disregarding the error code is not the optimal choice in this case.
I'd have created some PR for this, but I'm actually not really sure how to best handle the branches. Replacing the first check for err-file-empty-p
with (= errcode 0)
worked for me, but it leaves the case unhandled where:
- Error code is
0
- The output is empty
- The error file is non-empty
Really the preferred method here would be to not even support stylish
in haskell-mode
: there are numerous separate packages which can trivially provide support for formatters, and be installed according to users' needs. My own reformatter
package makes it easy to construct such things. I imagine that the existing ormolu
emacs package can trivially be made to run fourmolu
instead.
I'm using a patched version of fourmolu
for now (for months, actually; just forgot to answer here).
I've installed reformatter
(but haven't configured it yet) since what you're saying really makes sense and this will surely make my life easier with other languages in Emacs in the long run, thanks!