Search code examples
emacsxemacs

Pasting with mouse-select in GNU Emacs


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


Solution

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