From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#66755: 30.0.50; how do i lookup a key but also respect key translations? Date: Wed, 10 Jan 2024 22:41:15 -0500 Message-ID: References: <87ttqeja59.fsf@strawberrytea.xyz> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26537"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 66755@debbugs.gnu.org To: StrawberryTea Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jan 11 04:42:32 2024 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 1rNlxf-0006gz-7c for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 11 Jan 2024 04:42:31 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rNlxF-0006N4-Mb; Wed, 10 Jan 2024 22:42:05 -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 1rNlxD-0006Mb-RT for bug-gnu-emacs@gnu.org; Wed, 10 Jan 2024 22:42:03 -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 1rNlxD-0003b0-J8 for bug-gnu-emacs@gnu.org; Wed, 10 Jan 2024 22:42:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rNlxC-00050e-55 for bug-gnu-emacs@gnu.org; Wed, 10 Jan 2024 22:42:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 11 Jan 2024 03:42:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66755 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: notabug Original-Received: via spool by 66755-submit@debbugs.gnu.org id=B66755.170494449219215 (code B ref 66755); Thu, 11 Jan 2024 03:42:02 +0000 Original-Received: (at 66755) by debbugs.gnu.org; 11 Jan 2024 03:41:32 +0000 Original-Received: from localhost ([127.0.0.1]:43643 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rNlwi-0004zq-7f for submit@debbugs.gnu.org; Wed, 10 Jan 2024 22:41:32 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:40502) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rNlwa-0004zT-VH for 66755@debbugs.gnu.org; Wed, 10 Jan 2024 22:41:31 -0500 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 46A598122F; Wed, 10 Jan 2024 22:41:18 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1704944477; bh=CwfSUSvNsEot9j6W6km4yPr8k21EYRhErNzfRg07iu8=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=o1F7veD1i4smaq0r3v2baJPHp4yLYZH1Ad32GhKdaAlKUAF8MPnSRfV53z+Kl/jdc 5Dz4DIDxbI6RTdbPErAfdS65g+VfGNQvvi85PWKu6W+tpgLHuVPLc7ABakB/xKUfHg qoOODO77jOfdk5Isz4LhqVoc2desKO6b/zsp1s3gOsktuB3TIXPzpl7PcXgVqUgZjh hIJNhEIY75jYwUJcWzX5N1oI1vLVBLR8g4MZS9KrfCqoUUf9xYx/PsyYAxO7v6IyNc 7rHyOG/SajcxiFmxIsAXwvHQbcQf8ALYaOj8Gyp6U06VYkXs/hHwSZ0l7WFdtOCkKP jo7+8EILYqwoA== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 05E6580841; Wed, 10 Jan 2024 22:41:17 -0500 (EST) Original-Received: from pastel (65-110-221-238.cpe.pppoe.ca [65.110.221.238]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id C52581204DC; Wed, 10 Jan 2024 22:41:16 -0500 (EST) In-Reply-To: <87ttqeja59.fsf@strawberrytea.xyz> (StrawberryTea's message of "Wed, 25 Oct 2023 22:57:58 -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:277859 Archived-At: > Hello. So I am trying to define a function which obtains the command > that would be called if 'corfu-mode' was not enabled: I recommend you try and avoid needing to do that. > (defun +corfu--get-passthrough-command () > (keymap-lookup > (thread-last > (current-active-maps t) > (delq corfu-map) > (delq (and (featurep 'evil) > (evil-get-auxiliary-keymap corfu-map evil-state)))) > (key-description (this-command-keys-vector)))) [ Eww... `keymap-lookup` forcing you to use `key-description` here is pretty hideous. ] > but I don't know how to look up that translation from Elisp. I looked at > the code for 'help.el' and found the above description comes from > 'read-key-sequence' returning 'C-?' and 'this-single-command-raw-keys' > returning '[backspace]' but 'read-key-sequence' is defined in C and I > don't know how trigger it's translation logic programmatically from > Elisp. Are you saying that `this-command-keys-vector` returns the same `[backspace]` as `this-single-command-raw-keys` here? That's odd, I'd have expected to return `[?\C-?]`. In any case it still won't always be the answer you're looking for. There is simply no reliable way to do what you want, because even deciding when the sequence of keys ends (to run your (presumably Corfu) command) can be affected by the existence of a binding to that command. I think the "closest" you can get is to take `this-single-command-raw-keys` and push it back on `unread-command-events`. Or else, arrange for your command's binding to be disabled when you don't actually want to run it, rather than make it delegate manually to the "next" binding. Stefan