From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#49253: 27.2; Emacs non-responsive when pasting into terminal-mode Date: Sat, 09 Dec 2023 13:10:52 +0200 Message-ID: <838r63y6kj.fsf@gnu.org> References: <87r12lqmco.fsf@gnus.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3692"; mail-complaints-to="usenet@ciao.gmane.io" Cc: larsi@gnus.org, 49253@debbugs.gnu.org To: Matt Bisson , Jared Finder Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Dec 09 12:12:07 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 1rBvFf-0000hE-0h for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 09 Dec 2023 12:12:07 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBvFN-00070M-Lc; Sat, 09 Dec 2023 06:11:49 -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 1rBvFM-000709-Mw for bug-gnu-emacs@gnu.org; Sat, 09 Dec 2023 06:11: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 1rBvFM-0000fY-CH for bug-gnu-emacs@gnu.org; Sat, 09 Dec 2023 06:11:48 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rBvFZ-00017H-RP for bug-gnu-emacs@gnu.org; Sat, 09 Dec 2023 06:12:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 09 Dec 2023 11:12:01 +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.17021202904251 (code B ref 49253); Sat, 09 Dec 2023 11:12:01 +0000 Original-Received: (at 49253) by debbugs.gnu.org; 9 Dec 2023 11:11:30 +0000 Original-Received: from localhost ([127.0.0.1]:46893 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rBvF3-00016U-JT for submit@debbugs.gnu.org; Sat, 09 Dec 2023 06:11:30 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59216) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rBvF1-00016H-6J for 49253@debbugs.gnu.org; Sat, 09 Dec 2023 06:11:28 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBvEi-0008QS-22; Sat, 09 Dec 2023 06:11:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=hjbtOyR3uG7KPizZ6Ij1e+tLgo4J5At8p1/cWdIqOb8=; b=KcT0IQVPf4/RGWFFgeAG 7c0hnrlmMlfSaGW+dvIr19OJJVu2W9YmP7j4Eim3IPwHna7aL/ZIb8AtIYnsTtp5k93O6YA/OasFW qEuaEwC9Qip4Z2ZR4El1/gNaN8/pMhRbsQG6r3X1fyL4q/BpL+lELyPIPx+4RJN1C98ZFNZmenkIJ vKIn+oxPWK/+S0m4BvPSRQSAEcht1gJN5TLisHxaCWN0kbsf0hakS/lgPuH/1vTQwsuHK7CJMfbcL AI/kusud0l6DIhQ1WjVYOk72KnECNr7Kd/x6Q5EFVzVPOxLzmg0htHNtLciTDk4Kl4LVaT1sTBG55 OTxnkYdRcEpwkw==; In-Reply-To: (message from Matt Bisson on Fri, 8 Dec 2023 15:35:36 -0500) 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:275843 Archived-At: 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) > diff --git a/lisp/term/xterm.el b/lisp/term/xterm.el > index 5ed4e46e0a5..117bd131123 100644 > --- a/lisp/term/xterm.el > +++ b/lisp/term/xterm.el > @@ -149,7 +149,8 @@ xterm--suspend-tty-function > ;; looping on read-key and buffering input for later processing. > > (defun xterm-translate-bracketed-paste (_prompt) > - (vector (list 'xterm-paste (xterm--pasted-text)))) > + (unless (and (eq major-mode 'term-mode) (term-in-char-mode)) > + (vector (list 'xterm-paste (xterm--pasted-text))))) > > (defvar xterm-rxvt-function-map > (let ((map (make-sparse-keymap))) > > > On Fri, Dec 8, 2023 at 2:06 PM Matt Bisson wrote: > > > > I've finally had some time to look at this and what's happening is term/xterm.el is fighting with term.el. The bracketed paste command comes in with "\e[200~", arrives in term/xterm.el's xterm--pasted-text function first. It correctly reads the text from the clipboard. This is because xterm-translate-bracketed-paste is registered as a key binding for [xterm-paste] (or "\e[200~" on RXVT). > > > > Immediately thereafter, term--xterm-paste in term.el notices the [xterm-paste] key as well (it has also registered a binding for "raw" mode), and begins the same process of xterm--pasted-text. At this point, there's nothing to read from read-event, and it hangs for most-positive-fixnum (basically, forever). > > > > So this is the root cause analysis. Unfortunately, naively removing the key binding from term.el does not work, because the pasted text must be inserted via term-send-raw-string. > > > > -Matt > > > > On Sat, Jul 16, 2022 at 3:13 PM Matt Bisson wrote: > >> > >> For sure. Even in emacs 28.2, if I want to paste something into the terminal buffer, I have to switch to line mode, and back when I'm done. You just can't paste into the terminal buffer in terminal emacs in key mode. > >> > >> On Sat, Jul 16, 2022, 8:21 AM Lars Ingebrigtsen wrote: > >>> > >>> Matt Bisson writes: > >>> > >>> > I have observed this behavior from MacOS, with an Emacs running either > >>> > locally on MacOS, or over SSH (running on Linux). Without any > >>> > modifications, a -Q invocation causes "xterm--pasted-text: Failed > >>> > select: Invalid argument", but without -Q it simply hangs. > >>> > >>> (I'm going through old bug reports that unfortunately weren't resolved > >>> at the time.) > >>> > >>> Are you still seeing this problem in recent Emacs versions? > >>> > >>> -- > >>> (domestic pets only, the antidote for overdose, milk.) > >>> bloggy blog: http://lars.ingebrigtsen.no > > > >