summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorJonas Bernoulli <jonas@bernoul.li>2025-03-12 15:53:43 +0100
committerJonas Bernoulli <jonas@bernoul.li>2025-03-12 15:53:43 +0100
commit4a06aeb0f7bd279f76bdf619a7852a4725bf4cc5 (patch)
tree57a90548434c46714fd19fa58589124274977a9e /lisp
parentf69e128654627275e7483a735f670bd53501999d (diff)
transient-suffix-object: Not finding any suffix isn't an error
Diffstat (limited to 'lisp')
-rw-r--r--lisp/transient.el38
1 files changed, 20 insertions, 18 deletions
diff --git a/lisp/transient.el b/lisp/transient.el
index 6f63f3e..f9464ff 100644
--- a/lisp/transient.el
+++ b/lisp/transient.el
@@ -1859,22 +1859,25 @@ probably use this instead:
this-command))))
(or transient--suffixes
transient-current-suffixes))))
- (or (if (cdr suffixes)
- (cl-find-if
- (lambda (obj)
- (equal (listify-key-sequence (transient--kbd (oref obj key)))
- (listify-key-sequence (this-command-keys))))
- suffixes)
- (car suffixes))
- ;; COMMAND is only provided if `this-command' is meaningless, in
- ;; which case `this-command-keys' is also meaningless, making it
- ;; impossible to disambiguate redundant bindings.
- (if command
- (car suffixes)
- ;; TODO Decide whether it is legimate to use this function
- ;; as a predicate, and also whether to return an object for
- ;; suffixes common to all prefixes. See #29 and #337.
- (error "BUG: Cannot determine suffix object")))))
+ (cond
+ ((length= suffixes 1)
+ (car suffixes))
+ ((cl-find-if (lambda (obj)
+ (equal
+ (listify-key-sequence (transient--kbd (oref obj key)))
+ (listify-key-sequence (this-command-keys))))
+ suffixes))
+ ;; COMMAND is only provided if `this-command' is meaningless, in
+ ;; which case `this-command-keys' is also meaningless, making it
+ ;; impossible to disambiguate bindings for the same command.
+ (command (car suffixes))
+ ;; If COMMAND is nil, then failure to disambiguate likely means
+ ;; that there is a bug somewhere.
+ ((length> suffixes 1)
+ (error "BUG: Cannot unambigiously determine suffix object"))
+ ;; It is legimate to use this function as a predicate of sorts.
+ ;; `transient--pre-command' and `transient-help' are examples.
+ (t nil))))
((and-let* ((obj (transient--suffix-prototype (or command this-command)))
(obj (clone obj)))
(progn
@@ -2541,8 +2544,7 @@ value. Otherwise return CHILDREN as is.")
((not (transient--edebug-command-p))
(setq this-command 'transient-undefined))))
((and transient--editp
- ;; See TODO in that function.
- (ignore-errors (transient-suffix-object))
+ (transient-suffix-object)
(not (memq this-command '(transient-quit-one
transient-quit-all
transient-help))))