branch: externals/transient
commit c356d1bca13ef1dd78ec7e83a89936cc58553f75
Author: Jonas Bernoulli <jo...@bernoul.li>
Commit: Jonas Bernoulli <jo...@bernoul.li>

    transient--make-transient-map: Relax conflicts of inapt suffixes
    
    When a inapt suffix conflicts with an apt suffix, bind the latter.
    
    When two apt suffixes conflict, the later one wins by default, as
    before, though, with the above type of conflict resolved,  we might
    change that in the future.
---
 lisp/transient.el | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/lisp/transient.el b/lisp/transient.el
index 083fcc0429..6fdb108a27 100644
--- a/lisp/transient.el
+++ b/lisp/transient.el
@@ -1865,15 +1865,19 @@ of the corresponding object."
           (setq key (save-match-data
                       (funcall transient-substitute-key-function obj)))
           (oset obj key key))
-        (let ((kbd (kbd key))
-              (cmd (oref obj command)))
-          (when-let ((conflict (and transient-detect-key-conflicts
-                                    (transient--lookup-key map kbd))))
-            (unless (eq cmd conflict)
-              (error "Cannot bind %S to %s and also %s"
-                     (string-trim key)
-                     cmd conflict)))
-          (define-key map kbd cmd))))
+        (let* ((kbd (kbd key))
+               (cmd (oref obj command))
+               (alt (transient--lookup-key map kbd)))
+          (cond ((not alt)
+                 (define-key map kbd cmd))
+                ((eq alt cmd))
+                ((transient--inapt-suffix-p obj))
+                ((transient--inapt-suffix-p (transient-suffix-object alt))
+                 (define-key map kbd cmd))
+                (transient-detect-key-conflicts
+                 (error "Cannot bind %S to %s and also %s"
+                        (string-trim key) cmd alt))
+                ((define-key map kbd cmd))))))
     (when-let ((b (keymap-lookup map "-"))) (keymap-set map "<kp-subtract>" b))
     (when-let ((b (keymap-lookup map "="))) (keymap-set map "<kp-equal>" b))
     (when-let ((b (keymap-lookup map "+"))) (keymap-set map "<kp-add>" b))

Reply via email to