From: Paul Eggert <eggert@cs.ucla.edu>
To: Stefan Monnier <monnier@IRO.UMontreal.CA>
Cc: Kaushal Modi <kaushal.modi@gmail.com>,
23519-done@debbugs.gnu.org, Jan Synacek <jsynacekf@redhat.com>
Subject: bug#23519: 25.0.93; pasting with the middle mouse button while searching doesn't work
Date: Sun, 22 May 2016 13:49:40 -0700 [thread overview]
Message-ID: <57421B64.4070604@cs.ucla.edu> (raw)
In-Reply-To: <m6feg97zqf0.fsf@jsynacek-ntb.brq.redhat.com>
[-- Attachment #1: Type: text/plain, Size: 203 bytes --]
> isearch currently doesn't have a binding for
> xterm-paste. We should add one, just like we added one to global-map.
Thanks, I did that by installing the attached patch into the emacs-25 branch.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Bring-back-xterm-pasting-with-middle-mouse.patch --]
[-- Type: text/x-diff; name="0001-Bring-back-xterm-pasting-with-middle-mouse.patch", Size: 4282 bytes --]
From 3ca5d39a25a6f56b5946c85fa9bdc722ee0c9546 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Sun, 22 May 2016 13:38:53 -0700
Subject: [PATCH] Bring back xterm pasting with middle mouse
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
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 @@ isearch-mode-map
;; 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 @@ isearch-mouse-2
(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 @@ xterm-max-cut-length
(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)))
--
2.5.5
prev parent reply other threads:[~2016-05-22 20:49 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-12 7:28 bug#23519: 25.0.93; pasting with the middle mouse button while searching doesn't work Jan Synáček
2016-05-12 8:00 ` Eli Zaretskii
2016-05-12 8:04 ` Jan Synacek
2016-05-12 8:23 ` Eli Zaretskii
2016-05-12 8:42 ` Jan Synacek
2016-05-12 9:03 ` Eli Zaretskii
2016-05-16 8:16 ` Jan Synacek
2016-05-18 20:13 ` Kaushal Modi
2016-05-19 0:46 ` Stefan Monnier
2016-05-22 20:49 ` Paul Eggert [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=57421B64.4070604@cs.ucla.edu \
--to=eggert@cs.ucla.edu \
--cc=23519-done@debbugs.gnu.org \
--cc=jsynacekf@redhat.com \
--cc=kaushal.modi@gmail.com \
--cc=monnier@IRO.UMontreal.CA \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).