diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2016-05-22 13:38:53 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2016-05-22 13:39:30 -0700 |
commit | 869092c9ed373e97f92c7f7518396e3fbdb24dd8 (patch) | |
tree | ec04c978bdb685b671184daf30ac3a166050ebe5 /lisp/term/xterm.el | |
parent | 5ab083034ca221a7b4f00156a0efece84da999d8 (diff) | |
download | emacs-869092c9ed373e97f92c7f7518396e3fbdb24dd8.tar.gz emacs-869092c9ed373e97f92c7f7518396e3fbdb24dd8.tar.bz2 emacs-869092c9ed373e97f92c7f7518396e3fbdb24dd8.zip |
Bring back xterm pasting with middle mouse
Problem reported by Jan Synáček.
Solution suggested by Stefan Monnier (Bug#23519).
* lisp/isearch.el (isearch-mode-map): Add a binding for xterm-paste.
(xterm--pasted-text): New decl.
(isearch-xterm-paste): New function.
* lisp/term/xterm.el (xterm--pasted-text): New function,
taken from xterm-paste internals.
(xterm-paste): Use it.
Diffstat (limited to 'lisp/term/xterm.el')
-rw-r--r-- | lisp/term/xterm.el | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/lisp/term/xterm.el b/lisp/term/xterm.el index e06423ccfdd..19eb37a51d6 100644 --- a/lisp/term/xterm.el +++ b/lisp/term/xterm.el @@ -71,28 +71,29 @@ string bytes that can be copied is 3/4 of this value." (defconst xterm-paste-ending-sequence "\e[201~" "Characters send by the terminal to end a bracketed paste.") +(defun xterm--pasted-text () + "Handle the rest of a terminal paste operation. +Return the pasted text as a string." + (let ((end-marker-length (length xterm-paste-ending-sequence))) + (with-temp-buffer + (set-buffer-multibyte nil) + (while (not (search-backward xterm-paste-ending-sequence + (- (point) end-marker-length) t)) + (let ((event (read-event nil nil + ;; Use finite timeout to avoid glomming the + ;; event onto this-command-keys. + most-positive-fixnum))) + (when (eql event ?\r) + (setf event ?\n)) + (insert event))) + (let ((last-coding-system-used)) + (decode-coding-region (point-min) (point) (keyboard-coding-system) + t))))) + (defun xterm-paste () "Handle the start of a terminal paste operation." (interactive) - (let* ((end-marker-length (length xterm-paste-ending-sequence)) - (pasted-text (with-temp-buffer - (set-buffer-multibyte nil) - (while (not (search-backward - xterm-paste-ending-sequence - (- (point) end-marker-length) t)) - (let ((event (read-event - nil nil - ;; Use finite timeout to avoid - ;; glomming the event onto - ;; this-command-keys. - most-positive-fixnum))) - (when (eql event ?\r) - (setf event ?\n)) - (insert event))) - (let ((last-coding-system-used)) - (decode-coding-region - (point-min) (point) - (keyboard-coding-system) t)))) + (let* ((pasted-text (xterm--pasted-text)) (interprogram-paste-function (lambda () pasted-text))) (yank))) |