From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Madhu Newsgroups: gmane.emacs.help Subject: emacs term-keys, and describe-prefix-translations Date: Tue, 03 Dec 2024 12:21:15 +0530 Message-ID: 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="37609"; mail-complaints-to="usenet@ciao.gmane.io" To: help-gnu-emacs@gnu.org Cancel-Lock: sha1:97WtrtyUC4L/CIrOveCdXSnLBk0= Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Tue Dec 03 07:51:21 2024 Return-path: Envelope-to: geh-help-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 1tIMkj-0009i3-Le for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 03 Dec 2024 07:51:21 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tIMk1-0003Ul-Tm; Tue, 03 Dec 2024 01:50:37 -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 1tIMk0-0003UX-NC for help-gnu-emacs@gnu.org; Tue, 03 Dec 2024 01:50:36 -0500 Original-Received: from ciao.gmane.io ([116.202.254.214]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tIMjz-0002ZM-54 for help-gnu-emacs@gnu.org; Tue, 03 Dec 2024 01:50:36 -0500 Original-Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1tIMjx-0008ml-B1 for help-gnu-emacs@gnu.org; Tue, 03 Dec 2024 07:50:33 +0100 X-Injected-Via-Gmane: http://gmane.org/ Received-SPF: pass client-ip=116.202.254.214; envelope-from=geh-help-gnu-emacs@m.gmane-mx.org; helo=ciao.gmane.io X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:148525 Archived-At: When trying to use term-keys (actually my gh clone of it) to handle Super- bindings in the terminal, I run into behaviour that I do not understand, which I detail below where "s-s" works but "s-d" doesn't. term-keys works by arranging for "xterm" (and other terms) to send escape codes and setting up input-decode-map on emacs terminal frames to handle them. for xterm my config sets up these overrides via Xresources *VT100.Translations:#override ``` ~Shift ~Ctrl ~Meta Super ~Hyper ~Alt s : string(0x1b) string(0x1f) string(0x3e) string(0x68) string(0x1f) \n\ ~Shift ~Ctrl ~Meta Super ~Hyper ~Alt d : string(0x1b) string(0x1f) string(0x3f) string(0x48) string(0x1f) \n\ ``` and typing "Super-s" and "Super-d" under "showkeys -a" in any terminal produces the following. ``` $ showkey -a Press any keys - Ctrl-D will terminate this program ^[^_>h^_ 27 0033 0x1b 31 0037 0x1f 62 0076 0x3e 104 0150 0x68 31 0037 0x1f ^[^_?H^_ 27 0033 0x1b 31 0037 0x1f 63 0077 0x3f 72 0110 0x48 31 0037 0x1f ``` On the emacs side, term-keys-init does the equivalent of calling ``` (define-key input-decode-map (string #x1b #x1f #x3e #x68 #x1f) (kbd "s-s")) (define-key input-decode-map (string #x1b #x1f #x3f #x48 #x1f) (kbd "s-d")) ``` And can is verified with lookup-key. **HERE** Now calling Super-s on the terminal correctly produces "s-s is undefined" but calling Super-d produces a help screen with the input decoding map translations for C-M-_ view-lossage has an entry: ESC C-_ ? ;; describe-prefix-bindings and the (info "(elisp) Help Functions") has ``` The help character is special after prefix keys, too. If it has no binding as a subcommand of the prefix key, it runs ‘describe-prefix-bindings’, which displays a list of all the subcommands of the prefix key. ``` Is the input keymap machinery doing the right thing here in interpreting the escape sequence for "d" (lookup-key input-decode-map (string #x1b #x1f #x3e #x68)) => (keymap (31 . [8388723])) as a key sequence which calls the prefix-help-command? Should I avoid the use of #x68 in the encoding used by the term-keys protocol or is there some other solution? Any comments welcome, thanks