Function: easy-menu-add-item

easy-menu-add-item is a byte-compiled function defined in easymenu.el.gz.

Signature

(easy-menu-add-item MAP PATH ITEM &optional BEFORE)

Documentation

To the submenu of MAP with path PATH, add ITEM.

If an item with the same name is already present in this submenu, then ITEM replaces it. Otherwise, ITEM is added to this submenu. In the latter case, ITEM is normally added at the end of the submenu. However, if BEFORE is a string and there is an item in the submenu with that name, then ITEM is added before that item.

MAP should normally be a keymap; nil stands for the local menu-bar keymap. It can also be a symbol, which has earlier been used as the first argument in a call to easy-menu-define, or the value of such a symbol.

PATH is a list of strings for locating the submenu where ITEM is to be added. If PATH is nil, MAP itself is used. Otherwise, the first element should be the name of a submenu directly under MAP. This submenu is then traversed recursively with the remaining elements of PATH.

ITEM is either defined as in easy-menu-define or a non-nil value returned by easy-menu-item-present-p or easy-menu-remove-item or a menu defined earlier by easy-menu-define or easy-menu-create-menu.

Probably introduced at or before Emacs version 20.4.

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/easymenu.el.gz
(defun easy-menu-add-item (map path item &optional before)
  "To the submenu of MAP with path PATH, add ITEM.

If an item with the same name is already present in this submenu,
then ITEM replaces it.  Otherwise, ITEM is added to this submenu.
In the latter case, ITEM is normally added at the end of the submenu.
However, if BEFORE is a string and there is an item in the submenu
with that name, then ITEM is added before that item.

MAP should normally be a keymap; nil stands for the local menu-bar keymap.
It can also be a symbol, which has earlier been used as the first
argument in a call to `easy-menu-define', or the value of such a symbol.

PATH is a list of strings for locating the submenu where ITEM is to be
added.  If PATH is nil, MAP itself is used.  Otherwise, the first
element should be the name of a submenu directly under MAP.  This
submenu is then traversed recursively with the remaining elements of PATH.

ITEM is either defined as in `easy-menu-define' or a non-nil value returned
by `easy-menu-item-present-p' or `easy-menu-remove-item' or a menu defined
earlier by `easy-menu-define' or `easy-menu-create-menu'."
  (setq map (easy-menu-get-map map path
			       (and (null map) (null path)
				    (stringp (car-safe item))
				    (car item))))
  (if (and (consp item) (consp (cdr item)) (eq (cadr item) 'menu-item))
      ;; This is a value returned by `easy-menu-item-present-p' or
      ;; `easy-menu-remove-item'.
      (easy-menu-define-key map (easy-menu-intern (car item))
			    (cdr item) before)
    (if (or (keymapp item)
	    (and (symbolp item) (keymapp (symbol-value item))
		 (setq item (symbol-value item))))
	;; Item is a keymap, find the prompt string and use as item name.
	(setq item (cons (keymap-prompt item) item)))
    (setq item (easy-menu-convert-item item))
    (easy-menu-define-key map (easy-menu-intern (car item)) (cdr item) before)))