help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Commands with more than one keybinding in menus


From: Thorsten Jolitz
Subject: Re: Commands with more than one keybinding in menus
Date: Wed, 14 Aug 2013 18:55:16 +0200
User-agent: Gnus/5.130002 (Ma Gnus v0.2) Emacs/24.3 (gnu/linux)

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> The macro was offered by a user of outshine, I only fiddled around with
>> it until it worked without errors. It serves its purpose, because
>> without it a minor-mode, unconditionally defining 'M-[S-]<arrow-key>'
>> bindings, runs a high risk of breaking major-mode or user settings - I
>> would not want to do without it.
>
> There are a few ways to have your cake and eat it too:
> - Move the conditional test into the command, so the menu entries are
>   bound to the same command as the keys.  If you want the menu-entries
>   to skip the test, then you can do that by checking the event(s) that
>   triggered the command.
> - You can use ":keys STRING" in the menu.  This will show "STRING" as
>   the shortcut without checking if it indeed runs the same command.

I quickly applied this as an immediate "solution", it solves most cases
where keybindings were missing in the menu, otherwise the :keys property
is overwritten by the alternative keybindings (that do not involve the
macro). 

> - You can use dynamic key-bindings, i.e. instead of binding your key to
>   (lambda () (interactive) (if foo (CMD))), bind it to
>   (menu-item "" CMD :filter (lambda (cmd) (if foo cmd))).

I will have a look at the other option later, thanks for the hints.

-- 
cheers,
Thorsten




reply via email to

[Prev in Thread] Current Thread [Next in Thread]