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: Tue, 13 Aug 2013 23:13:46 +0200
User-agent: Gnus/5.130002 (Ma Gnus v0.2) Emacs/24.3 (gnu/linux)

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

>> if a command that should appear in the menu for a mode has more than one
>> keybinding - how do I specify which binding shows up in the menu?
>
> (put 'my-command :advertised-binding [C-M-right])

I completely refactored the old menu and keybinding code in
'outshine.el', that was mostly inherited from older libraries
'outline-magic' and 'out-xtra', giving outshine its own menu entry while
getting rid of the "Outline" entry with its countless specialised
outline commands (many of them kind of obsolete due to a few more
powerful commands introduced in 'outline-magic' and
'outline-mode-easy-bindings').

Its looks good so far, but I could not make easy-menu to show the
advertised keybindings. The whole thing looks like this:

,-----------------------------------------------------------------------
| ;; ** Menus
| ;; *** Advertise Bindings
|
| (put 'outline-cycle :advertised-binding [TAB])
| (put 'outshine-cycle-buffer :advertised-binding [BACKTAB])
| (put 'outline-promote :advertised-binding [M-S-left])
| (put 'outline-demote :advertised-binding [M-S-right])
| [...snip...]
| (put 'outline-up-heading :advertised-binding [M-\# M-u])
| (put 'outorg-edit-as-org :advertised-binding [M-\# M-\#])
|
| ;; *** Define Menu
|
| (easy-menu-define outshine-menu outline-minor-mode-map "Outshine menu"
|   '("Outshine"
|      ["Cycle Subtree" outline-cycle
|       :active (outline-on-heading-p)]
|       [...snip...]
|      ["Up Heading" outline-up-heading t]
|     "--"
|      ["Edit As Org" outorg-edit-as-org t]))
|
| ;; add "Outshine" menu item
| (easy-menu-add outshine-menu outline-minor-mode-map)
| ;; get rid of "Outline" menu item
| (define-key outline-minor-mode-map [menu-bar outline] 'undefined)
`-----------------------------------------------------------------------

but the advertised bindings don't appear in the menu, either the
alternative bindings or no bindings at all show up.

I should mention that I use a specialised macro to define keybindings
conditional on point position, in order to not mess with user setting
(this is a minor-mode). Am I doing the advertising the wrong way?

--
cheers,
Thorsten




reply via email to

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