如何禁用Emacs Evil选择自动复制到剪贴板

jus*_*don 6 emacs clipboard evil-mode emacs24

与此问题相关:如何在emacs中禁用x粘贴

这适用于鼠标

(setq mouse-drag-copy-region nil)
Run Code Online (Sandbox Code Playgroud)

如何在emacs中为Evil模式执行相同的操作?

我在Mac OS上运行Emacs 24.2.91.

jus*_*don 0

我将其发送到邪恶模式邮件列表:

剪贴板历史记录和选择的问题

x-select-enable-clipboard 的当前实现调用 x-select-text 来进行所有光标移动和选择。这不是使用非邪恶模式时的行为。基本上,除非完成下面的补丁,否则 emacs 会接管我的剪贴板历史记录。我使用的是 Mac 并使用 Alfred 剪贴板历史记录。

我下面的粗体更改似乎解决了这个问题。

  1. 这是正确的做法吗?
  2. 是否有贡献信息页面解释如何为该项目做出贡献。我熟悉 github fork 和 pull requests。

谢谢,

贾斯汀

(setq x-select-enable-clipboard nil)
(defun evil-visual-update-x-selection (&optional buffer)
  "Update the X selection with the current visual region."
  (let ((buf (or buffer (current-buffer))))
    (when (buffer-live-p buf)
      (with-current-buffer buf
        (when (and (evil-visual-state-p)
                   (fboundp 'x-select-text)
                   (or (not (boundp 'ns-initialized))
                       (with-no-warnings ns-initialized))
                   (not (eq evil-visual-selection 'block)))
          ;; CHANGE
          ;; ONLY call x-select-text if x-select-enable-clipboard is true
          (if x-select-enable-clipboard
              (x-select-text (buffer-substring-no-properties
                              evil-visual-beginning
                              evil-visual-end))))))))
Run Code Online (Sandbox Code Playgroud)