Sau khi thực hiện một số đào sâu vào vấn đề tương tự, tôi tin rằng vấn đề thực sự nằm trong Emacs x-select-text
chức năng, mà bỏ qua một cách rõ ràng giá trị của x-select-enable-clipboard
trên NextStep (và OS X là NextStep).
tôi đã "giải quyết" vấn đề này bằng cách thay thế x-select-text
với một hàm không-op, sau đó một cách rõ ràng bằng NS- {get, set} tông cho interprogram {cắt, dán} -function:
; 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)
Đây là mã số x-select-text
gốc:
(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))))))
Nguồn
2014-04-23 20:39:00
Bất kỳ lý do nào câu trả lời này tốt hơn? – justingordon
Nó khắc phục vấn đề của văn bản được lựa chọn được đặt trên bàn phím ở khắp mọi nơi, không chỉ từ Evil. –
Đối với tôi những ns-set-pasteboard, ns-get-pasteboard dường như không tồn tại vì vậy tôi nhận được lỗi khi cắt văn bản vv (emacs-mac) –