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

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

[elpa] externals/transient 544b3bb864 057/366: Support automatically dis


From: Jonas Bernoulli
Subject: [elpa] externals/transient 544b3bb864 057/366: Support automatically disabling incompatible arguments
Date: Tue, 25 Jan 2022 18:54:26 -0500 (EST)

branch: externals/transient
commit 544b3bb864438b23eb0dc7a1af2254f7bf4f200c
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>

    Support automatically disabling incompatible arguments
---
 lisp/transient.el | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/lisp/transient.el b/lisp/transient.el
index a1460c02e4..fe94416078 100644
--- a/lisp/transient.el
+++ b/lisp/transient.el
@@ -411,7 +411,8 @@ If `transient-save-history' is nil, then do nothing."
    (man-page    :initarg :man-page    :initform nil)
    (info-manual :initarg :info-manual :initform nil)
    (transient-suffix     :initarg :transient-suffix     :initform nil)
-   (transient-non-suffix :initarg :transient-non-suffix :initform nil))
+   (transient-non-suffix :initarg :transient-non-suffix :initform nil)
+   (incompatible         :initarg :incompatible         :initform nil))
   "Transient prefix command.
 
 Each transient prefix command consists of a command, which is
@@ -2172,6 +2173,8 @@ prompt."
 
 ;;;; Set
 
+(defvar transient--unset-incompatible t)
+
 (cl-defgeneric transient-infix-set (obj value)
   "Set the value of infix object OBJ to value.")
 
@@ -2179,9 +2182,25 @@ prompt."
   "Set the value of infix object OBJ to value.
 
 This implementation should be suitable for almost all infix
-commands.  It simply calls `oset'."
+commands."
   (oset obj value value))
 
+(cl-defmethod transient-infix-set :around ((obj transient-infix) value)
+  "Unset incompatible infix arguments."
+  (if-let ((sic transient--unset-incompatible)
+           (arg (oref obj argument))
+           (spec (oref transient--prefix incompatible))
+           (incomp (remove arg (cl-find-if (lambda (elt) (member arg elt)) 
spec))))
+      (progn
+        (cl-call-next-method)
+        (dolist (arg incomp)
+          (when-let ((obj (cl-find-if (lambda (obj)
+                                        (equal (oref obj argument) arg))
+                                      transient--suffixes)))
+            (let ((transient--unset-incompatible nil))
+              (transient-infix-set obj nil)))))
+    (cl-call-next-method)))
+
 (cl-defmethod transient-set-value ((obj transient-prefix))
   (oset (oref obj prototype) value (transient-args))
   (transient--history-push obj))



reply via email to

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