Backport Transient commit f69e1286

2025-03-12 f69e128654627275e7483a735f670bd53501999d
transient-suffix-object: Handle duplicated command invoked using mouse

Fixes bug#76680.
This commit is contained in:
Jonas Bernoulli 2025-03-15 20:29:58 +01:00
parent dcf3916e55
commit 91a9d02199
No known key found for this signature in database
GPG key ID: 230C2EFBB326D927

View file

@ -1573,6 +1573,10 @@ drawing in the transient buffer.")
This is bound while the suffix predicate is being evaluated, This is bound while the suffix predicate is being evaluated,
and while functions that return faces are being evaluated.") and while functions that return faces are being evaluated.")
(defvar transient--current-suffix nil
"The suffix currently being invoked using a mouse event.
Do not use this; instead use function `transient-suffix-object'.")
(defvar transient--pending-group nil (defvar transient--pending-group nil
"The group that is currently being processed. "The group that is currently being processed.
This is bound while the suffixes are drawn in the transient buffer.") This is bound while the suffixes are drawn in the transient buffer.")
@ -1656,6 +1660,7 @@ probably use this instead:
(cl-check-type command command)) (cl-check-type command command))
(cond (cond
(transient--pending-suffix) (transient--pending-suffix)
(transient--current-suffix)
((or transient--prefix ((or transient--prefix
transient-current-prefix) transient-current-prefix)
(let ((suffixes (let ((suffixes
@ -2544,7 +2549,8 @@ value. Otherwise return CHILDREN as is."
(transient--redisplay))))) (transient--redisplay)))))
(setq transient-current-prefix nil) (setq transient-current-prefix nil)
(setq transient-current-command nil) (setq transient-current-command nil)
(setq transient-current-suffixes nil))) (setq transient-current-suffixes nil)
(setq transient--current-suffix nil)))
(defun transient--post-exit (&optional command) (defun transient--post-exit (&optional command)
(transient--debug 'post-exit) (transient--debug 'post-exit)
@ -2577,6 +2583,8 @@ value. Otherwise return CHILDREN as is."
(setq transient--all-levels-p nil) (setq transient--all-levels-p nil)
(setq transient--minibuffer-depth 0) (setq transient--minibuffer-depth 0)
(run-hooks 'transient-exit-hook) (run-hooks 'transient-exit-hook)
(when command
(setq transient--current-suffix nil))
(when resume (when resume
(transient--stack-pop)))) (transient--stack-pop))))
@ -2748,12 +2756,12 @@ Use that command's pre-command to determine transient behavior."
(not (eq (posn-window (event-start last-command-event)) (not (eq (posn-window (event-start last-command-event))
transient--window))) transient--window)))
transient--stay transient--stay
(setq this-command (with-selected-window transient--window
(with-selected-window transient--window (let ((pos (if (mouse-event-p last-command-event)
(get-text-property (if (mouse-event-p last-command-event) (posn-point (event-start last-command-event))
(posn-point (event-start last-command-event)) (point))))
(point)) (setq this-command (get-text-property pos 'command))
'command))) (setq transient--current-suffix (get-text-property pos 'suffix))))
(transient--call-pre-command))) (transient--call-pre-command)))
(defun transient--do-recurse () (defun transient--do-recurse ()