In vim you can explicitly copy/paste to/from the X11 selection buffer and clipboard buffer by using "*y
and "+y
, respectively.
My emacs is (apparently -- it's not intentional on my part) set up to use the selection buffer for C-w
, C-y
, and friends.
Are there functions that I can call, analogous to kill-region
and yank
which use the clipboard buffer?
To be clear, I want selective access to both buffers at the same time. Based on some quick web searches, it looks like there are configuration variables I can set which will globally change yank
to use one buffer or the other. I want to be able to select, just like vim's *
and +
registers allow.
(Hopefully I've gotten the terminology right: when I say "selection buffer", I mean the buffer where you can highlight text with the mouse and middle-click to paste. When I say "clipboard buffer", I mean the place where text goes when copied by ctrl-c in non-emacs apps.)
Edit: bzg's answer is really close.
In gnome-terminal, I select ~/projects with the mouse, then right-mouse -> copy. Then I select /home. Still in gnome-terminal, when I do:
- middle-mouse: /home
- right-mouse -> paste: ~/projects
When I move into emacs and do:
- middle-mouse: /home
- M-y (yank): /home
- C-S-y (my-yank): ~/projects
Great! yank
uses the selection buffer and my-yank
uses the clipboard.
Now, still in emacs, I do:
- C-SPC M-f M-f C-w (make region "regular kill", and kill it)
then go to gnome-terminal and do:
- middle-mouse: "regular kill"
- right-mouse -> paste: ~/projects
Great! Only the selection buffer was changed, not the clipboard.
Then, back in emacs, I do:
- C-SPC M-f M-f C-S-w (make region "my kill", and kill it)
then go to gnome-terminal and do:
- middle-mouse: regular kill
- right-mouse -> paste: ~/projects
That's wrong, the clipboard buffer should contain "my kill".
My interprogram-cut-function
is x-select-text
. My x-select-enable-clipboard
is nil
.