annotate lisp/easymenu.el @ 215:1f0dabaa0855 r20-4b6

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