Skip to content

Commit

Permalink
transient--make-transient-map: Relax conflicts of inapt suffixes
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tarsius committed Apr 12, 2024
1 parent 8c0a3ac commit c356d1b
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions lisp/transient.el
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit c356d1b

Please sign in to comment.