An extended-format menu item is a more flexible and also cleaner
alternative to the simple format. It consists of a list that starts
with the symbol menu-item
. To define a non-selectable string,
the item looks like this:
(menu-item item-name)
where a string consisting of two or more dashes specifies a separator line.
To define a real menu item which can be selected, the extended format item looks like this:
(menu-item item-name real-binding . item-property-list)
Here, item-name is an expression which evaluates to the menu item string. Thus, the string need not be a constant. The third element, real-binding, is the command to execute. The tail of the list, item-property-list, has the form of a property list which contains other information. Here is a table of the properties that are supported:
:enable FORM
nil
means yes).
:visible FORM
nil
means yes). If the item
does not appear, then the menu is displayed as if this item were
not defined at all.
:help help
:button (type . selected)
:toggle
or
:radio
. The CDR, selected, should be a form; the
result of evaluating it says whether this button is currently selected.
A toggle is a menu item which is labeled as either "on" or "off"
according to the value of selected. The command itself should
toggle selected, setting it to t
if it is nil
,
and to nil
if it is t
. Here is how the menu item
to toggle the debug-on-error
flag is defined:
(menu-item "Debug on Error" toggle-debug-on-error :button (:toggle . (and (boundp 'debug-on-error) debug-on-error))This works because
toggle-debug-on-error
is defined as a command
which toggles the variable debug-on-error
.
Radio buttons are a group of menu items, in which at any time one
and only one is "selected." There should be a variable whose value
says which one is selected at any time. The selected form for
each radio button in the group should check whether the variable has the
right value for selecting that button. Clicking on the button should
set the variable so that the button you clicked on becomes selected.
:key-sequence key-sequence
:key-sequence nil
:keys
property and finds the keyboard
equivalent anyway.
:keys string
:filter filter-fn
Go to the first, previous, next, last section, table of contents.