How can I drag and drop text from one Emacs window into another?

1

1

Is it possible to select text in one Emacs window and then drag-drop it into another window of the same Emacs session?

If so, how can it be done?

Bleeding Fingers

Posted 2014-01-05T16:26:39.310

Reputation: 254

In what operating system? If Linux, which Desktop Environment or Window Manager? – terdon – 2014-01-05T16:27:43.693

I actually use both Windows 7 (Windows) and Ubuntu 13.10 (Linux). Is there a cross-platform solution? – Bleeding Fingers – 2014-01-05T16:29:27.600

Don't think so, but I'm not sure. Personally, I just copy/paste. – terdon – 2014-01-05T16:30:53.297

There are left / right mouse-up and mouse-down keys, so you could trigger paste with . . . mouse-up . . . and you could use (mouse-set-point event) before the paste -- take a look at mouse.el and mouse-copy.el and mouse-drag.el. – lawlist – 2014-01-05T19:44:09.340

Answers

1

Define "drag-drop it into another". Mouse-dragging in Emacs selects text -- see (emacs) Mouse Commands. Do you mean pasting selected text into a different Emacs window in the same Emacs session? In a different session?

If you just want to copy text from one Emacs window to another using the mouse, then select it and then use mouse-2 to paste it. To copy+paste to a different Emacs session, you might need to set some variables (depends on your platform/setup), to have mouse selection also copy the selction to the interprogram clipboard etc. See (emacs) Primary Selection.

On MS Windows, I use these settings, FWIW:

  • mouse-2 is bound to mouse-yank-at-click
  • select-active-regions is t
  • x-select-enable-clipboard is t
  • mouse-drag-copy-region is t

Drew

Posted 2014-01-05T16:26:39.310

Reputation: 1 898

I had discovered the same solution and was going to mention mouse-2 in an answer. Yes, same Emacs session. Question updated. – Bleeding Fingers – 2014-01-07T06:11:24.663