2013-06-15 36 views

Trả lời

0

tôi gửi này cho ác-mode mailing list:

Vấn đề với Lịch sử Clipboard và lựa chọn

Việc thực hiện các cuộc gọi x-select-enable-clipboard của x-select-văn bản cho tất cả các phong trào con trỏ với một lựa chọn. Đây không phải là hành vi khi sử dụng chế độ không ác. Về cơ bản, emacs mất lịch sử clipboard của tôi trừ khi các bản vá dưới đây được thực hiện. Tôi đang ở trên máy Mac và sử dụng lịch sử khay nhớ tạm của Alfred.

Thay đổi của tôi dưới dạng chữ đậm dường như khắc phục được sự cố này.

  1. Đây có phải là điều đúng để làm không?
  2. Có trang thông tin đóng góp giải thích cách đóng góp cho dự án này không. Tôi quen thuộc với github dĩa và kéo yêu cầu.

Cảm ơn,

Justin

(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)))))))) 
2

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)))))) 
+0

Bất kỳ lý do nào câu trả lời này tốt hơn? – justingordon

+0

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. –

+0

Đố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) –

3

Đến đây trong khi Googling giải pháp cho vấn đề này. Những gì tôi tìm được để làm việc là một phần của số Spacemacs FAQ:

(fset 'evil-visual-update-x-selection 'ignore) 
Các vấn đề liên quan