Mercurial > hg > xemacs-beta
comparison lisp/utils/easymenu.el @ 169:15872534500d r20-3b11
Import from CVS: tag r20-3b11
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:46:53 +0200 |
parents | 59463afc5666 |
children | 929b76928fce |
comparison
equal
deleted
inserted
replaced
168:9851d5c6556e | 169:15872534500d |
---|---|
1 ;;; easymenu.el - Easy menu support for Emacs 19 and XEmacs. | 1 ;;; easymenu.el - Easy menu support for Emacs 19 and XEmacs. |
2 ;; | 2 ;; |
3 ;; $Id: easymenu.el,v 1.4 1997/05/23 01:36:43 steve Exp $ | 3 ;; $Id: easymenu.el,v 1.5 1997/07/07 00:53:20 steve Exp $ |
4 ;; | 4 ;; |
5 ;; LCD Archive Entry: | 5 ;; LCD Archive Entry: |
6 ;; easymenu|Per Abrahamsen|abraham@iesd.auc.dk| | 6 ;; easymenu|Per Abrahamsen|abraham@iesd.auc.dk| |
7 ;; Easy menu support for XEmacs| | 7 ;; Easy menu support for XEmacs| |
8 ;; $Date: 1997/05/23 01:36:43 $|$Revision: 1.4 $|~/misc/easymenu.el.gz| | 8 ;; $Date: 1997/07/07 00:53:20 $|$Revision: 1.5 $|~/misc/easymenu.el.gz| |
9 | 9 |
10 ;; Copyright (C) 1992, 1993, 1994, 1995 Free Software Foundation, Inc. | 10 ;; Copyright (C) 1992, 1993, 1994, 1995 Free Software Foundation, Inc. |
11 | 11 |
12 ;; This file is part of XEmacs. | 12 ;; This file is part of XEmacs. |
13 | 13 |
76 ;; explicitly call `easy-menu-add' and `easy-menu-remove' to add and | 76 ;; explicitly call `easy-menu-add' and `easy-menu-remove' to add and |
77 ;; remove menus from the menu bar. | 77 ;; remove menus from the menu bar. |
78 | 78 |
79 ;;; Code: | 79 ;;; Code: |
80 | 80 |
81 ;;;###autoload | 81 ;; ;;;###autoload |
82 (defmacro easy-menu-define (symbol maps doc menu) | 82 (defmacro easy-menu-define (symbol maps doc menu) |
83 "Define a menu bar submenu in maps MAPS, according to MENU. | 83 "Define a menu bar submenu in maps MAPS, according to MENU. |
84 The arguments SYMBOL and DOC are ignored; they are present for | 84 The arguments SYMBOL and DOC are ignored; they are present for |
85 compatibility only. SYMBOL is not evaluated. In other Emacs versions | 85 compatibility only. SYMBOL is not evaluated. In other Emacs versions |
86 these arguments may be used as a variable to hold the menu data, and a | 86 these arguments may be used as a variable to hold the menu data, and a |
167 (defun easy-menu-add (menu &optional map) | 167 (defun easy-menu-add (menu &optional map) |
168 "Add MENU to the current menu bar." | 168 "Add MENU to the current menu bar." |
169 (if (featurep 'menubar) | 169 (if (featurep 'menubar) |
170 (progn | 170 (progn |
171 (pushnew menu easy-menu-all-popups) | 171 (pushnew menu easy-menu-all-popups) |
172 (setq mode-popup-menu (cons (easy-menu-title) | 172 (setq mode-popup-menu (if (< (length easy-menu-all-popups) 1) |
173 (reverse easy-menu-all-popups))) | 173 (cons (easy-menu-title) |
174 (reverse easy-menu-all-popups)) | |
175 (car easy-menu-all-popups))) | |
174 | 176 |
175 (cond ((null current-menubar) | 177 (cond ((null current-menubar) |
176 ;; Don't add it to a non-existing menubar. | 178 ;; Don't add it to a non-existing menubar. |
177 nil) | 179 nil) |
178 ((assoc (car menu) current-menubar) | 180 ((assoc (car menu) current-menubar) |
189 (defun easy-menu-remove (menu) | 191 (defun easy-menu-remove (menu) |
190 "Remove MENU from the current menu bar." | 192 "Remove MENU from the current menu bar." |
191 (if (featurep 'menubar) | 193 (if (featurep 'menubar) |
192 (progn | 194 (progn |
193 (setq easy-menu-all-popups (delq menu easy-menu-all-popups) | 195 (setq easy-menu-all-popups (delq menu easy-menu-all-popups) |
194 mode-popup-menu (cons (easy-menu-title) | 196 mode-popup-menu (if (< (length easy-menu-all-popups) 1) |
195 (reverse easy-menu-all-popups))) | 197 (cons (easy-menu-title) |
198 (reverse easy-menu-all-popups)) | |
199 (car easy-menu-all-popups))) | |
200 | |
196 (and current-menubar | 201 (and current-menubar |
197 (assoc (car menu) current-menubar) | 202 (assoc (car menu) current-menubar) |
198 (delete-menu-item (list (car menu))))))) | 203 (delete-menu-item (list (car menu))))))) |
199 | 204 |
200 ;; Think up a good title for the menu. Take the major-mode of the | 205 ;; Think up a good title for the menu. Take the major-mode of the |