emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/reformatter 7219a0804c 48/81: Support for formatters which


From: ELPA Syncer
Subject: [nongnu] elpa/reformatter 7219a0804c 48/81: Support for formatters which succeed with non-zero exit codes
Date: Tue, 5 Sep 2023 04:03:37 -0400 (EDT)

branch: elpa/reformatter
commit 7219a0804c8500c44c3890ecc706d68f7c4d3501
Author: Steve Purcell <steve@sanityinc.com>
Commit: Steve Purcell <steve@sanityinc.com>

    Support for formatters which succeed with non-zero exit codes
    
    See #22
---
 reformatter.el | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/reformatter.el b/reformatter.el
index 1262fcd695..8c1df62b93 100644
--- a/reformatter.el
+++ b/reformatter.el
@@ -75,7 +75,7 @@
 (require 'ansi-color)
 
 ;;;###autoload
-(cl-defmacro reformatter-define (name &key program args (mode t) lighter 
keymap group)
+(cl-defmacro reformatter-define (name &key program args (mode t) lighter 
keymap group (exit-code-success-p 'zerop))
   "Define a reformatter command with NAME.
 
 When called, the reformatter will use PROGRAM and any ARGS to
@@ -121,9 +121,18 @@ The macro accepts the following keyword arguments:
 :keymap
 
   If provided, this is the symbol name of the \"-on-save\" mode's
-  keymap, which you must declare yourself.  Default is no keymap."
+  keymap, which you must declare yourself.  Default is no keymap.
+
+:exit-code-success-p
+
+  If provided, this is a function object callable with `funcall'
+  which accepts an integer process exit code, and returns non-nil
+  if that exit code is considered successful.  This could be a
+  lambda, quoted symbol or sharp-quoted symbol.  If not supplied,
+  the code is considered successful if it is `zerop'."
   (declare (indent defun))
   (cl-assert (symbolp name))
+  (cl-assert (functionp exit-code-success-p))
   (cl-assert program)
   ;; Note: we skip using `gensym' here because the macro arguments are only
   ;; referred to once below, but this may have to change later.
@@ -182,7 +191,7 @@ DISPLAY-ERRORS, shows a buffer if the formatting fails."
                      (insert-file-contents err-file nil nil nil t)
                      (ansi-color-apply-on-region (point-min) (point-max)))
                    (special-mode))
-                 (if (zerop retcode)
+                 (if (funcall #',exit-code-success-p retcode)
                      (progn
                        (save-restriction
                          ;; This replacement method minimises



reply via email to

[Prev in Thread] Current Thread [Next in Thread]