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: Wed, 13 Dec 2023 14:26:17 -0500 Message-ID: References: <87r12lqmco.fsf@gnus.org> <838r63y6kj.fsf@gnu.org> <11108ebcb87fae9390410fa4f3355967@finder.org> <5d8850165ca6f3d344e764397339abf0@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="11121"; 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 Wed Dec 13 20:27:04 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 1rDUsp-0002db-03 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 13 Dec 2023 20:27:03 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rDUsb-00081b-7E; Wed, 13 Dec 2023 14:26: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 1rDUsZ-0007zo-HM for bug-gnu-emacs@gnu.org; Wed, 13 Dec 2023 14:26:47 -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 1rDUsY-0002GR-89 for bug-gnu-emacs@gnu.org; Wed, 13 Dec 2023 14:26:47 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rDUso-0007ze-AV for bug-gnu-emacs@gnu.org; Wed, 13 Dec 2023 14:27: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: Wed, 13 Dec 2023 19:27: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.170249561430693 (code B ref 49253); Wed, 13 Dec 2023 19:27:02 +0000 Original-Received: (at 49253) by debbugs.gnu.org; 13 Dec 2023 19:26:54 +0000 Original-Received: from localhost ([127.0.0.1]:59694 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rDUsg-0007yp-2x for submit@debbugs.gnu.org; Wed, 13 Dec 2023 14:26:54 -0500 Original-Received: from mail-lj1-x22d.google.com ([2a00:1450:4864:20::22d]:51378) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rDUsc-0007yb-De for 49253@debbugs.gnu.org; Wed, 13 Dec 2023 14:26:53 -0500 Original-Received: by mail-lj1-x22d.google.com with SMTP id 38308e7fff4ca-2ca00dffc23so93205211fa.2 for <49253@debbugs.gnu.org>; Wed, 13 Dec 2023 11:26:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702495588; x=1703100388; 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=hsm7Hd1tfmXNjP7ExDTGzsMsdLsbSJzwV9FaijljnYY=; b=KDjOXoxPgLYptDnRdSHY8/HpvEBsh7dn4eKXB/4O4xMdxyAM/8/fQJhmE9ryNkWEx1 Y0W4Na50q72Nj1x+9MKda46ySJNTxk49ntrAOFxUXgoBl18PBvKtUYcCcMOzSHEQhhH1 +zcA1x4z57QTwuHlw6nCZuwFF8wAUNSQnKI/RDgVeDzw/KEI42U2hbSdbJk1u58kWfbP DJCZT03F0Fl0iBH97OnVJBHsVFDLct1nKmFQNq1RqNyJz2qVxUROgrBENyAQk0VB8bil uElZ1Ix6hM+49vqAL2ZlAoEf/gUL8qV0PXZDrKqeAH2xWOu6cY8kOV2U0b8htFoadgrv fA3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702495588; x=1703100388; 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=hsm7Hd1tfmXNjP7ExDTGzsMsdLsbSJzwV9FaijljnYY=; b=H4nY/977DTWQfmeJLNr9J9diAEjCEJyGRFg1gSinwlCco4aVsLsySdk14uqxMlTnG3 U/hpcuqCslckhJuEmbHx83RQj6PLf9VP5uG8T0waWPN8mLll84aeBWIUWVF+rao83BqP w9ml8RCNyuswdDScc3soqcJqFYDNhXDsgBvsLpag1qtJREwLJOxXk/L3ysoHmHl1ksPZ edqhDTCY4Kvu6M6Wozv7BgG4BNfOv5fDzOR/lTcSXevQX4n5yqzHwy3XP7nSxGhPzXKM xkAqstB+w5HaXM7rTC9DUZRHh/kYOK+mTpO4TprUPpjVOScgZLQj5505odVH+xM95Qqb rf1Q== X-Gm-Message-State: AOJu0YxTkwiNzlNBA2lQy7LQnNbmAcJLL/TZCnwIXuuf2VJX6kKhinaf xt5EtpcQ+PAeaR7l8ls3QTOIcYhN5rcq7uHjVuc= X-Google-Smtp-Source: AGHT+IGCeaAaRTlhJwYTB4OL4lSXN4Qajcr7utoiGGbKcbNy/SZIpuXClKbj6Am58erBC8rs1dojTBjpSHJ8VPmckes= X-Received: by 2002:a05:6512:3c87:b0:50e:d97:fd25 with SMTP id h7-20020a0565123c8700b0050e0d97fd25mr1327363lfv.73.1702495588043; Wed, 13 Dec 2023 11:26:28 -0800 (PST) In-Reply-To: <5d8850165ca6f3d344e764397339abf0@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:276154 Archived-At: I definitely want to give the feedback here that this was an outstanding explanation of what's going on inside Emacs, and thanks very much for taking the time to write it. I didn't even know of the existence of some of these maps, and I now know not only that, but their intended purpose. Again, thanks a lot for this! On Mon, Dec 11, 2023 at 5:13=E2=80=AFPM Jared Finder wro= te: > > On 2023-12-11 08:10, Matt Bisson wrote: > > TL;DR: It works! > > Thank you for the testing! > > Eli, I think the fully correct definition for term--xterm-paste is the > following, which has additional error checking: > > (defun term--xterm-paste (event) > "Insert the text pasted in an XTerm bracketed paste operation." > (interactive "e") > (unless (eq (car-safe event) 'xterm-paste) > (error "term--xterm-paste must be found to xterm-paste event")) > (let ((str (nth 1 event))) > (unless (stringp str) > (error "term--xterm-paste provided event does not contain paste > text")) > (term-send-raw-string str))) > > >> 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! > > No worries! I hope I didn't come across as judgemental here. :) If you > want a bit more detail around the architecture here, read on (Eli, > please correct if I get anything wrong): > > In Emacs, in addition to the local and global keymaps, there are also > translation keymaps. > (https://www.gnu.org/software/emacs/manual/html_node/elisp/Translation-Ke= ymaps.html) > The docs are accurate but a bit hard to understand without concrete > examples. So let me provide an example for each of the translation > keymaps. There are three of them: > > 1. input-decode-map. This exists to translate terminal escape sequences > into the their proper events. That can be for keys (like the PF1 key > mentioned in the docs) but it also an be for mouse clicks or the xterm > paste operation. > > EXAMPLE: > This bug! In this bug, input-decode-map is what translates the > character sequence "ESC [ 2 0 0 ~ PASTED TEXT HERE ESC [ 2 0 1 ~" into > a single event, (xterm-paste "PASTED TEXT HERE"). It does > this by mapping "ESC [ 2 0 0 ~" to a function that reads until > encountering the "ESC [ 2 0 1 ~" sequence and returns that new event. > > 2. (local-)function-key-map. This exists to rename keys to more > preferred names that allow keybindings to be shared. The docs say "the > remapping only applies if the original key sequence would otherwise not > have any binding", this is to allow you to use the native keynames on > your keyboard if you do want to distinguish. > > EXAMPLE: > Many keyboards have a separate keypad number area. These keys get their > own events, e.g. "" for the zero character on the keypad. Emacs > uses function-key-map to translate "" into "0", so pressing the > keypad 0 acts the same as the number row 0. If you wanted to map the > keypad numbers to a different set of commands, you can still do so with > the original "" key. If you do so, that also implicitly overrides > this translation. > > 3. key-translation-map. I've never actually used this directly so I'm > not entirely clear on its intent. The docs make it sound like it is > intended for changing keyboard layouts. Which explains why I have never > used it -- I generally use OSes that allow keyboard layout translating > natively. > > EXAMPLE: > Based on my guess above, key-translation-map would let me map between > QWERTY and Dvorak inside Emacs. This would be nice if I was running > directly in a Linux terminal and did not have permission to run "sudo > loadkeys". > > As a final note, notice that all three of these examples involve > changing a key into a different key. None of them are for binding > commands. Commands being bound to a key always is the job of the local > and global keymaps. > > I hope these examples help you understand the setup here! > > -- MJF