From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jared Finder via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#49253: 27.2; Emacs non-responsive when pasting into terminal-mode Date: Mon, 11 Dec 2023 14:13:24 -0800 Message-ID: <5d8850165ca6f3d344e764397339abf0@finder.org> References: <87r12lqmco.fsf@gnus.org> <838r63y6kj.fsf@gnu.org> <11108ebcb87fae9390410fa4f3355967@finder.org> Reply-To: Jared Finder Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25860"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , larsi@gnus.org, 49253@debbugs.gnu.org To: Matt Bisson Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Dec 11 23:14: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 1rCoXO-0006Uq-Na for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 11 Dec 2023 23:14:06 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rCoX9-0006nn-TO; Mon, 11 Dec 2023 17:13:51 -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 1rCoX5-0006nK-0h for bug-gnu-emacs@gnu.org; Mon, 11 Dec 2023 17:13: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 1rCoX4-00072B-Oh for bug-gnu-emacs@gnu.org; Mon, 11 Dec 2023 17:13:46 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rCoXJ-0004Rg-Ni for bug-gnu-emacs@gnu.org; Mon, 11 Dec 2023 17:14:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Jared Finder Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 11 Dec 2023 22:14: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.170233282317058 (code B ref 49253); Mon, 11 Dec 2023 22:14:01 +0000 Original-Received: (at 49253) by debbugs.gnu.org; 11 Dec 2023 22:13:43 +0000 Original-Received: from localhost ([127.0.0.1]:54860 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rCoX0-0004R4-VQ for submit@debbugs.gnu.org; Mon, 11 Dec 2023 17:13:43 -0500 Original-Received: from greenhill.hpalace.com ([192.155.80.58]:51864) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rCoWy-0004Qu-UT for 49253@debbugs.gnu.org; Mon, 11 Dec 2023 17:13:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=finder.org; s=2018; t=1702332805; bh=MPtj42VMJejUItGawnMyN9lY9DaRvyKLy6Q6dp1dIt8=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=zN1ifs1WOptxElTzII1zQy5WfqAbi8BNpyTBQkuOE8oacI+jd3psRluLaUWW5HbEI aJ4dzZy8KmZv/WuJlBS4QSc0Dik0aZKsPPRTRZq0yTBx5gHq5WIcXuv5ClmjKFyKpS XFeqOu4Z6MfsWl1vD+JjVjf6IJ+MPIx2u/l+TcCDLpVwdyNtDP/xpe4f77bsfcCC2O 9/E7sZgc59DTilx1xqGnQZbZT68EiGf3ffvenQ/0DV8diNlVgST5TbvK/LSGH5/e7f q7czwqGMpFj+QiScJQuJLXNXwfWQFKJpLT+eca3MrkqcN2vHO2mTGmpeSvtSpe3YfD fKF86nnZUt2Dw== Original-Received: from mail.finder.org (unknown [192.155.80.58]) by greenhill.hpalace.com (Postfix) with ESMTPSA id F0E4F9A8; Mon, 11 Dec 2023 22:13:24 +0000 (UTC) In-Reply-To: X-Sender: jared@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:276006 Archived-At: 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-Keymaps.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