From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#69306: 30.0.50; defining menu-items with :enable enables them unconditionally Date: Fri, 23 Feb 2024 09:23:45 +0200 Message-ID: <86le7b1w5a.fsf@gnu.org> References: <87zfvtmm5h.fsf@strawberrytea.xyz> <86bk89m25w.fsf@gnu.org> <87edd4yyyn.fsf@strawberrytea.xyz> 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="4668"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 69306@debbugs.gnu.org To: StrawberryTea , Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Feb 23 08:40:55 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 1rdQAw-0000vv-W8 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 23 Feb 2024 08:40:55 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rdQAl-0007vH-3P; Fri, 23 Feb 2024 02:40:43 -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 1rdQAi-0007uy-TI for bug-gnu-emacs@gnu.org; Fri, 23 Feb 2024 02:40:42 -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 1rdQAg-000474-RE for bug-gnu-emacs@gnu.org; Fri, 23 Feb 2024 02:40:40 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rdQB4-0001s7-12 for bug-gnu-emacs@gnu.org; Fri, 23 Feb 2024 02:41:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 23 Feb 2024 07:41:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 69306 X-GNU-PR-Package: emacs Original-Received: via spool by 69306-submit@debbugs.gnu.org id=B69306.17086740207070 (code B ref 69306); Fri, 23 Feb 2024 07:41:01 +0000 Original-Received: (at 69306) by debbugs.gnu.org; 23 Feb 2024 07:40:20 +0000 Original-Received: from localhost ([127.0.0.1]:46730 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rdQAN-0001pv-Rx for submit@debbugs.gnu.org; Fri, 23 Feb 2024 02:40:20 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:40994) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rdPwx-0001AH-9p for 69306@debbugs.gnu.org; Fri, 23 Feb 2024 02:26:30 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rdPuN-0001ey-7s; Fri, 23 Feb 2024 02:23:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=KmAT64mgnXLR3qSQJjZANaLzAT7kyH6tAnROPOMnLx8=; b=NbTmaCP1wYJ4tfhNtyJ3 8Qe4sTFf9tOQGRSuxRCPHT7aMEzMYOv+mBxt7TMp1ogXwt2PSqeWAbbsbtRj/jLENsSNEiBc7Znk8 btRmqug0u4T1EKJWcasnK9+cemZnkQvXz9HF29YGpIgDtuvlxO+Qt0ixD9mPU9eXDCB6Z5YNptZkb 3EovfNtNPLiIiiVETypOwr7Tsi5zjWH8L/VTfAbgjg9bAhEzY/mXUWg0uijHGz1WxT7JoKK4mwVWx cfriqI3yDUl14NQHVPY/4AtyBbHvJ8ObjIlRBACApQJv1zCl9ZnfAXzgwA/vqYor1jBXDJEkjojIy 56g6S5ucKDzcEA==; In-Reply-To: <87edd4yyyn.fsf@strawberrytea.xyz> (message from StrawberryTea on Thu, 22 Feb 2024 15:19:26 -0600) 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:280483 Archived-At: > From: StrawberryTea > Cc: 69306@debbugs.gnu.org > Date: Thu, 22 Feb 2024 15:19:26 -0600 > > Basically, I am trying to define a conditional keybinding. The real-world > example I’m working with is: > > (when-let ((cmds-del (and (modulep! :completion corfu +tng) > ’(menu-item “Reset completion” corfu-reset > :enable (and (> corfu–index -1) > (eq corfu-preview-current ’insert))))) > (cmds-ret ’(menu-item “Insert completion” corfu-insert > :filter (lambda (cmd) > (if (eq corfu–index -1) > (corfu-quit) > cmd))))) > (map! :when (modulep! :completion corfu) > :after corfu > :map corfu-map > [backspace] cmds-del > “DEL” cmds-del > :ig [return] cmds-ret > :ig “RET” cmds-ret)) > > Here, the :filter and :enable properties are used to conditionally enable their > respective keybindings. The :filter property works as expected, but the :enable > property does not. The backspace keybinding is always enabled, even when the > :enable property is evaluates to nil. If you expect that the key binding will be disabled via :enable, then I don't think this is supported except in menus (and tool bars and tab bars): the value is evaluated by the menu-related code, when it actually displays the menu, and in your case there's no menu. The :filter attribute is interpreted differently, so it just happens to work. But that's sheer luck, I'd say. Adding Stefan in case he has comments.