emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs-25 869092c: Bring back xterm pasting with middle mou


From: Paul Eggert
Subject: [Emacs-diffs] emacs-25 869092c: Bring back xterm pasting with middle mouse
Date: Sun, 22 May 2016 20:39:34 +0000 (UTC)

branch: emacs-25
commit 869092c9ed373e97f92c7f7518396e3fbdb24dd8
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>

    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.
---
 lisp/isearch.el    |    8 ++++++++
 lisp/term/xterm.el |   39 ++++++++++++++++++++-------------------
 2 files changed, 28 insertions(+), 19 deletions(-)

diff --git a/lisp/isearch.el b/lisp/isearch.el
index e4de0b6..7360a0b 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -510,6 +510,7 @@ This is like `describe-bindings', but displays only Isearch 
keys."
     ;; People expect to be able to paste with the mouse.
     (define-key map [mouse-2] #'isearch-mouse-2)
     (define-key map [down-mouse-2] nil)
+    (define-key map [xterm-paste] #'isearch-xterm-paste)
 
     ;; Some bindings you may want to put in your isearch-mode-hook.
     ;; Suggest some alternates...
@@ -2001,6 +2002,13 @@ is bound to outside of Isearch."
       (when (functionp binding)
        (call-interactively binding)))))
 
+(declare-function xterm--pasted-text "term/xterm" ())
+
+(defun isearch-xterm-paste ()
+  "Pull terminal paste into search string."
+  (interactive)
+  (isearch-yank-string (xterm--pasted-text)))
+
 (defun isearch-yank-internal (jumpform)
   "Pull the text from point to the point reached by JUMPFORM.
 JUMPFORM is a lambda expression that takes no arguments and returns
diff --git a/lisp/term/xterm.el b/lisp/term/xterm.el
index e06423c..19eb37a 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)))
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]