Mercurial > emacs
annotate lisp/emacs-lisp/lmenu.el @ 13363:941c37982f37
(BITS_PER_SHORT, BITS_PER_INT, BITS_PER_LONG):
Rename from SHORTBITS, INTBITS, LONGBITS.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Tue, 31 Oct 1995 02:34:16 +0000 |
parents | 3bc36769004f |
children | 83f275dcd93a |
rev | line source |
---|---|
2232
4f9d60f7de9d
Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2231
diff
changeset
|
1 ;;; lmenu.el --- emulate Lucid's menubar support |
4f9d60f7de9d
Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2231
diff
changeset
|
2 |
2233
fb0ed5a1d0f3
Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2232
diff
changeset
|
3 ;; Keywords: emulations |
fb0ed5a1d0f3
Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2232
diff
changeset
|
4 |
7298 | 5 ;; Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc. |
2231 | 6 |
7 ;; This file is part of GNU Emacs. | |
8 | |
9 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
10 ;; it under the terms of the GNU General Public License as published by | |
11 ;; the Free Software Foundation; either version 2, or (at your option) | |
12 ;; any later version. | |
13 | |
14 ;; GNU Emacs is distributed in the hope that it will be useful, | |
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 ;; GNU General Public License for more details. | |
18 | |
19 ;; You should have received a copy of the GNU General Public License | |
20 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
21 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
22 | |
2232
4f9d60f7de9d
Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2231
diff
changeset
|
23 ;;; Code: |
4f9d60f7de9d
Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2231
diff
changeset
|
24 |
2231 | 25 |
26 ;; First, emulate the Lucid menubar support in GNU Emacs 19. | |
27 | |
28 ;; Arrange to use current-menubar to set up part of the menu bar. | |
29 | |
7656
d50e5481aae2
(popup-dialog-box): Bind meaning with let.
Richard M. Stallman <rms@gnu.org>
parents:
7655
diff
changeset
|
30 (defvar current-menubar) |
d50e5481aae2
(popup-dialog-box): Bind meaning with let.
Richard M. Stallman <rms@gnu.org>
parents:
7655
diff
changeset
|
31 |
2231 | 32 (setq recompute-lucid-menubar 'recompute-lucid-menubar) |
33 (defun recompute-lucid-menubar () | |
34 (define-key lucid-menubar-map [menu-bar] | |
35 (condition-case nil | |
36 (make-lucid-menu-keymap "menu-bar" current-menubar) | |
37 (error (message "Invalid data in current-menubar moved to lucid-failing-menubar") | |
38 (sit-for 1) | |
39 (setq lucid-failing-menubar current-menubar | |
40 current-menubar nil)))) | |
41 (setq lucid-menu-bar-dirty-flag nil)) | |
42 | |
43 (defvar lucid-menubar-map (make-sparse-keymap)) | |
44 (or (assq 'current-menubar minor-mode-map-alist) | |
45 (setq minor-mode-map-alist | |
46 (cons (cons 'current-menubar lucid-menubar-map) | |
47 minor-mode-map-alist))) | |
48 | |
49 (defun set-menubar-dirty-flag () | |
50 (force-mode-line-update) | |
51 (setq lucid-menu-bar-dirty-flag t)) | |
52 | |
53 (defvar add-menu-item-count 0) | |
54 | |
8868
5eff9b0c1a43
(make-lucid-menu-keymap-disable): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8051
diff
changeset
|
55 ;; This is a variable whose value is always nil. |
5eff9b0c1a43
(make-lucid-menu-keymap-disable): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8051
diff
changeset
|
56 (defvar make-lucid-menu-keymap-disable nil) |
5eff9b0c1a43
(make-lucid-menu-keymap-disable): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8051
diff
changeset
|
57 |
2231 | 58 ;; Return a menu keymap corresponding to a Lucid-style menu list |
59 ;; MENU-ITEMS, and with name MENU-NAME. | |
60 (defun make-lucid-menu-keymap (menu-name menu-items) | |
61 (let ((menu (make-sparse-keymap menu-name))) | |
62 ;; Process items in reverse order, | |
63 ;; since the define-key loop reverses them again. | |
64 (setq menu-items (reverse menu-items)) | |
65 (while menu-items | |
9523
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
66 (let ((item (car menu-items)) |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
67 command name callback) |
2231 | 68 (cond ((stringp item) |
69 (setq command nil) | |
6445
19bf0e182eda
(make-lucid-menu-keymap): Any row of dashes means blank.
Karl Heuer <kwzh@gnu.org>
parents:
6435
diff
changeset
|
70 (setq name (if (string-match "^-+$" item) "" item))) |
2231 | 71 ((consp item) |
72 (setq command (make-lucid-menu-keymap (car item) (cdr item))) | |
73 (setq name (car item))) | |
74 ((vectorp item) | |
75 (setq command (make-symbol (format "menu-function-%d" | |
9523
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
76 add-menu-item-count)) |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
77 add-menu-item-count (1+ add-menu-item-count) |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
78 name (aref item 0) |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
79 callback (aref item 1)) |
2231 | 80 (if (symbolp callback) |
81 (fset command callback) | |
9523
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
82 (fset command (list 'lambda () '(interactive) callback))) |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
83 (let ((i 2)) |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
84 (while (< i (length item)) |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
85 (cond |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
86 ((eq (aref item i) ':active) |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
87 (put command 'menu-enable |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
88 (or (aref item (1+ i)) |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
89 'make-lucid-menu-keymap-disable)) |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
90 (setq i (+ 2 i))) |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
91 ((eq (aref item i) ':suffix) |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
92 ;; unimplemented |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
93 (setq i (+ 2 i))) |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
94 ((eq (aref item i) ':keys) |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
95 ;; unimplemented |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
96 (setq i (+ 2 i))) |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
97 ((eq (aref item i) ':style) |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
98 ;; unimplemented |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
99 (setq i (+ 2 i))) |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
100 ((eq (aref item i) ':selected) |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
101 ;; unimplemented |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
102 (setq i (+ 2 i))) |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
103 ((and (symbolp (aref item i)) |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
104 (= ?: (string-to-char (symbol-name (aref item i))))) |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
105 (error "Unrecognized menu item keyword: %S" |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
106 (aref item i))) |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
107 ((= i 2) |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
108 ;; old-style format: active-p &optional suffix |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
109 (put command 'menu-enable |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
110 (or (aref item i) 'make-lucid-menu-keymap-disable)) |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
111 ;; suffix is unimplemented |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
112 (setq i (length item))) |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
113 (t |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
114 (error "Unexpected menu item value: %S" |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
115 (aref item i)))))))) |
5477
2efe469a9c24
(make-lucid-menu-keymap): Allow multiple identical inactive strings.
Richard M. Stallman <rms@gnu.org>
parents:
5461
diff
changeset
|
116 (if (null command) |
2efe469a9c24
(make-lucid-menu-keymap): Allow multiple identical inactive strings.
Richard M. Stallman <rms@gnu.org>
parents:
5461
diff
changeset
|
117 ;; Handle inactive strings specially--allow any number |
2efe469a9c24
(make-lucid-menu-keymap): Allow multiple identical inactive strings.
Richard M. Stallman <rms@gnu.org>
parents:
5461
diff
changeset
|
118 ;; of identical ones. |
2efe469a9c24
(make-lucid-menu-keymap): Allow multiple identical inactive strings.
Richard M. Stallman <rms@gnu.org>
parents:
5461
diff
changeset
|
119 (setcdr menu (cons (list nil name) (cdr menu))) |
9523
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
120 (if name |
5477
2efe469a9c24
(make-lucid-menu-keymap): Allow multiple identical inactive strings.
Richard M. Stallman <rms@gnu.org>
parents:
5461
diff
changeset
|
121 (define-key menu (vector (intern name)) (cons name command))))) |
2231 | 122 (setq menu-items (cdr menu-items))) |
123 menu)) | |
124 | |
125 (defun popup-menu (menu-desc) | |
126 "Pop up the given menu. | |
127 A menu is a list of menu items, strings, and submenus. | |
128 | |
129 The first element of a menu must be a string, which is the name of the | |
130 menu. This is the string that will be displayed in the parent menu, if | |
131 any. For toplevel menus, it is ignored. This string is not displayed | |
132 in the menu itself. | |
133 | |
9523
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
134 A menu item is a vector containing: |
2231 | 135 |
136 - the name of the menu item (a string); | |
137 - the `callback' of that item; | |
9523
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
138 - a list of keywords with associated values: |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
139 - :active active-p a form specifying whether this item is selectable; |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
140 - :suffix suffix a string to be appended to the name as an `argument' |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
141 to the command, like `Kill Buffer NAME'; |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
142 - :keys command-keys a string, suitable for `substitute-command-keys', |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
143 to specify the keyboard equivalent of a command |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
144 when the callback is a form (this is not necessary |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
145 when the callback is a symbol, as the keyboard |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
146 equivalent is computed automatically in that case); |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
147 - :style style a symbol: nil for a normal menu item, `toggle' for |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
148 a toggle button (a single option that can be turned |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
149 on or off), or `radio' for a radio button (one of a |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
150 group of mutually exclusive options); |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
151 - :selected form for `toggle' or `radio' style, a form that specifies |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
152 whether the button will be in the selected state. |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
153 |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
154 Alternately, the vector may contain exactly 3 or 4 elements, with the third |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
155 element specifying `active-p' and the fourth specifying `suffix'. |
2231 | 156 |
157 If the `callback' of a menu item is a symbol, then it must name a command. | |
158 It will be invoked with `call-interactively'. If it is a list, then it is | |
159 evaluated with `eval'. | |
160 | |
161 If an element of a menu is a string, then that string will be presented in | |
162 the menu as unselectable text. | |
163 | |
164 If an element of a menu is a string consisting solely of hyphens, then that | |
165 item will be presented as a solid horizontal line. | |
166 | |
167 If an element of a menu is a list, it is treated as a submenu. The name of | |
168 that submenu (the first element in the list) will be used as the name of the | |
169 item representing this menu on the parent. | |
170 | |
171 The syntax, more precisely: | |
172 | |
173 form := <something to pass to `eval'> | |
174 command := <a symbol or string, to pass to `call-interactively'> | |
175 callback := command | form | |
176 active-p := <t or nil, whether this thing is selectable> | |
177 text := <string, non selectable> | |
178 name := <string> | |
9523
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
179 suffix := <string> |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
180 command-keys := <string> |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
181 object-style := 'nil' | 'toggle' | 'radio' |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
182 keyword := ':active' active-p |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
183 | ':suffix' suffix |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
184 | ':keys' command-keys |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
185 | ':style' object-style |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
186 | ':selected' form |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
187 menu-item := '[' name callback active-p [ suffix ] ']' |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
188 | '[' name callback [ keyword ]+ ']' |
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
189 menu := '(' name [ menu-item | menu | text ]+ ')'" |
2231 | 190 (let ((menu (make-lucid-menu-keymap (car menu-desc) (cdr menu-desc))) |
7641
2db2ad2025c4
(popup-menu): Use mouse-pixel-position.
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
191 (pos (mouse-pixel-position)) |
7655
9134274acb76
(popup-menu): Bind cmd with let.
Richard M. Stallman <rms@gnu.org>
parents:
7641
diff
changeset
|
192 answer cmd) |
8051
a320525f4d8f
(popup-menu): Allow user to select nothing.
Karl Heuer <kwzh@gnu.org>
parents:
8038
diff
changeset
|
193 (while (and menu |
a320525f4d8f
(popup-menu): Allow user to select nothing.
Karl Heuer <kwzh@gnu.org>
parents:
8038
diff
changeset
|
194 (setq answer (x-popup-menu (list (list (nth 1 pos) |
a320525f4d8f
(popup-menu): Allow user to select nothing.
Karl Heuer <kwzh@gnu.org>
parents:
8038
diff
changeset
|
195 (nthcdr 2 pos)) |
a320525f4d8f
(popup-menu): Allow user to select nothing.
Karl Heuer <kwzh@gnu.org>
parents:
8038
diff
changeset
|
196 (car pos)) |
a320525f4d8f
(popup-menu): Allow user to select nothing.
Karl Heuer <kwzh@gnu.org>
parents:
8038
diff
changeset
|
197 menu))) |
8038
bffab6b07862
(popup-menu): Convert list to same-size vector, not singleton vector.
Karl Heuer <kwzh@gnu.org>
parents:
7742
diff
changeset
|
198 (setq cmd (lookup-key menu (apply 'vector answer))) |
5439
77798fccc85c
(popup-menu): Add loop to handle submenus.
Richard M. Stallman <rms@gnu.org>
parents:
2751
diff
changeset
|
199 (setq menu nil) |
77798fccc85c
(popup-menu): Add loop to handle submenus.
Richard M. Stallman <rms@gnu.org>
parents:
2751
diff
changeset
|
200 (and cmd |
77798fccc85c
(popup-menu): Add loop to handle submenus.
Richard M. Stallman <rms@gnu.org>
parents:
2751
diff
changeset
|
201 (if (keymapp cmd) |
77798fccc85c
(popup-menu): Add loop to handle submenus.
Richard M. Stallman <rms@gnu.org>
parents:
2751
diff
changeset
|
202 (setq menu cmd) |
77798fccc85c
(popup-menu): Add loop to handle submenus.
Richard M. Stallman <rms@gnu.org>
parents:
2751
diff
changeset
|
203 (call-interactively cmd)))))) |
6744
67485a72803d
(popup-dialog-box): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6445
diff
changeset
|
204 |
67485a72803d
(popup-dialog-box): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6445
diff
changeset
|
205 (defun popup-dialog-box (data) |
67485a72803d
(popup-dialog-box): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6445
diff
changeset
|
206 "Pop up a dialog box. |
67485a72803d
(popup-dialog-box): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6445
diff
changeset
|
207 A dialog box description is a list. |
67485a72803d
(popup-dialog-box): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6445
diff
changeset
|
208 |
67485a72803d
(popup-dialog-box): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6445
diff
changeset
|
209 - The first element of the list is a string to display in the dialog box. |
67485a72803d
(popup-dialog-box): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6445
diff
changeset
|
210 - The rest of the elements are descriptions of the dialog box's buttons. |
67485a72803d
(popup-dialog-box): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6445
diff
changeset
|
211 Each one is a vector of three elements: |
67485a72803d
(popup-dialog-box): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6445
diff
changeset
|
212 - The first element is the text of the button. |
67485a72803d
(popup-dialog-box): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6445
diff
changeset
|
213 - The second element is the `callback'. |
67485a72803d
(popup-dialog-box): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6445
diff
changeset
|
214 - The third element is t or nil, whether this button is selectable. |
67485a72803d
(popup-dialog-box): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6445
diff
changeset
|
215 |
67485a72803d
(popup-dialog-box): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6445
diff
changeset
|
216 If the `callback' of a button is a symbol, then it must name a command. |
67485a72803d
(popup-dialog-box): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6445
diff
changeset
|
217 It will be invoked with `call-interactively'. If it is a list, then it is |
67485a72803d
(popup-dialog-box): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6445
diff
changeset
|
218 evaluated with `eval'. |
67485a72803d
(popup-dialog-box): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6445
diff
changeset
|
219 |
67485a72803d
(popup-dialog-box): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6445
diff
changeset
|
220 One (and only one) of the buttons may be `nil'. This marker means that all |
67485a72803d
(popup-dialog-box): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6445
diff
changeset
|
221 following buttons should be flushright instead of flushleft. |
67485a72803d
(popup-dialog-box): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6445
diff
changeset
|
222 |
67485a72803d
(popup-dialog-box): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6445
diff
changeset
|
223 The syntax, more precisely: |
67485a72803d
(popup-dialog-box): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6445
diff
changeset
|
224 |
67485a72803d
(popup-dialog-box): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6445
diff
changeset
|
225 form := <something to pass to `eval'> |
67485a72803d
(popup-dialog-box): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6445
diff
changeset
|
226 command := <a symbol or string, to pass to `call-interactively'> |
67485a72803d
(popup-dialog-box): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6445
diff
changeset
|
227 callback := command | form |
67485a72803d
(popup-dialog-box): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6445
diff
changeset
|
228 active-p := <t, nil, or a form to evaluate to decide whether this |
67485a72803d
(popup-dialog-box): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6445
diff
changeset
|
229 button should be selectable> |
67485a72803d
(popup-dialog-box): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6445
diff
changeset
|
230 name := <string> |
67485a72803d
(popup-dialog-box): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6445
diff
changeset
|
231 partition := 'nil' |
67485a72803d
(popup-dialog-box): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6445
diff
changeset
|
232 button := '[' name callback active-p ']' |
67485a72803d
(popup-dialog-box): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6445
diff
changeset
|
233 dialog := '(' name [ button ]+ [ partition [ button ]+ ] ')'" |
67485a72803d
(popup-dialog-box): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6445
diff
changeset
|
234 (let ((name (car data)) |
67485a72803d
(popup-dialog-box): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6445
diff
changeset
|
235 (tail (cdr data)) |
67485a72803d
(popup-dialog-box): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6445
diff
changeset
|
236 converted |
7656
d50e5481aae2
(popup-dialog-box): Bind meaning with let.
Richard M. Stallman <rms@gnu.org>
parents:
7655
diff
changeset
|
237 choice meaning) |
6744
67485a72803d
(popup-dialog-box): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6445
diff
changeset
|
238 (while tail |
67485a72803d
(popup-dialog-box): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6445
diff
changeset
|
239 (if (null (car tail)) |
67485a72803d
(popup-dialog-box): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6445
diff
changeset
|
240 (setq converted (cons nil converted)) |
67485a72803d
(popup-dialog-box): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6445
diff
changeset
|
241 (let ((item (aref (car tail) 0)) |
67485a72803d
(popup-dialog-box): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6445
diff
changeset
|
242 (callback (aref (car tail) 1)) |
67485a72803d
(popup-dialog-box): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6445
diff
changeset
|
243 (enable (aref (car tail) 2))) |
67485a72803d
(popup-dialog-box): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6445
diff
changeset
|
244 (setq converted |
67485a72803d
(popup-dialog-box): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6445
diff
changeset
|
245 (cons (if enable (cons item callback) item) |
67485a72803d
(popup-dialog-box): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6445
diff
changeset
|
246 converted)))) |
67485a72803d
(popup-dialog-box): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6445
diff
changeset
|
247 (setq tail (cdr tail))) |
67485a72803d
(popup-dialog-box): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6445
diff
changeset
|
248 (setq choice (x-popup-dialog t (cons name (nreverse converted)))) |
11765
3bc36769004f
(popup-dialog-box): x-popup-dialog returns the value, not the cons cell.
Richard M. Stallman <rms@gnu.org>
parents:
10954
diff
changeset
|
249 (if choice |
3bc36769004f
(popup-dialog-box): x-popup-dialog returns the value, not the cons cell.
Richard M. Stallman <rms@gnu.org>
parents:
10954
diff
changeset
|
250 (if (symbolp choice) |
3bc36769004f
(popup-dialog-box): x-popup-dialog returns the value, not the cons cell.
Richard M. Stallman <rms@gnu.org>
parents:
10954
diff
changeset
|
251 (call-interactively choice) |
3bc36769004f
(popup-dialog-box): x-popup-dialog returns the value, not the cons cell.
Richard M. Stallman <rms@gnu.org>
parents:
10954
diff
changeset
|
252 (eval choice))))) |
2231 | 253 |
9523
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
254 ;; This is empty because the usual elements of the menu bar |
2751
f95808ad4b95
(default-menubar): Make initial value nil.
Richard M. Stallman <rms@gnu.org>
parents:
2233
diff
changeset
|
255 ;; are provided by menu-bar.el instead. |
f95808ad4b95
(default-menubar): Make initial value nil.
Richard M. Stallman <rms@gnu.org>
parents:
2233
diff
changeset
|
256 ;; It would not make sense to duplicate them here. |
f95808ad4b95
(default-menubar): Make initial value nil.
Richard M. Stallman <rms@gnu.org>
parents:
2233
diff
changeset
|
257 (defconst default-menubar nil) |
2231 | 258 |
259 (defun set-menubar (menubar) | |
260 "Set the default menubar to be menubar." | |
261 (setq-default current-menubar (copy-sequence menubar)) | |
262 (set-menubar-dirty-flag)) | |
263 | |
264 (defun set-buffer-menubar (menubar) | |
265 "Set the buffer-local menubar to be menubar." | |
266 (make-local-variable 'current-menubar) | |
267 (setq current-menubar (copy-sequence menubar)) | |
268 (set-menubar-dirty-flag)) | |
269 | |
270 | |
271 ;;; menu manipulation functions | |
272 | |
273 (defun find-menu-item (menubar item-path-list &optional parent) | |
274 "Searches MENUBAR for item given by ITEM-PATH-LIST. | |
275 Returns (ITEM . PARENT), where PARENT is the immediate parent of | |
276 the item found. | |
277 Signals an error if the item is not found." | |
278 (or parent (setq item-path-list (mapcar 'downcase item-path-list))) | |
279 (if (not (consp menubar)) | |
280 nil | |
281 (let ((rest menubar) | |
282 result) | |
283 (while rest | |
284 (if (and (car rest) | |
285 (equal (car item-path-list) | |
286 (downcase (if (vectorp (car rest)) | |
287 (aref (car rest) 0) | |
288 (if (stringp (car rest)) | |
289 (car rest) | |
290 (car (car rest))))))) | |
291 (setq result (car rest) rest nil) | |
292 (setq rest (cdr rest)))) | |
293 (if (cdr item-path-list) | |
294 (if (consp result) | |
295 (find-menu-item (cdr result) (cdr item-path-list) result) | |
296 (if result | |
297 (signal 'error (list "not a submenu" result)) | |
298 (signal 'error (list "no such submenu" (car item-path-list))))) | |
299 (cons result parent))))) | |
300 | |
301 | |
302 (defun disable-menu-item (path) | |
303 "Make the named menu item be unselectable. | |
9523
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
304 PATH is a list of strings which identify the position of the menu item in |
2231 | 305 the menu hierarchy. (\"File\" \"Save\") means the menu item called \"Save\" |
9523
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
306 under the toplevel \"File\" menu. (\"Menu\" \"Foo\" \"Item\") means the |
2231 | 307 menu item called \"Item\" under the \"Foo\" submenu of \"Menu\"." |
308 (let* ((menubar current-menubar) | |
309 (pair (find-menu-item menubar path)) | |
310 (item (car pair)) | |
311 (menu (cdr pair))) | |
312 (or item | |
313 (signal 'error (list (if menu "No such menu item" "No such menu") | |
314 path))) | |
315 (if (consp item) (error "can't disable menus, only menu items")) | |
316 (aset item 2 nil) | |
317 (set-menubar-dirty-flag) | |
318 item)) | |
319 | |
320 | |
321 (defun enable-menu-item (path) | |
322 "Make the named menu item be selectable. | |
9523
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
323 PATH is a list of strings which identify the position of the menu item in |
2231 | 324 the menu hierarchy. (\"File\" \"Save\") means the menu item called \"Save\" |
9523
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
325 under the toplevel \"File\" menu. (\"Menu\" \"Foo\" \"Item\") means the |
2231 | 326 menu item called \"Item\" under the \"Foo\" submenu of \"Menu\"." |
327 (let* ((menubar current-menubar) | |
328 (pair (find-menu-item menubar path)) | |
329 (item (car pair)) | |
330 (menu (cdr pair))) | |
331 (or item | |
332 (signal 'error (list (if menu "No such menu item" "No such menu") | |
333 path))) | |
334 (if (consp item) (error "%S is a menu, not a menu item" path)) | |
335 (aset item 2 t) | |
336 (set-menubar-dirty-flag) | |
337 item)) | |
338 | |
339 | |
340 (defun add-menu-item-1 (item-p menu-path item-name item-data enabled-p before) | |
341 (if before (setq before (downcase before))) | |
342 (let* ((menubar current-menubar) | |
343 (menu (condition-case () | |
344 (car (find-menu-item menubar menu-path)) | |
345 (error nil))) | |
346 (item (if (listp menu) | |
347 (car (find-menu-item (cdr menu) (list item-name))) | |
348 (signal 'error (list "not a submenu" menu-path))))) | |
349 (or menu | |
350 (let ((rest menu-path) | |
351 (so-far menubar)) | |
352 (while rest | |
353 ;;; (setq menu (car (find-menu-item (cdr so-far) (list (car rest))))) | |
354 (setq menu | |
355 (if (eq so-far menubar) | |
356 (car (find-menu-item so-far (list (car rest)))) | |
357 (car (find-menu-item (cdr so-far) (list (car rest)))))) | |
358 (or menu | |
359 (let ((rest2 so-far)) | |
10954
d9ab06338f6a
(add-menu-item-1): Better error message if
Richard M. Stallman <rms@gnu.org>
parents:
9523
diff
changeset
|
360 (or rest2 |
d9ab06338f6a
(add-menu-item-1): Better error message if
Richard M. Stallman <rms@gnu.org>
parents:
9523
diff
changeset
|
361 (error "Trying to modify a menu that doesn't exist")) |
2231 | 362 (while (and (cdr rest2) (car (cdr rest2))) |
363 (setq rest2 (cdr rest2))) | |
364 (setcdr rest2 | |
7699 | 365 (nconc (list (setq menu (list (car rest)))) |
366 (cdr rest2))))) | |
2231 | 367 (setq so-far menu) |
368 (setq rest (cdr rest))))) | |
369 (or menu (setq menu menubar)) | |
370 (if item | |
371 nil ; it's already there | |
372 (if item-p | |
373 (setq item (vector item-name item-data enabled-p)) | |
374 (setq item (cons item-name item-data))) | |
375 ;; if BEFORE is specified, try to add it there. | |
376 (if before | |
377 (setq before (car (find-menu-item menu (list before))))) | |
378 (let ((rest menu) | |
379 (added-before nil)) | |
380 (while rest | |
381 (if (eq before (car (cdr rest))) | |
382 (progn | |
383 (setcdr rest (cons item (cdr rest))) | |
384 (setq rest nil added-before t)) | |
385 (setq rest (cdr rest)))) | |
386 (if (not added-before) | |
387 ;; adding before the first item on the menubar itself is harder | |
388 (if (and (eq menu menubar) (eq before (car menu))) | |
389 (setq menu (cons item menu) | |
390 current-menubar menu) | |
391 ;; otherwise, add the item to the end. | |
392 (nconc menu (list item)))))) | |
393 (if item-p | |
394 (progn | |
395 (aset item 1 item-data) | |
396 (aset item 2 (not (null enabled-p)))) | |
397 (setcar item item-name) | |
398 (setcdr item item-data)) | |
399 (set-menubar-dirty-flag) | |
400 item)) | |
401 | |
402 (defun add-menu-item (menu-path item-name function enabled-p &optional before) | |
403 "Add a menu item to some menu, creating the menu first if necessary. | |
404 If the named item exists already, it is changed. | |
405 MENU-PATH identifies the menu under which the new menu item should be inserted. | |
406 It is a list of strings; for example, (\"File\") names the top-level \"File\" | |
407 menu. (\"File\" \"Foo\") names a hypothetical submenu of \"File\". | |
408 ITEM-NAME is the string naming the menu item to be added. | |
409 FUNCTION is the command to invoke when this menu item is selected. | |
410 If it is a symbol, then it is invoked with `call-interactively', in the same | |
9523
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
411 way that functions bound to keys are invoked. If it is a list, then the |
2231 | 412 list is simply evaluated. |
413 ENABLED-P controls whether the item is selectable or not. | |
414 BEFORE, if provided, is the name of a menu item before which this item should | |
415 be added, if this item is not on the menu already. If the item is already | |
416 present, it will not be moved." | |
417 (or menu-path (error "must specify a menu path")) | |
418 (or item-name (error "must specify an item name")) | |
419 (add-menu-item-1 t menu-path item-name function enabled-p before)) | |
420 | |
421 | |
422 (defun delete-menu-item (path) | |
423 "Remove the named menu item from the menu hierarchy. | |
9523
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
424 PATH is a list of strings which identify the position of the menu item in |
2231 | 425 the menu hierarchy. (\"File\" \"Save\") means the menu item called \"Save\" |
9523
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
426 under the toplevel \"File\" menu. (\"Menu\" \"Foo\" \"Item\") means the |
2231 | 427 menu item called \"Item\" under the \"Foo\" submenu of \"Menu\"." |
428 (let* ((menubar current-menubar) | |
429 (pair (find-menu-item menubar path)) | |
430 (item (car pair)) | |
431 (menu (or (cdr pair) menubar))) | |
432 (if (not item) | |
433 nil | |
434 ;; the menubar is the only special case, because other menus begin | |
435 ;; with their name. | |
436 (if (eq menu current-menubar) | |
437 (setq current-menubar (delq item menu)) | |
438 (delq item menu)) | |
439 (set-menubar-dirty-flag) | |
440 item))) | |
441 | |
442 | |
443 (defun relabel-menu-item (path new-name) | |
444 "Change the string of the specified menu item. | |
9523
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
445 PATH is a list of strings which identify the position of the menu item in |
2231 | 446 the menu hierarchy. (\"File\" \"Save\") means the menu item called \"Save\" |
9523
f9cba4810d7b
(make-lucid-menu-keymap): Allow Lucid-style keyword-based menu items.
Karl Heuer <kwzh@gnu.org>
parents:
8868
diff
changeset
|
447 under the toplevel \"File\" menu. (\"Menu\" \"Foo\" \"Item\") means the |
2231 | 448 menu item called \"Item\" under the \"Foo\" submenu of \"Menu\". |
449 NEW-NAME is the string that the menu item will be printed as from now on." | |
450 (or (stringp new-name) | |
451 (setq new-name (signal 'wrong-type-argument (list 'stringp new-name)))) | |
452 (let* ((menubar current-menubar) | |
453 (pair (find-menu-item menubar path)) | |
454 (item (car pair)) | |
455 (menu (cdr pair))) | |
456 (or item | |
457 (signal 'error (list (if menu "No such menu item" "No such menu") | |
458 path))) | |
459 (if (and (consp item) | |
460 (stringp (car item))) | |
461 (setcar item new-name) | |
462 (aset item 0 new-name)) | |
463 (set-menubar-dirty-flag) | |
464 item)) | |
465 | |
466 (defun add-menu (menu-path menu-name menu-items &optional before) | |
467 "Add a menu to the menubar or one of its submenus. | |
468 If the named menu exists already, it is changed. | |
469 MENU-PATH identifies the menu under which the new menu should be inserted. | |
470 It is a list of strings; for example, (\"File\") names the top-level \"File\" | |
471 menu. (\"File\" \"Foo\") names a hypothetical submenu of \"File\". | |
472 If MENU-PATH is nil, then the menu will be added to the menubar itself. | |
473 MENU-NAME is the string naming the menu to be added. | |
474 MENU-ITEMS is a list of menu item descriptions. | |
475 Each menu item should be a vector of three elements: | |
476 - a string, the name of the menu item; | |
477 - a symbol naming a command, or a form to evaluate; | |
7742
2b0419458768
(make-lucid-menu-keymap): Allow any form as the enabler.
Richard M. Stallman <rms@gnu.org>
parents:
7699
diff
changeset
|
478 - and a form whose value determines whether this item is selectable. |
2231 | 479 BEFORE, if provided, is the name of a menu before which this menu should |
480 be added, if this menu is not on its parent already. If the menu is already | |
481 present, it will not be moved." | |
482 (or menu-name (error "must specify a menu name")) | |
483 (or menu-items (error "must specify some menu items")) | |
484 (add-menu-item-1 nil menu-path menu-name menu-items t before)) | |
485 | |
486 | |
487 | |
488 (defvar put-buffer-names-in-file-menu t) | |
489 | |
490 | |
5982
a9f7e018245b
Delete the code to enable menu bars.
Richard M. Stallman <rms@gnu.org>
parents:
5477
diff
changeset
|
491 ;; Don't unconditionally enable menu bars; leave that up to the user. |
a9f7e018245b
Delete the code to enable menu bars.
Richard M. Stallman <rms@gnu.org>
parents:
5477
diff
changeset
|
492 ;;(let ((frames (frame-list))) |
a9f7e018245b
Delete the code to enable menu bars.
Richard M. Stallman <rms@gnu.org>
parents:
5477
diff
changeset
|
493 ;; (while frames |
a9f7e018245b
Delete the code to enable menu bars.
Richard M. Stallman <rms@gnu.org>
parents:
5477
diff
changeset
|
494 ;; (modify-frame-parameters (car frames) '((menu-bar-lines . 1))) |
a9f7e018245b
Delete the code to enable menu bars.
Richard M. Stallman <rms@gnu.org>
parents:
5477
diff
changeset
|
495 ;; (setq frames (cdr frames)))) |
a9f7e018245b
Delete the code to enable menu bars.
Richard M. Stallman <rms@gnu.org>
parents:
5477
diff
changeset
|
496 ;;(or (assq 'menu-bar-lines default-frame-alist) |
a9f7e018245b
Delete the code to enable menu bars.
Richard M. Stallman <rms@gnu.org>
parents:
5477
diff
changeset
|
497 ;; (setq default-frame-alist |
a9f7e018245b
Delete the code to enable menu bars.
Richard M. Stallman <rms@gnu.org>
parents:
5477
diff
changeset
|
498 ;; (cons '(menu-bar-lines . 1) default-frame-alist))) |
2231 | 499 |
500 (set-menubar default-menubar) | |
501 | |
6435
050f711140e0
Provide lmenu, not menubar.
Richard M. Stallman <rms@gnu.org>
parents:
5982
diff
changeset
|
502 (provide 'lmenu) |
2231 | 503 |
2232
4f9d60f7de9d
Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2231
diff
changeset
|
504 ;;; lmenu.el ends here |