2

There is an functionality in XEmacs that if the user selects a region with the mouse while holding Ctrl, the selected region will be automatically pasted at the current cursor position.

In other words, if you need to quickly copy a short block of text from some open buffer to a new spot, you put the cursor there, and then do Ctrl-mouse-select and it works.

Unfortunately, I recently had to switch from XEmacs to GNU Emacs, and I'm looking to see if there is similar functionality there, or perhaps I could provide it with a custom module (I am very bad at Lisp, unfortunately).

N.N.
  • 8,336
  • 12
  • 54
  • 94
gt6989b
  • 4,125
  • 8
  • 46
  • 64

3 Answers3

2

You sure can, the functionality is bound to mouse button 3 if I'm not mistaken. I assume so, because clicking my mousewheel yanks what I've copied at the cursor.

And Mousewheel == mouse button 3 in most cases.

  1. Select using your mouse
  2. With your mouse button down, hit control
  3. Release your mouse button
  4. Hit mouse button 3
  5. Profit - selection yanked at your cursor

edit:

I found this on http://www.gnu.org/software/emacs/manual/html_node/emacs/Mouse-Commands.html

  • Mouse-1

    Move point to where you click (mouse-set-point).

  • Drag-Mouse-1

    Activate the region around the text selected by dragging, and copy it to the kill ring (mouse-set-region).

  • Mouse-2

    Yank the last killed text at the click position (mouse-yank-at-click).

  • Mouse-3

    If the region is active, move the nearer end of the region to the click position; otherwise, set mark at the current value of point and point at the click position. Save the resulting region in the kill ring; on a second click, kill it (mouse-save-then-kill).

martinjlowm
  • 871
  • 5
  • 8
  • Has no effect for me. It seems my button3 works as a scroller, but I can't make it work as paste at all. Also, the key mechanics I described for XEmacs is quite different (and it seems more convenient): Ctrl+mouse-select. Just making sure what I wrote was not misinterpreted... – gt6989b Mar 28 '12 at 03:28
  • which means you can't click the scroller? All the mice I've had the scroller could be clicked as well as scrolled forth and back. – martinjlowm Mar 28 '12 at 10:50
  • When I'm at my workplace, clicking the scroller works as paste, but your instructions yield yanking new text at the place of the mouse button 3 click (as it would behave if nothing was done with the Ctrl key - just select with the mouse and then mouse-3 pastes). When I'm at home, my mouse scroller scrolls ok, but when I click it, it does not work as paste at all. Not sure if something could be done about that, will find out, but what can I do to at least get the situation at my workplace (where scroller click registers as paste) resolved? thank you. – gt6989b Mar 28 '12 at 13:55
1

Put the following in your init file (.emacs):

(require 'mouse-copy)
(global-set-key [C-down-mouse-1] 'mouse-drag-secondary-pasting)

Once you restart Emacs, it should work just like you're used to in XEmacs--hold down Ctrl and the left mouse button, select your text, and when you release the mouse the text will be inserted at your current cursor position.

  • @Stefan recommended mouse-copy as well but I couldn't find any information on it (I got a "Can't find library mouse-copy") when trying to find it in Emacs, and I had byte-compiled source code in my distribution; I finally figured out how to use it here: http://www.opensource.apple.com/source/emacs/emacs-51/emacs/lisp/mouse-copy.el – Statisfactions Apr 25 '12 at 02:55
0

You might want to use mouse-copy.el which comes with Emacs.

Stefan
  • 27,908
  • 4
  • 53
  • 82