unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Thorsten Jolitz <tjolitz@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Commands with more than one keybinding in menus
Date: Tue, 13 Aug 2013 23:13:46 +0200	[thread overview]
Message-ID: <87ob91i99x.fsf@gmail.com> (raw)
In-Reply-To: jwvob91iqrr.fsf-monnier+gnu.emacs.help@gnu.org

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	other threads:[~2013-08-13 21:13 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.3104.1376386441.12400.help-gnu-emacs@gnu.org>
2013-08-13 14:57 ` Commands with more than one keybinding in menus Stefan Monnier
2013-08-13 21:13   ` Thorsten Jolitz [this message]
2013-08-14 12:36     ` Michael Heerdegen
2013-08-14 13:25       ` Thorsten Jolitz
     [not found]       ` <mailman.3200.1376486779.12400.help-gnu-emacs@gnu.org>
2013-08-14 14:12         ` Stefan Monnier
2013-08-14 15:40           ` Thorsten Jolitz
     [not found]           ` <mailman.3205.1376494881.12400.help-gnu-emacs@gnu.org>
2013-08-14 16:23             ` Stefan Monnier
2013-08-14 16:55               ` Thorsten Jolitz
     [not found]   ` <mailman.3163.1376428457.12400.help-gnu-emacs@gnu.org>
2013-08-14 14:09     ` Stefan Monnier
2013-08-13  9:33 Thorsten Jolitz
2013-08-13 13:48 ` Michael Heerdegen
2013-08-13 14:52   ` Thorsten Jolitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ob91i99x.fsf@gmail.com \
    --to=tjolitz@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).