aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/emacs-lisp/easymenu.el44
1 files changed, 27 insertions, 17 deletions
diff --git a/lisp/emacs-lisp/easymenu.el b/lisp/emacs-lisp/easymenu.el
index 0a489840133..90b4f55fe09 100644
--- a/lisp/emacs-lisp/easymenu.el
+++ b/lisp/emacs-lisp/easymenu.el
@@ -1,9 +1,10 @@
1;;; easymenu.el --- support the easymenu interface for defining a menu. 1;;; easymenu.el --- support the easymenu interface for defining a menu.
2 2
3;; Keywords: emulations
4
5;; Copyright (C) 1994 Free Software Foundation, Inc. 3;; Copyright (C) 1994 Free Software Foundation, Inc.
6 4
5;; Keywords: emulations
6;; Author: rms
7
7;; This file is part of GNU Emacs. 8;; This file is part of GNU Emacs.
8 9
9;; GNU Emacs is free software; you can redistribute it and/or modify 10;; GNU Emacs is free software; you can redistribute it and/or modify
@@ -27,22 +28,26 @@
27;;; Code: 28;;; Code:
28 29
29;;;###autoload 30;;;###autoload
30(defun easy-menu-define (symbol maps doc menu) 31(defmacro easy-menu-define (symbol maps doc menu)
31 "Define a menu bar submenu in maps MAPS, according to MENU. 32 "Define a menu bar submenu in maps MAPS, according to MENU.
32The arguments SYMBOL and DOC are ignored; they are present for 33The arguments SYMBOL and DOC are ignored; they are present for
33compatibility only. In other Emacs versions they may be used 34compatibility only. SYMBOL is not evaluated. In other Emacs versions
34as a variable to hold the menu data, and a doc string for that variable. 35these arguments may be used as a variable to hold the menu data, and a
36doc string for that variable.
35 37
36The first element of MENU must be a string. It is the menu bar item name. 38The first element of MENU must be a string. It is the menu bar item name.
37The rest of the elements are menu items. 39The rest of the elements are menu items.
38 40
39A menu item is usually a vector of three elements: [NAME CALLBACK t] 41A menu item is usually a vector of three elements: [NAME CALLBACK ENABLE]
40 42
41NAME is a string--the menu item name. 43NAME is a string--the menu item name.
42 44
43CALLBACK is a command to run when the item is chosen, 45CALLBACK is a command to run when the item is chosen,
44or a list to evaluate when the item is chosen. 46or a list to evaluate when the item is chosen.
45 47
48ENABLE is a symbol; if its value is non-nil, the item is enabled
49for selection.
50
46A menu item can be a string. Then that string appears in the menu as 51A menu item can be a string. Then that string appears in the menu as
47unselectable text. A string consisting solely of hyphens is displayed 52unselectable text. A string consisting solely of hyphens is displayed
48as a solid horizontal line. 53as a solid horizontal line.
@@ -51,12 +56,14 @@ A menu item can be a list. It is treated as a submenu.
51The first element should be the submenu name. That's used as the 56The first element should be the submenu name. That's used as the
52menu item in the top-level menu. The cdr of the submenu list 57menu item in the top-level menu. The cdr of the submenu list
53is a list of menu items, as above." 58is a list of menu items, as above."
54 (or (keymapp maps) (setq maps (list maps))) 59 (` (let* ((maps (, maps))
55 (let ((keymap (easy-menu-keymap (car menu) (cdr menu)))) 60 (menu (, menu))
56 (while maps 61 (keymap (easy-menu-keymap (car menu) (cdr menu))))
57 (define-key (car maps) (vector 'menu-bar (intern (car menu))) 62 (and (keymapp maps) (setq maps (list maps)))
58 (cons (car menu) keymap)) 63 (while maps
59 (setq maps (cdr maps))))) 64 (define-key (car maps) (vector 'menu-bar (intern (car menu)))
65 (cons (car menu) keymap))
66 (setq maps (cdr maps))))))
60 67
61(defvar easy-menu-item-count 0) 68(defvar easy-menu-item-count 0)
62 69
@@ -76,16 +83,15 @@ is a list of menu items, as above."
76 (setq name (if (string-match "^-+$" item) "" item))) 83 (setq name (if (string-match "^-+$" item) "" item)))
77 ((consp item) 84 ((consp item)
78 (setq command (easy-menu-keymap (car item) (cdr item))) 85 (setq command (easy-menu-keymap (car item) (cdr item)))
79 (setq name (car item))) 86 (setq name (concat (car item) "...")))
80 ((vectorp item) 87 ((vectorp item)
81 (setq command (make-symbol (format "menu-function-%d" 88 (setq command (make-symbol (format "menu-function-%d"
82 easy-menu-item-count))) 89 easy-menu-item-count)))
83 (setq enabler (make-symbol (format "menu-function-%d-enabler"
84 easy-menu-item-count)))
85 (setq easy-menu-item-count (1+ easy-menu-item-count)) 90 (setq easy-menu-item-count (1+ easy-menu-item-count))
86 (put command 'menu-enable enabler) 91 (put command 'menu-enable (aref item 2))
87 (set enabler (aref item 2))
88 (setq name (aref item 0)) 92 (setq name (aref item 0))
93 (if (keymapp callback)
94 (setq name (concat name " ...")))
89 (if (symbolp callback) 95 (if (symbolp callback)
90 (fset command callback) 96 (fset command callback)
91 (fset command (list 'lambda () '(interactive) callback))))) 97 (fset command (list 'lambda () '(interactive) callback)))))
@@ -98,6 +104,10 @@ is a list of menu items, as above."
98 (setq menu-items (cdr menu-items))) 104 (setq menu-items (cdr menu-items)))
99 menu)) 105 menu))
100 106
107(defmacro easy-menu-remove (menu))
108
109(defmacro easy-menu-add (menu &optional map))
110
101(provide 'easymenu) 111(provide 'easymenu)
102 112
103;;; easymenu.el ends here 113;;; easymenu.el ends here