transient icon indicating copy to clipboard operation
transient copied to clipboard

Allow copying text from the transient buffer

Open tarsius opened this issue 3 years ago • 4 comments

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.

tarsius avatar Aug 07 '21 09:08 tarsius

FWIW I used to use an advice like this to copy a transient buffer contents. But I agree that it could be simpler.

pkryger avatar Aug 07 '21 11:08 pkryger

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.

dalanicolai avatar Aug 17 '21 07:08 dalanicolai

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))

dalanicolai avatar Aug 17 '21 07:08 dalanicolai

For evil users I have found this, which works simple and effective.

dalanicolai avatar Sep 02 '21 21:09 dalanicolai

The easiest way is:

  (keymap-set transient-predicate-map
              "<mouse-set-region>"
              #'transient--do-stay)

I've just added a FAQ entry about that.

tarsius avatar Mar 04 '23 11:03 tarsius