I have (cua-mode t) in my .emacs, so that C-c is copy and C-v is paste just like most other programs on my desktop (Ubuntu, Gnome, Linux). However, Emacs does not seem to share the clipboard/copy buffer with other programs.
For example, if I C-c in Firefox I can S-C-v to paste into a terminal or C-v to paste into gedit. However, if I C-v (or C-y) in emacs, I do not get what I copied from Firefox.
Is there any way to make this work? Is there another command I can use to access the system's copy-paste buffer?
Maybe this EmacsWiki page will help, especially the section where
clipboard-kill-region
,clipboard-kill-ring-save
, andclipboard-yank
are mentioned.I had the same problem. I added this to my .emacs file:
Now Ctrl-C and Ctrl-v between Emacs and other applications work fine. Source: Ubuntu Forums
See
clipboard-yank
andclipboard-kill-region
in the clipboard section of the manual.This works on my machine:
I solve this problem with
autocutsel
, which works withemacs
and the rest of my Ubuntu system too.I use the following commands (run once, usually invoked by my window manager's "startup" mechanism, or
~/.xsession
):The first instance of
autocutsel
does the following:However there's usually a third clipboard, called
PRIMARY
, which the second instance ofautocutsel
is used to sync with the other two.The advantages of this are that the three main clipboards are unified, so that pasting current selection via middle-click or CUA-style copy/paste with CTRL-C and CTRL-V all work together.
The main downside of this approach is that any automatic highlighting of text (such as double-clicking to highlight a word in emacs, or clicking the BlockQuote icon in a StackOverflow edit field) will obliterate your copy buffer instantly. To work around this, I use a clipboard history recorder such as
glipper
, which also conveniently records all clipboard content and allows me to retrieve lost clipboard contents in such circumstances. It can take a little getting-used-to and works well for me. As an alternative, you could experiment with the-pause
option, which waits for some period of time before taking the selection, which may be long enough to deselect or delete any auto-selected text. I wasn't able to get results that worked well enough for me, though.Note that this solution doesn't require any special
emacs
configuration, which I use with cua-mode enabled.