aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md5
-rw-r--r--apheleia.el41
2 files changed, 26 insertions, 20 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0498d7c..7e89f92 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -25,6 +25,10 @@ The format is based on [Keep a Changelog].
running. Instead, it is disabled in narrowed buffers. Support for
narrowed buffers may be added in future but it has never been
correctly supported in the past (see [#43]). More at [#124], [#127].
+* Currently, when a formatter invoked via a process isn't installed
+ correctly; it throws an error. It doesn't make sense to attempt to
+ format if we can't find the correct formatter, so instead formatting
+ is only attempted when the formatter is found. [#126]
### Formatters
* [elm-format](https://github.com/avh4/elm-format) for Elm ([#100]).
@@ -53,6 +57,7 @@ The format is based on [Keep a Changelog].
[#124]: https://github.com/radian-software/apheleia/issues/124
[#125]: https://github.com/radian-software/apheleia/pull/125
[#127]: https://github.com/radian-software/apheleia/pull/127
+[#128]: https://github.com/radian-software/apheleia/pull/128
## 3.0 (released 2022-06-01)
### Breaking changes
diff --git a/apheleia.el b/apheleia.el
index 379fd0d..f9dbcc5 100644
--- a/apheleia.el
+++ b/apheleia.el
@@ -862,27 +862,28 @@ purposes."
(locate-library "apheleia"))))))
exec-path)))
(cl-destructuring-bind (input-fname output-fname stdin &rest command) ret
- (apheleia--execute-formatter-process
- :command command
- :stdin (unless input-fname
- stdin)
- :callback
- (lambda (stdout)
- (when output-fname
- ;; Load output-fname contents into the stdout buffer.
- (erase-buffer)
- (insert-file-contents-literally output-fname))
-
- (funcall callback stdout))
- :ensure
- (lambda ()
- (ignore-errors
- (when input-fname
- (delete-file input-fname))
+ (when (executable-find (car command))
+ (apheleia--execute-formatter-process
+ :command command
+ :stdin (unless input-fname
+ stdin)
+ :callback
+ (lambda (stdout)
(when output-fname
- (delete-file output-fname))))
- :remote remote
- :formatter formatter)))))
+ ;; Load output-fname contents into the stdout buffer.
+ (erase-buffer)
+ (insert-file-contents-literally output-fname))
+
+ (funcall callback stdout))
+ :ensure
+ (lambda ()
+ (ignore-errors
+ (when input-fname
+ (delete-file input-fname))
+ (when output-fname
+ (delete-file output-fname))))
+ :remote remote
+ :formatter formatter))))))
(defun apheleia--run-formatter-function
(func buffer remote callback stdin formatter)