Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

haskell-mode-stylish-buffer cannot work with the fourmolu formatter with custom configuration file #1765

Closed
kenranunderscore opened this issue Sep 20, 2021 · 2 comments

Comments

@kenranunderscore
Copy link

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
@purcell
Copy link
Member

purcell commented Sep 23, 2021

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.

@kenranunderscore
Copy link
Author

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants