我在没有通过腻子的 X 窗口的远程机器上使用 Emacs。问题是从外部剪贴板(Shift+Ins)复制/粘贴很慢。
在 Vim 中,有一个选项 set paste
当我需要粘贴时,Emacs 是否有类似的功能?
我目前正在尝试一些解决方法:在粘贴之前,我将主要模式更改为 fundamental-mode
,然后我禁用模式行中显示的次要模式,以使副作用尽可能小。然而,它仍然比从 emacs -Q
开始时慢得多。 .
并且在显示区域(minibuffer)中,有以“matches ...”(括号等)开头的消息。
那么如何正确解决呢?
最佳答案
我不知道 Emacs 有这种“粘贴模式”。您可以从以下内容开始(新版本,使用单独的缓冲区,以便当前缓冲区的 *-change-functions 只在最后调用一次):
(defvar ttypaste-mode nil)
(add-to-list 'minor-mode-alist '(ttypaste-mode " Paste"))
(defun ttypaste-mode ()
(interactive)
(let ((buf (current-buffer))
(ttypaste-mode t))
(with-temp-buffer
(let ((stay t)
(text (current-buffer)))
(redisplay)
(while stay
(let ((char (let ((inhibit-redisplay t)) (read-event nil t 0.1))))
(unless char
(with-current-buffer buf (insert-buffer-substring text))
(erase-buffer)
(redisplay)
(setq char (read-event nil t)))
(cond
((not (characterp char)) (setq stay nil))
((eq char ?\r) (insert ?\n))
((eq char ?\e)
(if (sit-for 0.1 'nodisp) (setq stay nil) (insert ?\e)))
(t (insert char)))))
(insert-buffer-substring text)))))
关于vim - Emacs 中是否有 'set paste' 选项可以从外部剪贴板粘贴?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18691973/