Previous: , Up: Pull-down Menus   [Contents][Index]


2.4.8 Customizing SXEmacs Menus

You can customize any of the pull-down menus by adding or removing menu items and disabling or enabling existing menu items.

The following functions are available:

add-menu: (menu-path menu-name menu-items &optional before)

Add a menu to the menu bar or one of its submenus.

add-menu-item: (menu-path item-name function

enabled-p &optional before) Add a menu item to a menu, creating the menu first if necessary.

delete-menu-item: (path)

Remove the menu item defined by path from the menu hierarchy.

disable-menu-item: (path)

Disable the specified menu item.

enable-menu-item: (path)

Enable the specified previously disabled menu item.

relabel-menu-item: (path new-name)

Change the string of the menu item specified by path to new-name.

Use the function add-menu to add a new menu or submenu. If a menu or submenu of the given name exists already, it is changed.

menu-path identifies the menu under which the new menu should be inserted. It is a list of strings; for example, ("File") names the top-level File menu. ("File" "Foo") names a hypothetical submenu of File. If menu-path is nil, the menu is added to the menu bar itself.

menu-name is the string naming the menu to be added.

menu-items is a list of menu item descriptions. Each menu item should be a vector of three elements:

The optional argument before is the name of the menu before which the new menu or submenu should be added. If the menu is already present, it is not moved.

The function add-menu-item adds a menu item to the specified menu, creating the menu first if necessary. If the named item already exists, the menu remains unchanged.

menu-path identifies the menu into which the new menu item should be inserted. It is a list of strings; for example, ("File") names the top-level File menu. ("File" "Foo") names a hypothetical submenu of File.

item-name is the string naming the menu item to add.

function is the command to invoke when this menu item is selected. If it is a symbol, it is invoked with call-interactively, in the same way that functions bound to keys are invoked. If it is a list, the list is simply evaluated.

enabled-p controls whether the item is selectable or not. It should be t, nil, or a form to evaluate to decide. This form will be evaluated just before the menu is displayed, and the menu item will be selectable if that form returns non-nil.

For example, to make the rename-file command available from the File menu, use the following code:

(add-menu-item '("File") "Rename File" 'rename-file t)

To add a submenu of file management commands using a File Management item, use the following code:

(add-menu-item '("File" "File Management") "Copy File" 'copy-file t)
(add-menu-item '("File" "File Management") "Delete File" 'delete-file t)
(add-menu-item '("File" "File Management") "Rename File" 'rename-file t)

The optional before argument is the name of a menu item before which the new item should be added. If the item is already present, it is not moved.

To remove a specified menu item from the menu hierarchy, use delete-menu-item.

path is a list of strings that identify the position of the menu item in the menu hierarchy. ("File" "Save") means the menu item called Save under the top level File menu. ("Menu" "Foo" "Item") means the menu item called Item under the Foo submenu of Menu.

To disable a menu item, use disable-menu-item. The disabled menu item is grayed and can no longer be selected. To make the item selectable again, use enable-menu-item. disable-menu-item and enable-menu-item both have the argument path.

To change the string of the specified menu item, use relabel-menu-item. This function also takes the argument path.

new-name is the string to which the menu item will be changed.


Previous: , Up: Pull-down Menus   [Contents][Index]