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: Fri, 8 Dec 2023 15:35:36 -0500 Message-ID: References: <87r12lqmco.fsf@gnus.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="2064"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 49253@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Dec 08 21:36:57 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 1rBhai-0000IU-UB for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 08 Dec 2023 21:36:57 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBhae-0006y1-BM; Fri, 08 Dec 2023 15:36:52 -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 1rBhac-0006xs-GG for bug-gnu-emacs@gnu.org; Fri, 08 Dec 2023 15:36:50 -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 1rBhab-0003SJ-7f for bug-gnu-emacs@gnu.org; Fri, 08 Dec 2023 15:36:49 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rBhao-00005P-7X for bug-gnu-emacs@gnu.org; Fri, 08 Dec 2023 15:37: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: Fri, 08 Dec 2023 20:37: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.170206778432691 (code B ref 49253); Fri, 08 Dec 2023 20:37:02 +0000 Original-Received: (at 49253) by debbugs.gnu.org; 8 Dec 2023 20:36:24 +0000 Original-Received: from localhost ([127.0.0.1]:46292 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rBhaB-0008VC-M6 for submit@debbugs.gnu.org; Fri, 08 Dec 2023 15:36:24 -0500 Original-Received: from mail-lf1-x12f.google.com ([2a00:1450:4864:20::12f]:46377) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rBhZv-0008TJ-1e for 49253@debbugs.gnu.org; Fri, 08 Dec 2023 15:36:22 -0500 Original-Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-50bf898c43cso2438916e87.1 for <49253@debbugs.gnu.org>; Fri, 08 Dec 2023 12:35:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702067748; x=1702672548; 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=Q0liWEYRNqw4J4luJ6YC85N8KYMERvvZotWEGFd3jK8=; b=Yaqsr3408i+c+eu1U814ZZKPN4Ij3XxKsA6YZ06t7mRUhxRvN2G8CYmtBCFrQbpkij h1MzhETv+ohM815XKzVcGAUSC6dM1RsNBLwt6/pujSSBkHOFOsNY06hxCBjQcANbDgch NqXtSXiAfM0zJHHbYIDpN8EYe7S1K+j3kqbi4iSzjuVTK6co7lHnUIU1NwgnM9Lnfy2k 5lyW9K3DG9VAYsmOGI8Mc6cgCMbg58CC1A9Apv5OnHuDKkiaRcB4PvO23Rm31KgT4r17 szCIHXO6iKSGQaPklPug/PBnJw5I4WxwT0fWpmFvNBehxqyiYz9FjKObBKDEuvZNCYDc yR2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702067748; x=1702672548; 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=Q0liWEYRNqw4J4luJ6YC85N8KYMERvvZotWEGFd3jK8=; b=bOFDwavvW1PIyKeYacXjeDjdNzzuqbxktKDobY8MAZxhojyu4BDUTFmWyXyZKzuzwg 56vykk0sSMlmSYUbhWG1j3+pZ/C4KK5P3U9JdUIur13QMdfvhvjS8AOgZdyp/msNZwva ExnoSMCtjfdxfDUKQAiYmpUjcRjCQzMx0at6zK3KYVc7n1iJt7zBYuiAzwGZFBM8TwOu k5I1DZJ7q1lM7SPGn9JGlVUSrClZ0HlAH3ZTJZCNj4sHq0M38VJnr4cqaFHxpA7RAZKf 98jcDO4Gv9QNtJLJUSLWUZxS55F5bBD6CB3B2tORXwyUgEdKcj7xM/W93pysGrbRKmyY zfPA== X-Gm-Message-State: AOJu0Yw6vvvvKncyY5S/h86JZafGmhL6lnV24S1U+IaCs+j/s8r473W3 zxyaBYXniM1BO1GTIx/aDL8Ch82u6ERme+EMr48= X-Google-Smtp-Source: AGHT+IH+o6o1CdNfN6tuzUYthzvjMK+Fx5ArVPPIyfPYgiu82OvlDl90NXdT2pR7gFFIbH68peL+KJxv8UAKjf/wpmc= X-Received: by 2002:a05:6512:218e:b0:50c:f12:6daf with SMTP id b14-20020a056512218e00b0050c0f126dafmr128400lft.69.1702067747452; Fri, 08 Dec 2023 12:35:47 -0800 (PST) In-Reply-To: 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:275805 Archived-At: 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=E2=80=AFPM Matt Bisson wro= te: > > I've finally had some time to look at this and what's happening is term/x= term.el is fighting with term.el. The bracketed paste command comes in wit= h "\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-tra= nslate-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-p= aste] key as well (it has also registered a binding for "raw" mode), and be= gins the same process of xterm--pasted-text. At this point, there's nothin= g 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 ins= erted via term-send-raw-string. > > -Matt > > On Sat, Jul 16, 2022 at 3:13=E2=80=AFPM Matt Bisson = wrote: >> >> For sure. Even in emacs 28.2, if I want to paste something into the ter= minal buffer, I have to switch to line mode, and back when I'm done. You j= ust 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 eithe= r >>> > 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