unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Jared Finder via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: larsi@gnus.org, Matt Bisson <bisson.m@gmail.com>, 49253@debbugs.gnu.org
Subject: bug#49253: 27.2; Emacs non-responsive when pasting into terminal-mode
Date: Sat, 09 Dec 2023 13:38:50 -0800	[thread overview]
Message-ID: <11108ebcb87fae9390410fa4f3355967@finder.org> (raw)
In-Reply-To: <838r63y6kj.fsf@gnu.org>

On 2023-12-09 03:10, Eli Zaretskii wrote:
> Jared, can I ask you to look into this and share your thoughts and
> comments to the proposed change?  TIA.
> 
>> Cc: 49253@debbugs.gnu.org
>> From: Matt Bisson <bisson.m@gmail.com>
>> Date: Fri, 8 Dec 2023 15:35:36 -0500
>> 
>> Right, so this silly little fix works, but it's an obvious hack.  I
>> clearly don't know enough about how the key-bindings work, because I
>> would have expected those set by term-mode to override those in the
>> global keybindings (from xterm.el), but they don't.  The xterm.el one
>> runs first.  Here's the diff:
>> 
>> diff --git a/lisp/term.el b/lisp/term.el
>> index 81746e0c20d..e047fa767e8 100644
>> --- a/lisp/term.el
>> +++ b/lisp/term.el
>> @@ -956,6 +956,7 @@ term-raw-map
>>      (define-key map [?\C- ] #'term-send-C-@)
>>      (define-key map [?\C-\M-/] #'term-send-C-M-_)
>>      (define-key map [?\C-\M- ] #'term-send-C-M-@)
>> +    (define-key map "\e[200~" #'term--xterm-paste)
>> 
>>      (when term-bind-function-keys
>>        (dotimes (key 21)

Thanks for the investigation.  I don't think this is the right approach. 
  The xterm escape codes all go through input-decode-map and I would 
expect to preserve that.

Looking at code, the current behavior in xterm.el is the following:

Step 1: \e[200~ is put on input-decode-map, using 
xterm-translate-backeted-paste to decode.

Step 2: The function xterm-translate-bracketed-paste reads the pasted 
text and creates an event (xterm-paste "PASTED TEXT HERE")

Step 3: Globally, the event xterm-paste is bound to the function also 
named xterm-paste, which grabs the pasted text and puts it on the kill 
ring, then runs the function insert-for-yank.

Step 3a: In Term mode, the event xterm-paste is instead bound to the 
function term--xterm-paste.  However, instead of reading the pasted text 
off the event, it calls (xterm-pasted-text) again.

I think the correct fix is to change term--xterm-paste to read the 
pasted text off of the event generated in Step 2.  So something like the 
following (a real fix would add error checking like in xterm-paste):

(defun term--xterm-paste (event)
   "Insert the text pasted in an XTerm bracketed paste operation."
   (interactive "e")
   (term-send-raw-string (nth 1 event)))

Matt, can you try this change locally?  It worked for me.

   -- MJF





  reply	other threads:[~2023-12-09 21:38 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-28 14:28 bug#49253: 27.2; Emacs non-responsive when pasting into terminal-mode Matt Bisson
2021-06-28 16:57 ` Eli Zaretskii
2021-06-28 17:18   ` Matt Bisson
2021-06-28 17:27     ` Eli Zaretskii
2021-06-28 17:30       ` Matt Bisson
2021-06-28 17:34         ` Matt Bisson
2021-06-28 17:59           ` Eli Zaretskii
2021-06-28 18:00         ` Eli Zaretskii
2021-06-28 18:11           ` Matt Bisson
2021-06-28 18:37             ` Eli Zaretskii
2021-06-28 20:09               ` Matt Bisson
2021-06-29 12:09                 ` Eli Zaretskii
2021-06-29 15:06                   ` Matt Bisson
2022-07-16 12:21 ` Lars Ingebrigtsen
2022-07-16 19:13   ` Matt Bisson
2023-12-08 19:06     ` Matt Bisson
2023-12-08 20:35       ` Matt Bisson
2023-12-09 11:10         ` Eli Zaretskii
2023-12-09 21:38           ` Jared Finder via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2023-12-11 16:10             ` Matt Bisson
2023-12-11 22:13               ` Jared Finder via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-13 19:26                 ` Matt Bisson
2023-12-16 12:46                 ` Eli Zaretskii

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=11108ebcb87fae9390410fa4f3355967@finder.org \
    --to=bug-gnu-emacs@gnu.org \
    --cc=49253@debbugs.gnu.org \
    --cc=bisson.m@gmail.com \
    --cc=eliz@gnu.org \
    --cc=jared@finder.org \
    --cc=larsi@gnus.org \
    /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).