GNU bug report logs -
#49253
27.2; Emacs non-responsive when pasting into terminal-mode
Previous Next
Reported by: Matt Bisson <bisson.m <at> gmail.com>
Date: Mon, 28 Jun 2021 15:23:02 UTC
Severity: normal
Found in version 27.2
Done: Eli Zaretskii <eliz <at> gnu.org>
Bug is archived. No further changes may be made.
Full log
Message #63 received at 49253 <at> debbugs.gnu.org (full text, mbox):
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 <at> debbugs.gnu.org
>> From: Matt Bisson <bisson.m <at> 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
This bug report was last modified 1 year and 151 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.