-
Notifications
You must be signed in to change notification settings - Fork 94
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
Recommended elixir-format hook hides formatting errors #427
Comments
So I checked to see how https://github.com/bradyt/dart-mode/blob/master/dart-mode.el#L1710-L1721 Note the warning in the docstring about using the echo area. Other pertinent code: https://github.com/bradyt/dart-mode/blob/master/dart-mode.el#L1770-L1774 |
Thanks for doing all this investigative work! I'm comfortable enough with the solution used by go-mode and dart-mode. Are you comfortable enough with elisp to submit a pull request with tests for this? |
@Trevoke Not necessarily but I could potentially cargo cult it and get it working. :) Tests would probably go in |
That would be correct :D
…--
Aldric.
Sent from a mobile device.
On Thu, Nov 8, 2018, 11:00 Felipe Delgado ***@***.*** wrote:
@Trevoke <https://github.com/Trevoke> Not necessarily but I could
potentially cargo cult it and get it working. :)
Tests would probably go in test/elixir-format-test.el, correct?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#427 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAEJSY42RxJU9VCdB4l5e1ShdcKg_qXAks5utGMkgaJpZM4Wp2-U>
.
|
Issue:
As per the README:
However, when the formatter throws an error due to bad syntax, the
before-save-hook
reports the error which can be seen in the*Messages*
buffer, but:• In the minibuffer, the error message quickly goes away when the regular "Wrote
<file>
" message is displayed.• The
*elixir-format-errors*
buffer does not pop up as whenelixir-format
is called interactively.Software Versions:
What I've tried to solve this myself:
This StackOverflow answer suggests using
write-file-functions
orwrite-contents-functions
as hooks instead.I've tried the following code:
And when saving a file with syntactical errors, the file is not saved and a short error appears in the Emacs minibuffer (with details written to a separate buffer):
elixir-format failed: see *elixir-format-errors*
However, that actually doesn't work with files that are already formatted, as
elixir-format
returns(message "File is already formatted")
preventing the save.Possible Solutions:
elixir-format
could returnnil
instead of a message, which would allow thewrite-file-functions
hook to work. Bear in mind, using this hook disallows saving which might annoy some people, but is how e.g. VS Code formatting works in my experience.after-save-hook
be used instead? (In which case you'd still see "File is already formatted" every time you save a clean file—again, unlessnil
is returned as suggested above.)*elixir-format-errors*
buffer could open even ifelixir-format
was called non-interactively.The text was updated successfully, but these errors were encountered: