transient
transient copied to clipboard
Allow copying text from the transient buffer
A lot of text in Emacs cannot be simply copied: margin, header-line, mode-line, menu, and echo area. The latter including partial key sequences. Despite that the fact that Transient also comes with UI text that cannot be copied is used as an argument why it strays from The Way of Emacs.
FWIW I used to use an advice like this to copy a transient buffer contents. But I agree that it could be simpler.
Probably you have some ideas already, but a simple suggestion would be to just bind drag-mouse as a suffix to copy the text. I don't know if there are more reasons to select text in a transient.
Ah okay, that does not seem to work as expected :grin:
(transient-define-prefix test-transient ()
"Test"
:transient-suffix 'transient--do-call
:transient-non-suffix 'transient--do-stay
["Commands"
[([drag-mouse-1] "Copy text" copy-text)]]
[("q" "Quit" transient-quit-one)])
(transient-define-suffix copy-text (beg end)
(interactive "r")
(copy-region-as-kill beg end))
For evil users I have found this, which works simple and effective.
The easiest way is:
(keymap-set transient-predicate-map
"<mouse-set-region>"
#'transient--do-stay)
I've just added a FAQ entry about that.