[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)
- [elpa] externals/transient 8d8df0f038 20/41: transient-infix-set(argument): Cosmetics, (continued)
- [elpa] externals/transient 8d8df0f038 20/41: transient-infix-set(argument): Cosmetics, Jonas Bernoulli, 2023/11/12
- [elpa] externals/transient 9d9e931996 25/41: transient--shadowed-buffer: Renamed from transient--current-buffer, Jonas Bernoulli, 2023/11/12
- [elpa] externals/transient 8e15a29b59 31/41: transient-format-description: Support function as value of face slot, Jonas Bernoulli, 2023/11/12
- [elpa] externals/transient 533578b6b2 32/41: transient-information: Use a space as the fake key, Jonas Bernoulli, 2023/11/12
- [elpa] externals/transient 59d8c0342a 18/41: transient--unset-incompatible: Remove unnecessary variable, Jonas Bernoulli, 2023/11/12
- [elpa] externals/transient ed5bd6fdc3 23/41: transient-infix-set(argument): Fix disabling incompatible options, Jonas Bernoulli, 2023/11/12
- [elpa] externals/transient bad91f79ec 29/41: transient-with-shadowed-buffer: Move definition, Jonas Bernoulli, 2023/11/12
- [elpa] externals/transient cf32cf6f98 39/41: transient--get-face: Favor face over function, Jonas Bernoulli, 2023/11/12
- [elpa] externals/transient 4b9d831d28 10/41: transient--make-predicate-map: Drop obsolete condition, Jonas Bernoulli, 2023/11/12
- [elpa] externals/transient 784887b781 14/41: Account for t as transient-suffix for nested prefixes, Jonas Bernoulli, 2023/11/12
- [elpa] externals/transient 2eb214a6ec 24/41: transient-infix-set(argument): Also disable based on concrete value,
Jonas Bernoulli <=
- [elpa] externals/transient 94661e0ccd 34/41: transient--do-replace: Replace with two variants, Jonas Bernoulli, 2023/11/12
- [elpa] externals/transient 9617b6c77c 35/41: transient--make-predicate-map: Support shorthands, Jonas Bernoulli, 2023/11/12
- [elpa] externals/transient 3a2b936a67 36/41: Fix highlighting infix for which user input is being read, Jonas Bernoulli, 2023/11/12
- [elpa] externals/transient 222c2bfbeb 38/41: transient--get-face: New function, Jonas Bernoulli, 2023/11/12
- [elpa] externals/transient 02607dd9d9 04/41: manual: Move comparisons to wiki, Jonas Bernoulli, 2023/11/12
- [elpa] externals/transient 0677e2c3d8 26/41: transient-format-description: Operate in transient--shadowed-buffer, Jonas Bernoulli, 2023/11/12
- [elpa] externals/transient b4a2963636 33/41: transient-format(around:suffix): Update for transient-information, Jonas Bernoulli, 2023/11/12
- [elpa] externals/transient d44c4fce39 40/41: transient--get-face: Use for inapt-face, Jonas Bernoulli, 2023/11/12
- [elpa] externals/transient eaf062a921 11/41: transient--make-predicate-map: Refactor, Jonas Bernoulli, 2023/11/12
- [elpa] externals/transient 5ad5b627f6 15/41: transient--setup-recursion: When initiated by outer transient-suffix, Jonas Bernoulli, 2023/11/12