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

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

[elpa] externals/transient 2eb214a6ec 24/41: transient-infix-set(argumen


From: Jonas Bernoulli
Subject: [elpa] externals/transient 2eb214a6ec 24/41: transient-infix-set(argument): Also disable based on concrete value
Date: Sun, 12 Nov 2023 20:04:08 -0500 (EST)

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

    transient-infix-set(argument): Also disable based on concrete value
    
    "--one" may be incompatible with "--two=foo" but not "--two=bar".
---
 docs/transient.org  |  7 ++++++-
 docs/transient.texi |  9 +++++++--
 lisp/transient.el   | 18 +++++++++++++-----
 3 files changed, 26 insertions(+), 8 deletions(-)

diff --git a/docs/transient.org b/docs/transient.org
index 7f3ccf21c8..e8b5a6cbde 100644
--- a/docs/transient.org
+++ b/docs/transient.org
@@ -1792,7 +1792,12 @@ functions use ~describe-function~.
 - ~incompatible~ A list of lists.  Each sub-list specifies a set of
   mutually exclusive arguments.  Enabling one of these arguments
   causes the others to be disabled.  An argument may appear in
-  multiple sub-lists.
+  multiple sub-lists.  Arguments must me given in the same form as
+  used in the ~argument~ or ~argument-format~ slot of the respective
+  suffix objects, usually something like ~--switch~ or ~--option=%s~.  For
+  options and ~transient-switches~ suffixes it is also possible to match
+  against a specific value, as returned by ~transient-infix-value~,
+  for example, ~--option=one~.
 
 - ~scope~ For some transients it might be necessary to have a sort of
   secondary value, called a “scope”.  See ~transient-define-prefix~.
diff --git a/docs/transient.texi b/docs/transient.texi
index 873e2e86e2..a8d1ab2b1e 100644
--- a/docs/transient.texi
+++ b/docs/transient.texi
@@ -2033,11 +2033,16 @@ disabled by default and still considered experimental.
 @code{incompatible} A list of lists.  Each sub-list specifies a set of
 mutually exclusive arguments.  Enabling one of these arguments
 causes the others to be disabled.  An argument may appear in
-multiple sub-lists.
+multiple sub-lists.  Arguments must me given in the same form as
+used in the @code{argument} or @code{argument-format} slot of the respective
+suffix objects, usually something like @code{--switch} or @code{--option=%s}.  
For
+options and @code{transient-switches} suffixes it is also possible to match
+against a specific value, as returned by @code{transient-infix-value},
+for example, @code{--option=one}.
 
 @item
 @code{scope} For some transients it might be necessary to have a sort of
-secondary value, called a ``scope''.  See @code{transient-define-prefix}.
+secondary value, called a “scope”.  See @code{transient-define-prefix}.
 @end itemize
 
 @anchor{Internal Prefix Slots}
diff --git a/lisp/transient.el b/lisp/transient.el
index af11c3b7e9..e590c905c5 100644
--- a/lisp/transient.el
+++ b/lisp/transient.el
@@ -3188,20 +3188,28 @@ prompt."
 (cl-defmethod transient-infix-set :after ((obj transient-argument) value)
   "Unset incompatible infix arguments."
   (when-let* ((--- value)
+              (val (transient-infix-value obj))
               (arg (if (slot-boundp obj 'argument)
                        (oref obj argument)
                      (oref obj argument-format)))
               (spec (oref transient--prefix incompatible))
-              (incomp (cl-mapcan (lambda (rule)
-                                   (and (member arg rule)
-                                        (remove arg rule)))
-                                 spec)))
+              (filter (lambda (x rule)
+                        (and (member x rule)
+                             (remove x rule))))
+              (incomp (nconc
+                       (cl-mapcan (apply-partially filter arg) spec)
+                       (and (not (equal val arg))
+                            (cl-mapcan (apply-partially filter val) spec)))))
     (dolist (obj transient--suffixes)
       (when-let* ((--- (cl-typep obj 'transient-argument))
+                  (val (transient-infix-value obj))
                   (arg (if (slot-boundp obj 'argument)
                            (oref obj argument)
                          (oref obj argument-format)))
-                  (--- (member arg incomp)))
+                  (--- (if (equal val arg)
+                           (member arg incomp)
+                         (or (member val incomp)
+                             (member arg incomp)))))
         (transient-infix-set obj nil)))))
 
 (cl-defgeneric transient-set-value (obj)



reply via email to

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