annotate lisp/utils/easymenu.el @ 151:59463afc5666 r20-3b2

Import from CVS: tag r20-3b2
author cvs
date Mon, 13 Aug 2007 09:37:19 +0200
parents 1370575f1259
children 15872534500d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; easymenu.el - Easy menu support for Emacs 19 and XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;;
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 126
diff changeset
3 ;; $Id: easymenu.el,v 1.4 1997/05/23 01:36:43 steve Exp $
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; LCD Archive Entry:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; easymenu|Per Abrahamsen|abraham@iesd.auc.dk|
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; Easy menu support for XEmacs|
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 126
diff changeset
8 ;; $Date: 1997/05/23 01:36:43 $|$Revision: 1.4 $|~/misc/easymenu.el.gz|
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; Copyright (C) 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
11
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
12 ;; This file is part of XEmacs.
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
13
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
14 ;; XEmacs is free software; you can redistribute it and/or modify
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 12
diff changeset
15 ;; it under the terms of the GNU General Public License as published by
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; any later version.
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
18
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
19 ;; XEmacs is distributed in the hope that it will be useful,
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 12
diff changeset
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 12
diff changeset
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 12
diff changeset
22 ;; GNU General Public License for more details.
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
23
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;; You should have received a copy of the GNU General Public License
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
25 ;; along with XEmacs; if not, write to the Free Software
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
26 ;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
27 ;; 02111-1307, USA.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;;; Synched up with: Not synched with FSF.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;;; In RMS's typical lame-ass way, he removed all support for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;;; what he calls "other Emacs versions" from the version of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;;; easymenu.el included in FSF. He also incorrectly claims
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;;; himself as the author rather than Per Abrahamsen.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;; Easymenu allows you to define menus for both Emacs 19 and XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;; This file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;; The advantages of using easymenu are:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ;; - Easier to use than either the Emacs 19 and XEmacs menu syntax.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;; - Common interface for Emacs 18, Emacs 19, and XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;; (The code does nothing when run under Emacs 18).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ;; The public functions are:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 ;; - Function: easy-menu-define SYMBOL MAPS DOC MENU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 ;; SYMBOL is both the name of the variable that holds the menu and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ;; the name of a function that will present a the menu.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 ;; MAPS is a list of keymaps where the menu should appear in the menubar.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ;; DOC is the documentation string for the variable.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ;; MENU is an XEmacs style menu description.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 ;; See the documentation for easy-menu-define for details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 ;; - Function: easy-menu-change PATH NAME ITEMS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 ;; Change an existing menu.
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 12
diff changeset
60 ;; The menu must already exist and be visible on the menu bar.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 ;; PATH is a list of strings used for locating the menu on the menu bar.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 ;; NAME is the name of the menu.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 ;; ITEMS is a list of menu items, as defined in `easy-menu-define'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 ;; - Function: easy-menu-add MENU [ MAP ]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 ;; Add MENU to the current menubar in MAP.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 ;; - Function: easy-menu-remove MENU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 ;; Remove MENU from the current menubar.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 ;; Emacs 19 never uses `easy-menu-add' or `easy-menu-remove', menus
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 ;; automatically appear and disappear when the keymaps specified by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 ;; the MAPS argument to `easy-menu-define' are activated.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 ;; XEmacs will bind the map to button3 in each MAPS, but you must
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 ;; explicitly call `easy-menu-add' and `easy-menu-remove' to add and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 ;; remove menus from the menu bar.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (defmacro easy-menu-define (symbol maps doc menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 "Define a menu bar submenu in maps MAPS, according to MENU.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 The arguments SYMBOL and DOC are ignored; they are present for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 compatibility only. SYMBOL is not evaluated. In other Emacs versions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 these arguments may be used as a variable to hold the menu data, and a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 doc string for that variable.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 The first element of MENU must be a string. It is the menu bar item name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 The rest of the elements are menu items.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 A menu item is usually a vector of three elements: [NAME CALLBACK ENABLE]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 NAME is a string--the menu item name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 CALLBACK is a command to run when the item is chosen,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 or a list to evaluate when the item is chosen.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 ENABLE is an expression; the item is enabled for selection
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 whenever this expression's value is non-nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 Alternatively, a menu item may have the form:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 [ NAME CALLBACK [ KEYWORD ARG ] ... ]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 Where KEYWORD is one of the symbol defined below.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 :keys KEYS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 KEYS is a string; a complex keyboard equivalent to this menu item.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 :active ENABLE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 ENABLE is an expression; the item is enabled for selection
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 whenever this expression's value is non-nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 :suffix NAME
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 NAME is a string; the name of an argument to CALLBACK.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 :style STYLE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 STYLE is a symbol describing the type of menu item. The following are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 defined:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 toggle: A checkbox.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 Currently just prepend the name with the string \"Toggle \".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 radio: A radio button.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 nil: An ordinary menu item.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 :selected SELECTED
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 SELECTED is an expression; the checkbox or radio button is selected
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 whenever this expression's value is non-nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 Currently just disable radio buttons, no effect on checkboxes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 A menu item can be a string. Then that string appears in the menu as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 unselectable text. A string consisting solely of hyphens is displayed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 as a solid horizontal line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 A menu item can be a list. It is treated as a submenu.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 The first element should be the submenu name. That's used as the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 menu item in the top-level menu. The cdr of the submenu list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 is a list of menu items, as above."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (` (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (defvar (, symbol) nil (, doc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (easy-menu-do-define (quote (, symbol)) (, maps) (, doc) (, menu)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (defun easy-menu-do-define (symbol maps doc menu)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
150 (if (featurep 'menubar)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
151 (progn
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
152 (set symbol menu)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
153 (fset symbol (list 'lambda '(e)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
154 doc
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
155 '(interactive "@e")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
156 '(run-hooks 'activate-menubar-hook)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
157 '(setq zmacs-region-stays 't)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
158 (list 'popup-menu symbol))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (fset 'easy-menu-change (symbol-function 'add-menu))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
162 ;; This variable hold the easy-menu mode menus of all major and
126
1370575f1259 Import from CVS: tag xemacs-20-1p1
cvs
parents: 78
diff changeset
163 ;; minor modes currently in effect in the current buffer.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (defvar easy-menu-all-popups nil)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
165 (make-variable-buffer-local 'easy-menu-all-popups)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (defun easy-menu-add (menu &optional map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 "Add MENU to the current menu bar."
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
169 (if (featurep 'menubar)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
170 (progn
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 126
diff changeset
171 (pushnew menu easy-menu-all-popups)
126
1370575f1259 Import from CVS: tag xemacs-20-1p1
cvs
parents: 78
diff changeset
172 (setq mode-popup-menu (cons (easy-menu-title)
1370575f1259 Import from CVS: tag xemacs-20-1p1
cvs
parents: 78
diff changeset
173 (reverse easy-menu-all-popups)))
1370575f1259 Import from CVS: tag xemacs-20-1p1
cvs
parents: 78
diff changeset
174
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
175 (cond ((null current-menubar)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
176 ;; Don't add it to a non-existing menubar.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
177 nil)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
178 ((assoc (car menu) current-menubar)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
179 ;; Already present.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
180 nil)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
181 ((equal current-menubar '(nil))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
182 ;; Set at left if only contains right marker.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
183 (set-buffer-menubar (list menu nil)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
184 (t
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
185 ;; Add at right.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
186 (set-buffer-menubar (copy-sequence current-menubar))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
187 (add-menu nil (car menu) (cdr menu)))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (defun easy-menu-remove (menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 "Remove MENU from the current menu bar."
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
191 (if (featurep 'menubar)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
192 (progn
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
193 (setq easy-menu-all-popups (delq menu easy-menu-all-popups)
126
1370575f1259 Import from CVS: tag xemacs-20-1p1
cvs
parents: 78
diff changeset
194 mode-popup-menu (cons (easy-menu-title)
1370575f1259 Import from CVS: tag xemacs-20-1p1
cvs
parents: 78
diff changeset
195 (reverse easy-menu-all-popups)))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
196 (and current-menubar
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
197 (assoc (car menu) current-menubar)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
198 (delete-menu-item (list (car menu)))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199
126
1370575f1259 Import from CVS: tag xemacs-20-1p1
cvs
parents: 78
diff changeset
200 ;; Think up a good title for the menu. Take the major-mode of the
1370575f1259 Import from CVS: tag xemacs-20-1p1
cvs
parents: 78
diff changeset
201 ;; buffer, strip the -mode part, convert hyphens to spaces, and
1370575f1259 Import from CVS: tag xemacs-20-1p1
cvs
parents: 78
diff changeset
202 ;; capitalize it.
1370575f1259 Import from CVS: tag xemacs-20-1p1
cvs
parents: 78
diff changeset
203 ;;
1370575f1259 Import from CVS: tag xemacs-20-1p1
cvs
parents: 78
diff changeset
204 ;; If you can think of something smarter, feel free to replace it.
1370575f1259 Import from CVS: tag xemacs-20-1p1
cvs
parents: 78
diff changeset
205 ;; Don't forget to mail the change to xemacs@xemacs.org where everyone
1370575f1259 Import from CVS: tag xemacs-20-1p1
cvs
parents: 78
diff changeset
206 ;; can flame, er, praise your changes.
1370575f1259 Import from CVS: tag xemacs-20-1p1
cvs
parents: 78
diff changeset
207 (defun easy-menu-title ()
1370575f1259 Import from CVS: tag xemacs-20-1p1
cvs
parents: 78
diff changeset
208 (capitalize (replace-in-string (replace-in-string
1370575f1259 Import from CVS: tag xemacs-20-1p1
cvs
parents: 78
diff changeset
209 (symbol-name major-mode) "-mode$" "")
1370575f1259 Import from CVS: tag xemacs-20-1p1
cvs
parents: 78
diff changeset
210 "-" " ")))
1370575f1259 Import from CVS: tag xemacs-20-1p1
cvs
parents: 78
diff changeset
211
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (provide 'easymenu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 ;;; easymenu.el ends here