3

This only occurs when I turn evil-mode on!

Whenever I make a selection, either through evil or the mouse, the selection gets automatically copied into the clipboard. I have set

(setq select-active-regions nil)
(setq mouse-drag-copy-region nil)
(setq x-select-enable-primary nil)

but that doesn't seem to do anything.

Any help? Please?

Edit: I am using the GUI version of the the build found at emacsformacosx.com

Max
  • 93
  • 7
  • 2
    Which flavor of emacs on OSX are you using? Are you running it within a terminal window? I was able to turn copy on selection on/off using `M-: (setq mouse-drag-copy-region t)` and `M-: (setq mouse-drag-copy-region nil)` using version 24.4 from http://emacsformacosx.com/ – Harvey Oct 26 '14 at 03:31
  • dumb question, but did you import `mouse.el`? – nicael Oct 26 '14 at 07:18
  • @Harvey But the default value of `mouse-drag-copy-region` is nil? I think the OP is perhaps using an emacs compiled for X11. He might want to switch to the nextstep version, found on the site you linked. Or use `configure --with-ns` if he is building from source. – Harald Hanche-Olsen Oct 26 '14 at 09:39
  • I'm using the version from emacsformacosx.com. In the GUI, not in the terminal. I haven't imported mouse.el - would that be necessary? – Max Oct 26 '14 at 12:27
  • @Max I can't reproduce this behaviour on OS X. Does it occur in a plain Emacs session, i.e. without your `init.el` and any packages? –  Oct 26 '14 at 13:43
  • @lunaryorn You are correct, without my init files this doesn't happen. Any idea how to pinpoint which package is responsible for that behaviour? – Max Oct 26 '14 at 14:19
  • @lunaryorn you were correct, thank you! It's an issue with evil-mode!Now I just have to figure out how to disable THAT – Max Oct 26 '14 at 14:35

2 Answers2

4

It turns out it was evil-mode that did that! The answer can be found here: https://stackoverflow.com/questions/17127009/how-to-disable-emacs-evil-selection-auto-copies-to-clipboard/23254728#23254728

This is the code snippet that solved it:

; Override the default x-select-text function because it doesn't
; respect x-select-enable-clipboard on OS X.
(defun x-select-text (text))
(setq x-select-enable-clipboard nil)
(setq x-select-enable-primary nil)
(setq mouse-drag-copy-region nil)

(setq interprogram-cut-function 'ns-set-pasteboard)
(setq interprogram-paste-function 'ns-get-pasteboard)
Max
  • 93
  • 7
  • This breaks evil for me. I now can't do anything that would usually add to the clipboard. ie "daw" now gives this error: "Symbol's function definition is void: ns-get-pasteboard" :( – Jack Casey May 13 '15 at 03:10
1

Came across this while Googling for a solution to this problem. What I found to work is part of the Spacemacs FAQ:

(fset 'evil-visual-update-x-selection 'ignore)

See also: https://emacs.stackexchange.com/a/15054/84