[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#69306: 30.0.50; defining menu-items with :enable enables them uncond
From: |
StrawberryTea |
Subject: |
bug#69306: 30.0.50; defining menu-items with :enable enables them unconditionally |
Date: |
Thu, 22 Feb 2024 15:19:26 -0600 |
User-agent: |
mu4e 1.10.8; emacs 30.0.50 |
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.
Eli Zaretskii <eliz@gnu.org> writes:
>> From: StrawberryTea <look@strawberrytea.xyz>
>> Date: Wed, 21 Feb 2024 17:26:02 -0600
>>
>> Hi. I am not sure if I open a vanilla Emacs session and evaluate:
>> (defvar hello nil)
>> (setq hello nil)
>> (define-key global-map (kbd “C-M-S-f”) ’(menu-item “” delete-backward-char
>> :enable hello))
>>
>> and then press C-M-S-f, the delete-backward-char menu item will be
>> enabled, even though hello is nil.
>
> Enabled where? After evaluating the above, I don’t see your menu item
> anywhere (since it is not added to any existing menu, I guess?), so
> I’m not sure what you are describing here. Is some step missing from
> the recipe? Can you show a full recipe starting from “emacs -Q”?