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

  • 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 emacsformacosx.com – Harvey Oct 26 '14 at 3:31
  • dumb question, but did you import mouse.el? – nicael Oct 26 '14 at 7: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 9: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? – lunaryorn Oct 26 '14 at 13:43
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)
  • 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 3: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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.