0

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?

Devon Ville
  • 2,001
  • 2
  • 19
  • 32

2 Answers2

1

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?

Community
  • 1
  • 1
kbrand
  • 98
  • 1
  • 6
1

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)
Community
  • 1
  • 1
Carlos Cordoba
  • 33,273
  • 10
  • 95
  • 124
  • Nice, the sooner the better. – Devon Ville Jun 13 '13 at 23:02
  • @Carlos Strange, works as seamlessly for me in Emacs 24 as it did in Emacs 23. – kbrand Jul 04 '13 at 13:50
  • I don't know but the selected answer didn't work for me and it was driving me crazy! I spent several hours looking for a solution until I found my proposed answer [here](http://www.zzzxo.com/q/answers-how-to-to-combine-emacs-primary-clipboard-copy-and-paste-behavior-on-ms-windows-13036155.html). So I thought it could be useful for someone else :) – Carlos Cordoba Jul 04 '13 at 16:21