From c356d1bca13ef1dd78ec7e83a89936cc58553f75 Mon Sep 17 00:00:00 2001 From: Jonas Bernoulli Date: Fri, 12 Apr 2024 17:10:01 +0200 Subject: [PATCH] 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 083fcc04..6fdb108a 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 "" b)) (when-let ((b (keymap-lookup map "="))) (keymap-set map "" b)) (when-let ((b (keymap-lookup map "+"))) (keymap-set map "" b))