From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Matt Bisson Newsgroups: gmane.emacs.bugs Subject: bug#49253: 27.2; Emacs non-responsive when pasting into terminal-mode Date: Mon, 11 Dec 2023 11:10:22 -0500 Message-ID: References: <87r12lqmco.fsf@gnus.org> <838r63y6kj.fsf@gnu.org> <11108ebcb87fae9390410fa4f3355967@finder.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40803"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , larsi@gnus.org, 49253@debbugs.gnu.org To: Jared Finder Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Dec 11 17:11:17 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rCisH-000AOu-By for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 11 Dec 2023 17:11:17 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rCirq-0006C0-CW; Mon, 11 Dec 2023 11:10:50 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rCiro-0006Bg-AL for bug-gnu-emacs@gnu.org; Mon, 11 Dec 2023 11:10:48 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rCirn-0005WI-In for bug-gnu-emacs@gnu.org; Mon, 11 Dec 2023 11:10:48 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rCis2-00081Y-2Z for bug-gnu-emacs@gnu.org; Mon, 11 Dec 2023 11:11:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Matt Bisson Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 11 Dec 2023 16:11:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49253 X-GNU-PR-Package: emacs Original-Received: via spool by 49253-submit@debbugs.gnu.org id=B49253.170231105730829 (code B ref 49253); Mon, 11 Dec 2023 16:11:02 +0000 Original-Received: (at 49253) by debbugs.gnu.org; 11 Dec 2023 16:10:57 +0000 Original-Received: from localhost ([127.0.0.1]:54379 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rCirx-000819-5w for submit@debbugs.gnu.org; Mon, 11 Dec 2023 11:10:57 -0500 Original-Received: from mail-lj1-x22d.google.com ([2a00:1450:4864:20::22d]:57821) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rCiru-00080t-I8 for 49253@debbugs.gnu.org; Mon, 11 Dec 2023 11:10:55 -0500 Original-Received: by mail-lj1-x22d.google.com with SMTP id 38308e7fff4ca-2cb20c82a79so43392471fa.3 for <49253@debbugs.gnu.org>; Mon, 11 Dec 2023 08:10:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702311034; x=1702915834; darn=debbugs.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=dWbBsKcubFXSBRzw+Q8+pVQNmcaY3bmARhBPk8XvFS8=; b=Y/mQyqkpcOPt399k/7ypNPccd/Mp//6Oz3XKjz0vVxg9K/kPhtxzLV/JVx0H2pobcb MVmAE1uh66BLpc0CoW0OQQ6TMCVyPjigH9EhgQxIWOmL2HugP+C6tUj6oZNxXDmYBYpD r5hrsQFeXIqPjVizuSV1oKmISzseT2X8zv3AVODhipsSc9ZRaquuF2SmtqLe7nbVy0Z5 7G0rYV2Lt3X4ClF5KVq6fQAGnBFCMQiFuWdDDXm6e3aFuGX49OSa43egLD/gR+VyUUzO cafKxCmXWrXjOHusJ7c1esn9GeIirTXNZjQWVJx3ZP6uGmaGWk0DE85HF7eL8hvTTFGd +tew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702311034; x=1702915834; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dWbBsKcubFXSBRzw+Q8+pVQNmcaY3bmARhBPk8XvFS8=; b=pY2DvV50Idl3di8Ob5KOziY86ToiY/jnrNGaqXkKn7jqXJRD01uI1jN8A3EU5cz7Q3 4h4UoeX52zIDEOmJh7fUk2efFLjpiHBlLUv5yy7JP1qYZ9d9at3GD8Yf3qceCLjte9o2 1tOB2MK0SaJHrwoyj5LyYiTGLPZ5wSbwKG9Xj15dtbwa2YwAMTjMT5q8ENr5zzO1neMu 58rj/yGe2l3fF7PN4Qw0Wi9n7wVIMu1nwB5J9bIiIpPRZ28ZbkGoK09281wA0BIAc7fR cWcxgMdfE8Gnu1SLHaVsm9J8h+vG27GcjdHEhzMoXOkrSMUO/1W+mSYausrStG9FIfIG Cuyw== X-Gm-Message-State: AOJu0YxgBAIYtOaIgYHDIYKEMo2VKqzZ+J+w+E+iT+CxEk980gxEywCV yTWf4WC4lsXeAuoSpMewvk8lE7E677nKYPDvqbg= X-Google-Smtp-Source: AGHT+IHmEX9svf6l6iMawJ3czFgOFOOq4thc7Aq84TXLuVYmLXp2YvOek7IZvqSfjqdP0sOYdTI9y6d5DQkorPCtVWs= X-Received: by 2002:a05:651c:88:b0:2ca:41b:74db with SMTP id 8-20020a05651c008800b002ca041b74dbmr1622048ljq.47.1702311033318; Mon, 11 Dec 2023 08:10:33 -0800 (PST) In-Reply-To: <11108ebcb87fae9390410fa4f3355967@finder.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:275992 Archived-At: TL;DR: It works! > I don't think this is the right approach. Totally! :) The patch was definitely not a serious suggestion of what should be submitted, but just a demonstration that the interplay between the two functions is causing the issue, and it can be solved by touching only that. I haven't built up the knowledge of how these events function like you have, and was hoping you'd teach me a bit in response, and you did! The solution works for XTerm pasting into a scratch buffer, into a term buffer with line-mode enabled, and most notably, with char-mode enabled. As I use term-mode for basically everything I do in a terminal on a daily basis, this will make my life significantly nicer, so thanks for the fix! On Sat, Dec 9, 2023 at 4:38=E2=80=AFPM Jared Finder wrot= e: > > 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 > >> 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