From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: StrawberryTea Newsgroups: gmane.emacs.help Subject: Re: How do i lookup a key but also respect key translations? (was: bug#66755: 30.0.50) Date: Sat, 28 Oct 2023 10:12:45 -0500 Message-ID: <87h6mabve1.fsf@strawberrytea.xyz> References: <87ttqeja59.fsf@strawberrytea.xyz> <83msw5hmqn.fsf@gnu.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="33883"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.10.7; emacs 30.0.50 Cc: Eli Zaretskii , help-gnu-emacs@gnu.org To: Stefan Monnier Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Mon Oct 30 17:32:38 2023 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 1qxVBu-0008V3-FD for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 30 Oct 2023 17:32:38 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qxVBF-0000nl-1p; Mon, 30 Oct 2023 12:31:57 -0400 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 1qwlYM-0003NU-6E for help-gnu-emacs@gnu.org; Sat, 28 Oct 2023 11:48:46 -0400 Original-Received: from wout3-smtp.messagingengine.com ([64.147.123.19]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qwlYK-0007fS-8R; Sat, 28 Oct 2023 11:48:45 -0400 Original-Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 05AC832006F2; Sat, 28 Oct 2023 11:48:40 -0400 (EDT) Original-Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sat, 28 Oct 2023 11:48:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= strawberrytea.xyz; h=cc:cc:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm1; t= 1698508120; x=1698594520; bh=PdO6+EfozWboxGK37JYdKWFfZoeEH4ciy8H vfNbsC6s=; b=TQQiIb+QJ4iOvc5iPtaMe88+ttlkcEQomwZIWU4d4D8lzrzipZq l93Esrmfb+OtOk1pczoAN8mKGpz4Im9X53Qsb8VbLd+4xAzadiju+LstGlM2vHaX iGqzCfRR40syEqT8AZuARpMyYhqsNhidVEtIrU37RBsn5jItPxBxU2zNAerr3qIG y8wcrfJaVG4DwDFbn+R75Z3Punf13GyCRvOe1XdnZwV7xwptNCnAhPtOuHkVc46E WaRdg4c2s9xFdoPIGteYVZUZXHeRo9Mz07gz4u8oM6TBDfwCBTPrt6pH7pena4IJ DvVokDXmGWQ4SqBcXos1QlJiG8LWf08zrBA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; t=1698508120; x=1698594520; bh=PdO6+EfozWbox GK37JYdKWFfZoeEH4ciy8HvfNbsC6s=; b=fYIRhwotkXg+XEzsuoEREYk0OHmkB KnMehvzJ76ptK3JV3dAY6O/yrmRnS30TA9eleg9OsERxrMPBRs6dzi2/3Z31Daz1 gTJvhUbKbUNjs/NFZEMlHShpz6cZswGDyDyCoFgiB7Gg6j2zQfxTkGqEWRBxbXci LsSPKRkvAjzM2CFZtI+lgGce88KysGgsFOm3msd/FJCSrFqQjlsL6z870LdgYNWg V71QeGnksFLhnrkh0En8dZkp5pDR3GJPFw05s+19oKtsw/WHcbosQYOBwE/54P0X 8HooTLySKtvIxYhc/GlCFQthAIlXEIFhcbqesAqg4IXmG6Mc0cmqDrx9w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrleeigdeilecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfg hrlhcuvffnffculdefhedmnecujfgurhephffvvefuffhffggjkfggtgesmhdtreertder jeenucfhrhhomhepufhtrhgrfigsvghrrhihvfgvrgcuoehlohhokhesshhtrhgrfigsvg hrrhihthgvrgdrgiihiieqnecuggftrfgrthhtvghrnhephfelleffvdeijeetgfdtvdfg hfegfedvtefgjeefveejteegudekveelvdeluefhnecuvehluhhsthgvrhfuihiivgeptd enucfrrghrrghmpehmrghilhhfrhhomheplhhoohhksehsthhrrgifsggvrhhrhihtvggr rdighiii X-ME-Proxy: Feedback-ID: id85149b6:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 28 Oct 2023 11:48:39 -0400 (EDT) In-reply-to: Received-SPF: pass client-ip=64.147.123.19; envelope-from=look@strawberrytea.xyz; helo=wout3-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Mon, 30 Oct 2023 12:31:54 -0400 Content-Disposition: inline X-Content-Filtered-By: Mailman/MimeDel 2.1.29 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:145420 Archived-At: Hi Stefan. Using let-binding corfu-mode did not affect the output of current-active-maps but the menu-item usage worked perfectly for all the use-cases I was working on for a new Doom Emacs module. Thank you =F0=9F=98= =83. I was hoping for a drop-in replacement for keymap-lookup/lookup-key/key-bin= ding that respects key translations to pick up some low-hanging fruit in Meow/God Mode/Devil since those packages do not utilize the key-translation-map but = it seems that might be really complicated. Love your MPC package by the way! Stefan Monnier writes: >>> Hello. So I am trying to define a function which obtains the command >>> that would be called if =E2=80=99corfu-mode=E2=80=99 was not enabled: > > Sounds like pain. Often the better solution is to step back and think > of some other way to get that result, e.g. temporarily disabling > corfu-mode beforehand. > >>> (defun +corfu=E2=80=93get-passthrough-command () >>> (keymap-lookup >>> (thread-last >>> (current-active-maps t) >>> (delq corfu-map) > > I think you can get a similar result with > > (let ((corfu-mode nil)) > (current-active-maps t)) > >>> (keymap-lookup (current-active-maps t) >>> (key-description (vector =E2=80=99backspace))) >>> >>> returns nil whereas >>> >>> (keymap-lookup (current-active-maps t) (key-description (vector ?\C-?))) > > Right, because you need to obey the various key-remapping keymaps, like > `function-key-map` and friends. > > It=E2=80=99s actually a fundamentally difficult problem. Think of the ca= se > where the =E2=80=9Cunderlying binding=E2=80=9D you=E2=80=99re trying to f= ind is actually > a keymap because the user decided to use his DEL key as a prefix key? > What should you do in that case? > > If you can=E2=80=99t know beforehand that you=E2=80=99ll want to just =E2= =80=9Cpassthrough=E2=80=9D > (hence you can=E2=80=99t disable corfu ahead of time), a second best kind= of > solution is to push the events back on `unread-command-events`. > > Another approach that can be used sometime is to make the binding that > you sometimes want to fallthrough be dynamically enabled/disabled with > something like: > > (define-key map [THE-KEYS] > `(menu-item THE-COMMAND > :filter ,(lambda (cmd) (if (THE-CONDITION) cmd)))) > > =E2=80=93 Stefan