Devon Ville
Devon Ville

Reputation: 2091

Cua-copy/paste and System clipboard in emacs

I've set this in emacs:

    (setq x-select-enable-clipboard t)

And it works just fine.

That is, until I copy something from within emacs using cua-copy (bound to C-c). Then, whenever I try to copy something from other programs and paste it into emacs, it keeps pasting the same entry it last copied using cua-copy.

The clipboard itself still works - the same entry is pasted regularly in any other program.

So far I tried defining several things but to no avail:

(setq x-select-enable-primary nil)                               
(setq x-select-enable-clipboard t)                               
(setq select-active-regions t)                                   
(global-set-key [mouse-2] 'mouse-yank-primary)                   
(setq yank-pop-change-selection t)                               
(setq interprogram-paste-function 'x-cut-buffer-or-selection-value)

Only when I forcefully paste from the clipboard using the command x-clipboard-yank does it resolve to its proper state, until I use cua-copy again.

Did anyone Ever encountered such a problem, or have any idea how to solve it?

Upvotes: 0

Views: 2138

Answers (2)

Carlos Cordoba
Carlos Cordoba

Reputation: 34156

This Answer doesn't work for Emacs 24. Adding these lines to my .emacs is what worked for me:

(setq select-active-regions nil)
(setq mouse-drag-copy-region t)

Upvotes: 1

kbrand
kbrand

Reputation: 98

I don't know enough about Emacs to offer any insights, but I can share what works for me (on Ubuntu) since i also have copy/paste bound to C-c/C-v with this in my ~/.emacs:

(cua-mode t)

And per this post: Integrate Emacs copy/paste with System copy/paste I have copying and pasting to/from Emacs without the problem you describe with these lines in ~/.emacs:

(setq x-select-enable-clipboard t)
(setq interprogram-paste-function 'x-cut-buffer-or-selection-value)

I see you already tried the two lines above, but did you try them alone without the other lines which might be conflicting with them?

Upvotes: 1

Related Questions