[英]Prevent Emacs from modifying the OS X clipboard?
How can I prevent Emacs from ever modifying the OS X clipboard unless I explicitly ask it to? 除非明确要求,如何防止Emacs修改OS X剪贴板?
I've tried all of: 我已经尝试了所有:
(setq x-select-enable-clipboard nil)
(setq interprogram-cut-function nil)
(setq x-select-enable-primary nil)
(setq mouse-drag-copy-region nil)
Which does prevent kill/yank from modifying the clipboard, but selected text is still put on the clipboard. 确实可以防止kill / yank修改剪贴板,但是所选文本仍放在剪贴板上。
This is GNU Emacs.app on OS X. 这是OS X上的GNU Emacs.app。
What else should I try? 我还应该尝试什么?
After doing some digging into the same issue, I believe that the issue actually lies in the Emacs x-select-text
function, which explicitly ignores the value of x-select-enable-clipboard
on NextStep (and OS X is a NextStep). 在深入研究了相同的问题之后,我认为问题实际上出在Emacs的x-select-text
函数中,该函数显式忽略了NextStep上的x-select-enable-clipboard
值(而OS X是NextStep)。
I've "solved" this problem by replacing x-select-text
with a no-op function, then explicitly using ns-{get,set}pasteboard for interprogram{cut,paste}-function: 我通过用无操作功能替换x-select-text
来“解决”此问题,然后将ns- {get,set}粘贴板用于内部程序{cut,paste}-功能:
; 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)
Here is the original x-select-text
code: 这是原始的x-select-text
代码:
(defun x-select-text (text) "Select TEXT, a string, according to the window system. On X, if `x-select-enable-clipboard' is non-nil, copy TEXT to the clipboard. If `x-select-enable-primary' is non-nil, put TEXT in the primary selection. On MS-Windows, make TEXT the current selection. If `x-select-enable-clipboard' is non-nil, copy the text to the clipboard as well. On Nextstep, put TEXT in the pasteboard (`x-select-enable-clipboard' is not used)." (cond ((eq (framep (selected-frame)) 'w32) (if x-select-enable-clipboard (w32-set-clipboard-data text)) (setq x-last-selected-text text)) ((featurep 'ns) ; This is OS X ;; Don't send the pasteboard too much text. ;; It becomes slow, and if really big it causes errors. (ns-set-pasteboard text) (setq ns-last-selected-text text)) (t ;; With multi-tty, this function may be called from a tty frame. (when (eq (framep (selected-frame)) 'x) (when x-select-enable-primary (x-set-selection 'PRIMARY text) (setq x-last-selected-text-primary text)) (when x-select-enable-clipboard (x-set-selection 'CLIPBOARD text) (setq x-last-selected-text-clipboard text))))))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.