[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/reformatter 2ff029f84b 64/81: Display error message in err
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/reformatter 2ff029f84b 64/81: Display error message in error buffer if call-process signals |
Date: |
Tue, 5 Sep 2023 04:03:38 -0400 (EDT) |
branch: elpa/reformatter
commit 2ff029f84b9afe3665d828b4b1c19f349a37c982
Author: Aaron L. Zeng <me@bcc32.com>
Commit: Aaron L. Zeng <me@bcc32.com>
Display error message in error buffer if call-process signals
`call-process` may signal instead of returning an integer code if
executing the program failed, for example if the command was not
found.
In the case where reformatter is invoked from a `before-save-hook`,
the only sign that anything went wrong is a line in *Messages*:
Error: (file-missing "Searching for program" "No such file or
directory" "shfmt")
Unfortunately, this error message is immediately cleared from the echo
area by the following message:
Wrote /path/to/file
So the user may not even know that the formatter failed to run.
Change `reformatter--do-region` so that it displays the error message,
which would have been displayed in the echo area, in the error buffer
instead.
---
reformatter.el | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/reformatter.el b/reformatter.el
index 73d7cddb39..b54dcb5761 100644
--- a/reformatter.el
+++ b/reformatter.el
@@ -102,17 +102,21 @@ the `reformatter-define' macro."
(write-region beg end input-file nil :quiet)
(let* ((error-buffer (get-buffer-create (format "*%s errors*" name)))
(retcode
- (apply 'call-process program
- (when stdin input-file)
- (list (list :file stdout-file) stderr-file)
- nil
- args)))
+ (condition-case e
+ (apply 'call-process program
+ (when stdin input-file)
+ (list (list :file stdout-file) stderr-file)
+ nil
+ args)
+ (error e))))
(with-current-buffer error-buffer
(let ((inhibit-read-only t))
(insert-file-contents stderr-file nil nil nil t)
+ (unless (integerp retcode)
+ (insert (error-message-string retcode)))
(ansi-color-apply-on-region (point-min) (point-max)))
(special-mode))
- (if (funcall exit-code-success-p retcode)
+ (if (and (integerp retcode) (funcall exit-code-success-p retcode))
(progn
(save-restriction
;; This replacement method minimises
- [nongnu] elpa/reformatter 466203594c 36/81: Fix broken link to example, (continued)
- [nongnu] elpa/reformatter 466203594c 36/81: Fix broken link to example, ELPA Syncer, 2023/09/05
- [nongnu] elpa/reformatter 8423ad9e83 47/81: Merge pull request #21 from erickgnavar/close-error-buffer-with-no-errors, ELPA Syncer, 2023/09/05
- [nongnu] elpa/reformatter c6919a6549 38/81: Merge pull request #17 from bradyt/patch-1, ELPA Syncer, 2023/09/05
- [nongnu] elpa/reformatter 9d277200c1 52/81: Add Emacs 27.1 to CI matrix, ELPA Syncer, 2023/09/05
- [nongnu] elpa/reformatter 0c24778dfc 50/81: Fix grammar, ELPA Syncer, 2023/09/05
- [nongnu] elpa/reformatter f5fbed9e7d 46/81: Close error window when there is no errors to be shown, ELPA Syncer, 2023/09/05
- [nongnu] elpa/reformatter e8f70b20ca 45/81: No longer forcibly call delete-trailing-whitespace, ELPA Syncer, 2023/09/05
- [nongnu] elpa/reformatter 3833c13dd9 51/81: Clarify how args are evaluated, and what to avoid, ELPA Syncer, 2023/09/05
- [nongnu] elpa/reformatter 028dae00dd 30/81: Merge pull request #4 from peterwvj/patch-1, ELPA Syncer, 2023/09/05
- [nongnu] elpa/reformatter 7e41f1a397 33/81: Use replace-buffer-contents when available and not broken, ELPA Syncer, 2023/09/05
- [nongnu] elpa/reformatter 2ff029f84b 64/81: Display error message in error buffer if call-process signals,
ELPA Syncer <=
- [nongnu] elpa/reformatter 7c5452bf31 69/81: Update tests to used suffixed commands only, ELPA Syncer, 2023/09/05
- [nongnu] elpa/reformatter 130205bbe2 68/81: Remove the catch-all alias: users should make their own defalias as needed, ELPA Syncer, 2023/09/05
- [nongnu] elpa/reformatter e6c23cd52d 58/81: Update CI config to specify nix-path, ELPA Syncer, 2023/09/05
- [nongnu] elpa/reformatter 113ddd51bd 74/81: Add dependabot config, ELPA Syncer, 2023/09/05
- [nongnu] elpa/reformatter 1cbf7225b0 76/81: Merge pull request #40 from purcell/dependabot/github_actions/cachix/install-nix-action-22, ELPA Syncer, 2023/09/05
- [nongnu] elpa/reformatter 1af1371f71 78/81: chore(deps): bump actions/checkout from 2 to 4, ELPA Syncer, 2023/09/05
- [nongnu] elpa/reformatter 7cf8b5d71e 08/81: Note about absence of "gensym", ELPA Syncer, 2023/09/05
- [nongnu] elpa/reformatter 48bcae5856 06/81: Doc fixes, ELPA Syncer, 2023/09/05
- [nongnu] elpa/reformatter 0aea1debd1 05/81: package-lint fixes, primarily renaming define-formatter, ELPA Syncer, 2023/09/05
- [nongnu] elpa/reformatter 664fa96fd0 24/81: Add/update comments, ELPA Syncer, 2023/09/05