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, use define-key-after
:
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.
For 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)
Note that key is a sequence containing just one event type, but after is just an event type (not a sequence).
Go to the first, previous, next, last section, table of contents.