Mercurial > hg > xemacs-beta
comparison lisp/utils/easymenu.el @ 2:ac2d302a0011 r19-15b2
Import from CVS: tag r19-15b2
author | cvs |
---|---|
date | Mon, 13 Aug 2007 08:46:35 +0200 |
parents | 376386a54a3c |
children | bcdc7deadc19 |
comparison
equal
deleted
inserted
replaced
1:c0c6a60d29db | 2:ac2d302a0011 |
---|---|
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.1.1.1 1996/12/18 03:32:46 steve Exp $ | 3 ;; $Id: easymenu.el,v 1.1.1.2 1996/12/18 03:45:41 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: 1996/12/18 03:32:46 $|$Revision: 1.1.1.1 $|~/misc/easymenu.el.gz| | 8 ;; $Date: 1996/12/18 03:45:41 $|$Revision: 1.1.1.2 $|~/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 program is free software; you can redistribute it and/or modify | 12 ;; This program is free software; you can redistribute it and/or modify |
13 ;; it under the terms of the GNU General Public License as published by | 13 ;; it under the terms of the GNU General Public License as published by |
142 (` (progn | 142 (` (progn |
143 (defvar (, symbol) nil (, doc)) | 143 (defvar (, symbol) nil (, doc)) |
144 (easy-menu-do-define (quote (, symbol)) (, maps) (, doc) (, menu))))) | 144 (easy-menu-do-define (quote (, symbol)) (, maps) (, doc) (, menu))))) |
145 | 145 |
146 (defun easy-menu-do-define (symbol maps doc menu) | 146 (defun easy-menu-do-define (symbol maps doc menu) |
147 (set symbol menu) | 147 (if (featurep 'menubar) |
148 (fset symbol (list 'lambda '(e) | 148 (progn |
149 doc | 149 (set symbol menu) |
150 '(interactive "@e") | 150 (fset symbol (list 'lambda '(e) |
151 '(run-hooks 'activate-menubar-hook) | 151 doc |
152 '(setq zmacs-region-stays 't) | 152 '(interactive "@e") |
153 (list 'popup-menu symbol)))) | 153 '(run-hooks 'activate-menubar-hook) |
154 '(setq zmacs-region-stays 't) | |
155 (list 'popup-menu symbol)))))) | |
154 | 156 |
155 (fset 'easy-menu-change (symbol-function 'add-menu)) | 157 (fset 'easy-menu-change (symbol-function 'add-menu)) |
156 | 158 |
159 ;; This variable hold the easy-menu mode menus of all major and | |
160 ;; minor modes currently in effect. | |
157 (defvar easy-menu-all-popups nil) | 161 (defvar easy-menu-all-popups nil) |
158 ;; This variable hold the easy-menu mode menus of all major and | 162 (make-variable-buffer-local 'easy-menu-all-popups) |
159 ;; minor modes currently in effect. | |
160 (make-variable-buffer-local 'easy-menu-all-popups) | |
161 | 163 |
162 (defun easy-menu-add (menu &optional map) | 164 (defun easy-menu-add (menu &optional map) |
163 "Add MENU to the current menu bar." | 165 "Add MENU to the current menu bar." |
164 (if easy-menu-all-popups | 166 (if (featurep 'menubar) |
165 (setq easy-menu-all-popups (cons menu easy-menu-all-popups)) | 167 (progn |
166 (setq easy-menu-all-popups (list menu mode-popup-menu))) | 168 (if easy-menu-all-popups |
167 (setq mode-popup-menu menu) | 169 (setq easy-menu-all-popups (cons menu easy-menu-all-popups)) |
170 (setq easy-menu-all-popups (list menu mode-popup-menu))) | |
171 (setq mode-popup-menu menu) | |
168 | 172 |
169 (cond ((null current-menubar) | 173 (cond ((null current-menubar) |
170 ;; Don't add it to a non-existing menubar. | 174 ;; Don't add it to a non-existing menubar. |
171 nil) | 175 nil) |
172 ((assoc (car menu) current-menubar) | 176 ((assoc (car menu) current-menubar) |
173 ;; Already present. | 177 ;; Already present. |
174 nil) | 178 nil) |
175 ((equal current-menubar '(nil)) | 179 ((equal current-menubar '(nil)) |
176 ;; Set at left if only contains right marker. | 180 ;; Set at left if only contains right marker. |
177 (set-buffer-menubar (list menu nil))) | 181 (set-buffer-menubar (list menu nil))) |
178 (t | 182 (t |
179 ;; Add at right. | 183 ;; Add at right. |
180 (set-buffer-menubar (copy-sequence current-menubar)) | 184 (set-buffer-menubar (copy-sequence current-menubar)) |
181 (add-menu nil (car menu) (cdr menu))))) | 185 (add-menu nil (car menu) (cdr menu))))))) |
182 | 186 |
183 (defun easy-menu-remove (menu) | 187 (defun easy-menu-remove (menu) |
184 "Remove MENU from the current menu bar." | 188 "Remove MENU from the current menu bar." |
185 (setq easy-menu-all-popups (delq menu easy-menu-all-popups) | 189 (if (featurep 'menubar) |
186 mode-popup-menu (car easy-menu-all-popups)) | 190 (progn |
187 (and current-menubar | 191 (setq easy-menu-all-popups (delq menu easy-menu-all-popups) |
188 (assoc (car menu) current-menubar) | 192 mode-popup-menu (car easy-menu-all-popups)) |
189 (delete-menu-item (list (car menu))))) | 193 (and current-menubar |
194 (assoc (car menu) current-menubar) | |
195 (delete-menu-item (list (car menu))))))) | |
190 | 196 |
191 (provide 'easymenu) | 197 (provide 'easymenu) |
192 | 198 |
193 ;;; easymenu.el ends here | 199 ;;; easymenu.el ends here |