Mercurial > hg > xemacs-beta
comparison lisp/easymenu.el @ 377:d883f39b8495 r21-2b4
Import from CVS: tag r21-2b4
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:05:42 +0200 |
parents | cc15677e0335 |
children | 8626e4521993 |
comparison
equal
deleted
inserted
replaced
376:e2295b4d9f2e | 377:d883f39b8495 |
---|---|
21 ;; You should have received a copy of the GNU General Public License | 21 ;; You should have received a copy of the GNU General Public License |
22 ;; along with XEmacs; if not, write to the Free Software | 22 ;; along with XEmacs; if not, write to the Free Software |
23 ;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | 23 ;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
24 ;; 02111-1307, USA. | 24 ;; 02111-1307, USA. |
25 | 25 |
26 ;;; Synched up with: Not synched with FSF. | 26 ;;; Synched up with: Not synched with FSF but coordinated with the FSF |
27 ;;; easymenu maintor for compatability with FSF 20.4. | |
28 ;;; Please: Coordinate changes with Inge Frick <inge@nada.kth.se> | |
27 | 29 |
28 ;; Commentary: | 30 ;; Commentary: |
29 | 31 |
30 ;; This file is dumped with XEmacs. | 32 ;; This file is dumped with XEmacs. |
31 | 33 |
60 ;; - Function: easy-menu-add MENU [ MAP ] | 62 ;; - Function: easy-menu-add MENU [ MAP ] |
61 ;; Add MENU to the current menubar in MAP. | 63 ;; Add MENU to the current menubar in MAP. |
62 | 64 |
63 ;; - Function: easy-menu-remove MENU | 65 ;; - Function: easy-menu-remove MENU |
64 ;; Remove MENU from the current menubar. | 66 ;; Remove MENU from the current menubar. |
67 | |
68 ;; - Function: easy-menu-add-item | |
69 ;; Add item or submenu to existing menu | |
70 | |
71 ;; - Function: easy-menu-item-present-p | |
72 ;; Locate item | |
73 | |
74 ;; - Function: easy-menu-remove-item | |
75 ;; Delete item from menu. | |
65 | 76 |
66 ;; Emacs 19 never uses `easy-menu-add' or `easy-menu-remove', menus | 77 ;; Emacs 19 never uses `easy-menu-add' or `easy-menu-remove', menus |
67 ;; automatically appear and disappear when the keymaps specified by | 78 ;; automatically appear and disappear when the keymaps specified by |
68 ;; the MAPS argument to `easy-menu-define' are activated. | 79 ;; the MAPS argument to `easy-menu-define' are activated. |
69 | 80 |
198 | 209 |
199 (and current-menubar | 210 (and current-menubar |
200 (assoc (car menu) current-menubar) | 211 (assoc (car menu) current-menubar) |
201 (delete-menu-item (list (car menu))))))) | 212 (delete-menu-item (list (car menu))))))) |
202 | 213 |
214 (defsubst easy-menu-normalize (menu) | |
215 (if (symbolp menu) | |
216 (symbol-value menu) | |
217 menu)) | |
218 | |
219 (defun easy-menu-add-item (menu path item &optional before) | |
220 "At the end of the submenu of MENU with path PATH add ITEM. | |
221 If ITEM is already present in this submenu, then this item will be changed. | |
222 otherwise ITEM will be added at the end of the submenu, unless the optional | |
223 argument BEFORE is present, in which case ITEM will instead be added | |
224 before the item named BEFORE. | |
225 MENU is either a symbol, which have earlier been used as the first | |
226 argument in a call to `easy-menu-define', or the value of such a symbol | |
227 i.e. a menu, or nil which stands for the current menubar. | |
228 PATH is a list of strings for locating the submenu where ITEM is to be | |
229 added. If PATH is nil, MENU itself is used. Otherwise, the first | |
230 element should be the name of a submenu directly under MENU. This | |
231 submenu is then traversed recursively with the remaining elements of PATH. | |
232 ITEM is either defined as in `easy-menu-define', a menu defined earlier | |
233 by `easy-menu-define' or `easy-menu-create-menu' or an item returned | |
234 from `easy-menu-item-present-p' or `easy-menu-remove-item'." | |
235 (add-menu-button path item before (easy-menu-normalize menu))) | |
236 | |
237 (defun easy-menu-item-present-p (menu path name) | |
238 "In submenu of MENU with path PATH, return true iff item NAME is present. | |
239 MENU and PATH are defined as in `easy-menu-add-item'. | |
240 NAME should be a string, the name of the element to be looked for. | |
241 | |
242 The return value can be used as as an argument to `easy-menu-add-item'." | |
243 (car (find-menu-item (or (easy-menu-normalize menu) current-menubar) | |
244 (append path (list name))))) | |
245 | |
246 (defun easy-menu-remove-item (menu path name) | |
247 "From submenu of MENU with path PATH remove item NAME. | |
248 MENU and PATH are defined as in `easy-menu-add-item'. | |
249 NAME should be a string, the name of the element to be removed. | |
250 | |
251 The return value can be used as as an argument to `easy-menu-add-item'." | |
252 (delete-menu-item (append path (list name)) | |
253 (easy-menu-normalize menu))) | |
254 | |
255 | |
256 | |
257 | |
203 ;; Think up a good title for the menu. Take the major-mode of the | 258 ;; Think up a good title for the menu. Take the major-mode of the |
204 ;; buffer, strip the -mode part, convert hyphens to spaces, and | 259 ;; buffer, strip the -mode part, convert hyphens to spaces, and |
205 ;; capitalize it. | 260 ;; capitalize it. |
206 ;; | 261 ;; |
207 ;; If you can think of something smarter, feel free to replace it. | 262 ;; If you can think of something smarter, feel free to replace it. |