Modifying Menus
---------------
When you insert a new item in an existing menu, you probably want to
put it in a particular place among the menu's existing items. If you
use `define-key' to add the item, it normally goes at the front of the
menu. To put it elsewhere in the menu, use `define-key-after':
- Function: define-key-after map key binding &optional after
Define a binding in MAP for KEY, with value BINDING, just like
`define-key', but position the binding in MAP after the binding
for the event AFTER. The argument KEY should be of length one--a
vector or string with just one element. But AFTER should be a
single event type--a symbol or a character, not a sequence. The
new binding goes after the binding for AFTER. If AFTER is `t' or
is omitted, then the new binding goes last, at the end of the
keymap. However, new bindings are added before any inherited
keymap.
Here is an example:
(define-key-after my-menu [drink]
'("Drink" . drink-command) 'eat)
makes a binding for the fake function key <DRINK> and puts it
right after the binding for <EAT>.
Here is how to insert an item called `Work' in the `Signals' menu
of Shell mode, after the item `break':
(define-key-after
(lookup-key shell-mode-map [menu-bar signals])
[work] '("Work" . work-command) 'break)