I am using Emacs on a remote machine which has no X-window through putty. The problem is that the copy/paste from external clipboard(Shift+Ins) is quite slow.
In Vim, there is an option set paste
when I need to paste, then is there any similar function for Emacs?
I am currently trying some workarounds: before pasting, I change the major-mode into fundamental-mode
, then I disable the minor modes displayed in modeline to make the side effect as minimal as possible. However it is still much slower than when started with emacs -Q
.
And in the display area(minibuffer), there are messages starting with "matches ... "(parentheses, etc.).
So how to solve it properly?
I don't know of such a "paste mode" for Emacs. You could start with something like the following (new version, using a separate buffer, so that the current buffer's *-change-functions only get called once at the end):
(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)))))
If you prefer something a bit more tested and used:
;; enable clipboard interaction between emacs and system
(setq x-select-enable-clipboard t)
It works for me. A simple C-y and you are good to go! Hope that helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With