[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/transient f086cb620b 224/366: transient--insert-suffix:
From: |
Jonas Bernoulli |
Subject: |
[elpa] externals/transient f086cb620b 224/366: transient--insert-suffix: Allow same key with different predicates |
Date: |
Tue, 25 Jan 2022 18:54:43 -0500 (EST) |
branch: externals/transient
commit f086cb620b4c3cb99b5d1a885cf534718d0367d9
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>
transient--insert-suffix: Allow same key with different predicates
Previously it was not possible to add two bindings that use the
same key but different predicates using `transient-insert-suffix'.
Such only superficially conflicting bindings had to be added when
the prefix was defined using `transient-define-prefix'.
Now we use a heuristic to allow `transient-insert-suffix' to add
such bindings as well.
If both bindings define a predicate and these predicates are not
equal, then the two bindings are assumed to be distinct. If on
the other hand at least one of the bindings lacks a predicate or
the predicates are equal, then the new binding is considered a
replacement for the old binding, as before.
Closes #106.
---
lisp/transient.el | 24 +++++++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)
diff --git a/lisp/transient.el b/lisp/transient.el
index 5f6b509d34..cbd5ec4d12 100644
--- a/lisp/transient.el
+++ b/lisp/transient.el
@@ -1065,7 +1065,15 @@ example, sets a variable use `transient-define-infix'
instead.
;; We must keep `mem' until after we have inserted
;; behind it, which `transient-remove-suffix' does
;; not allow us to do.
- (setq action 'replace)
+ (let ((spred (transient--suffix-predicate suf))
+ (epred (transient--suffix-predicate elt)))
+ ;; If both suffixes have a predicate and they
+ ;; are not identical, then the probability is
+ ;; high that we want to keep both.
+ (when (or (not spred)
+ (not epred)
+ (equal spred epred))
+ (setq action 'replace)))
(transient-remove-suffix prefix key))))
(cl-ecase action
(insert (setcdr mem (cons elt (cdr mem)))
@@ -1801,6 +1809,20 @@ value. Otherwise return CHILDREN as is."
(apply #'derived-mode-p if-not-derived))))
(t default)))
+(defun transient--suffix-predicate (spec)
+ (let ((plist (nth 2 spec)))
+ (seq-some (lambda (prop)
+ (when-let ((pred (plist-get plist prop)))
+ (list prop pred)))
+ '( :if :if-not
+ :if-nil :if-non-nil
+ :if-mode :if-not-mode
+ :if-derived :if-not-derived
+ :inapt-if :inapt-if-not
+ :inapt-if-nil :inapt-if-non-nil
+ :inapt-if-mode :inapt-if-not-mode
+ :inapt-if-derived :inapt-if-not-derived))))
+
;;; Flow-Control
(defun transient--init-transient ()
- [elpa] externals/transient dcf7a4dc62 084/366: transient-read-with-initial-input: New option, (continued)
- [elpa] externals/transient dcf7a4dc62 084/366: transient-read-with-initial-input: New option, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient fd9e9bfe26 088/366: transient--layout-member-1: New function, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient ac02efc119 157/366: transient--scroll-commands: New variable, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 9683e8add2 165/366: transient--do-suffix-p: New function, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient ec2de622d2 171/366: transient-suffix-object: Check type of argument, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient bcd07e065b 172/366: transient--suffix-symbol: Split from transient--suffix-command, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 293a437d66 206/366: Support padding of keys regardless of the group's class, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 3284f6a0fe 213/366: transient-init-value: Support per-object functions for prefixes, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 809fd048b1 223/366: transient--insert-suffix: Add comments, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient fd2695d12c 217/366: transient--with-emergency-exit: Wrap default debug function, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient f086cb620b 224/366: transient--insert-suffix: Allow same key with different predicates,
Jonas Bernoulli <=
- [elpa] externals/transient 7811dcff82 226/366: Add /docs/*.info to .gitignore, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 8ad5fb83c4 227/366: Remove async-bytecomp kludge, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient d48f2451ec 232/366: transient--pre-exit: Don't log clearing of minibuffer, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 48335f8370 237/366: transient-status: Prevent use while minibuffer is active, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient baebe85ceb 239/366: manual: Deal with texinfo cross reference idiocy, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 8c28b8a4fa 242/366: transient-prefix: Do not initially bind SUFFIX-DESCRIPTION, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient cc16a5eaa7 244/366: transient-{, base-}map: Mention related keymaps in doc-string, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 39c536eab6 245/366: make: Add bump-version target, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 4da0fab7d9 246/366: Release version 0.3.1, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient c145229a89 247/366: Add missing argument to user-error, Jonas Bernoulli, 2022/01/25