Mercurial > emacs
annotate lisp/emacs-lisp/easymenu.el @ 15132:c89db56c289b
(CONFIG_H) [WIN95]: Use config.nt.
author | Geoff Voelker <voelker@cs.washington.edu> |
---|---|
date | Fri, 03 May 1996 18:20:11 +0000 |
parents | 83f275dcd93a |
children | 34acde979294 |
rev | line source |
---|---|
6529 | 1 ;;; easymenu.el --- support the easymenu interface for defining a menu. |
2 | |
6600
f75ac1f3d99c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6542
diff
changeset
|
3 ;; Copyright (C) 1994 Free Software Foundation, Inc. |
f75ac1f3d99c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6542
diff
changeset
|
4 |
6529 | 5 ;; Keywords: emulations |
6600
f75ac1f3d99c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6542
diff
changeset
|
6 ;; Author: rms |
6529 | 7 |
8 ;; This file is part of GNU Emacs. | |
9 | |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 ;; it under the terms of the GNU General Public License as published by | |
12 ;; the Free Software Foundation; either version 2, or (at your option) | |
13 ;; any later version. | |
14 | |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
14169 | 21 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
23 ;; Boston, MA 02111-1307, USA. | |
6529 | 24 |
14169 | 25 ;;; Commentary: |
26 | |
27 ;; This is compatible with easymenu.el by Per Abrahamsen | |
28 ;; but it is much simpler as it doesn't try to support other Emacs versions. | |
29 ;; The code was mostly derived from lmenu.el. | |
6529 | 30 |
31 ;;; Code: | |
32 | |
6542
1d9da8160357
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6529
diff
changeset
|
33 ;;;###autoload |
6600
f75ac1f3d99c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6542
diff
changeset
|
34 (defmacro easy-menu-define (symbol maps doc menu) |
6529 | 35 "Define a menu bar submenu in maps MAPS, according to MENU. |
11512
a196f05240a9
(easy-menu-define): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
10415
diff
changeset
|
36 The menu keymap is stored in symbol SYMBOL, both as its value |
a196f05240a9
(easy-menu-define): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
10415
diff
changeset
|
37 and as its function definition. DOC is used as the doc string for SYMBOL. |
6529 | 38 |
39 The first element of MENU must be a string. It is the menu bar item name. | |
40 The rest of the elements are menu items. | |
41 | |
6600
f75ac1f3d99c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6542
diff
changeset
|
42 A menu item is usually a vector of three elements: [NAME CALLBACK ENABLE] |
6529 | 43 |
6542
1d9da8160357
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6529
diff
changeset
|
44 NAME is a string--the menu item name. |
6529 | 45 |
6542
1d9da8160357
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6529
diff
changeset
|
46 CALLBACK is a command to run when the item is chosen, |
1d9da8160357
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6529
diff
changeset
|
47 or a list to evaluate when the item is chosen. |
6529 | 48 |
8541
39e8d792604f
(easy-menu-define): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
8085
diff
changeset
|
49 ENABLE is an expression; the item is enabled for selection |
39e8d792604f
(easy-menu-define): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
8085
diff
changeset
|
50 whenever this expression's value is non-nil. |
6600
f75ac1f3d99c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6542
diff
changeset
|
51 |
9733
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
52 Alternatively, a menu item may have the form: |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
53 |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
54 [ NAME CALLBACK [ KEYWORD ARG ] ... ] |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
55 |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
56 Where KEYWORD is one of the symbol defined below. |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
57 |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
58 :keys KEYS |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
59 |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
60 KEYS is a string; a complex keyboard equivalent to this menu item. |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
61 This is normally not needed because keyboard equivalents are usually |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
62 computed automatically. |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
63 |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
64 :active ENABLE |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
65 |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
66 ENABLE is an expression; the item is enabled for selection |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
67 whenever this expression's value is non-nil. |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
68 |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
69 :suffix NAME |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
70 |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
71 NAME is a string; the name of an argument to CALLBACK. |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
72 |
14108 | 73 :style STYLE |
9733
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
74 |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
75 STYLE is a symbol describing the type of menu item. The following are |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
76 defined: |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
77 |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
78 toggle: A checkbox. |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
79 Currently just prepend the name with the string \"Toggle \". |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
80 radio: A radio button. |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
81 nil: An ordinary menu item. |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
82 |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
83 :selected SELECTED |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
84 |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
85 SELECTED is an expression; the checkbox or radio button is selected |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
86 whenever this expression's value is non-nil. |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
87 Currently just disable radio buttons, no effect on checkboxes. |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
88 |
6542
1d9da8160357
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6529
diff
changeset
|
89 A menu item can be a string. Then that string appears in the menu as |
1d9da8160357
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6529
diff
changeset
|
90 unselectable text. A string consisting solely of hyphens is displayed |
1d9da8160357
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6529
diff
changeset
|
91 as a solid horizontal line. |
6529 | 92 |
6542
1d9da8160357
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6529
diff
changeset
|
93 A menu item can be a list. It is treated as a submenu. |
6529 | 94 The first element should be the submenu name. That's used as the |
95 menu item in the top-level menu. The cdr of the submenu list | |
96 is a list of menu items, as above." | |
9733
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
97 (` (progn |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
98 (defvar (, symbol) nil (, doc)) |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
99 (easy-menu-do-define (quote (, symbol)) (, maps) (, doc) (, menu))))) |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
100 |
11860
0c39d1945e5e
(easy-menu-do-define): Add autoload cookie.
Karl Heuer <kwzh@gnu.org>
parents:
11833
diff
changeset
|
101 ;;;###autoload |
9733
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
102 (defun easy-menu-do-define (symbol maps doc menu) |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
103 ;; We can't do anything that might differ between Emacs dialects in |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
104 ;; `easy-menu-define' in order to make byte compiled files |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
105 ;; compatible. Therefore everything interesting is done in this |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
106 ;; function. |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
107 (set symbol (easy-menu-create-keymaps (car menu) (cdr menu))) |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
108 (fset symbol (` (lambda (event) (, doc) (interactive "@e") |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
109 (easy-popup-menu event (, symbol))))) |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
110 (mapcar (function (lambda (map) |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
111 (define-key map (vector 'menu-bar (intern (car menu))) |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
112 (cons (car menu) (symbol-value symbol))))) |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
113 (if (keymapp maps) (list maps) maps))) |
6542
1d9da8160357
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6529
diff
changeset
|
114 |
1d9da8160357
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6529
diff
changeset
|
115 (defvar easy-menu-item-count 0) |
6529 | 116 |
117 ;; Return a menu keymap corresponding to a Lucid-style menu list | |
118 ;; MENU-ITEMS, and with name MENU-NAME. | |
9586
bada2dc32adc
(easy-menu-create-keymaps): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents:
8541
diff
changeset
|
119 ;;;###autoload |
7614
877b3aeaa9b5
(easy-menu-create-keymaps):
Richard M. Stallman <rms@gnu.org>
parents:
6794
diff
changeset
|
120 (defun easy-menu-create-keymaps (menu-name menu-items) |
6529 | 121 (let ((menu (make-sparse-keymap menu-name))) |
122 ;; Process items in reverse order, | |
123 ;; since the define-key loop reverses them again. | |
124 (setq menu-items (reverse menu-items)) | |
125 (while menu-items | |
126 (let* ((item (car menu-items)) | |
127 (callback (if (vectorp item) (aref item 1))) | |
128 command enabler name) | |
129 (cond ((stringp item) | |
130 (setq command nil) | |
131 (setq name (if (string-match "^-+$" item) "" item))) | |
132 ((consp item) | |
7614
877b3aeaa9b5
(easy-menu-create-keymaps):
Richard M. Stallman <rms@gnu.org>
parents:
6794
diff
changeset
|
133 (setq command (easy-menu-create-keymaps (car item) (cdr item))) |
6794 | 134 (setq name (car item))) |
6529 | 135 ((vectorp item) |
136 (setq command (make-symbol (format "menu-function-%d" | |
6542
1d9da8160357
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6529
diff
changeset
|
137 easy-menu-item-count))) |
1d9da8160357
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6529
diff
changeset
|
138 (setq easy-menu-item-count (1+ easy-menu-item-count)) |
9733
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
139 (setq name (aref item 0)) |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
140 (let ((keyword (aref item 2))) |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
141 (if (and (symbolp keyword) |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
142 (= ?: (aref (symbol-name keyword) 0))) |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
143 (let ((count 2) |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
144 style selected active keys |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
145 arg) |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
146 (while (> (length item) count) |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
147 (setq keyword (aref item count)) |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
148 (setq arg (aref item (1+ count))) |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
149 (setq count (+ 2 count)) |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
150 (cond ((eq keyword ':keys) |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
151 (setq keys arg)) |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
152 ((eq keyword ':active) |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
153 (setq active arg)) |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
154 ((eq keyword ':suffix) |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
155 (setq name (concat name " " arg))) |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
156 ((eq keyword ':style) |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
157 (setq style arg)) |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
158 ((eq keyword ':selected) |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
159 (setq selected arg)))) |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
160 (if keys |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
161 (setq name (concat name " (" keys ")"))) |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
162 (if (eq style 'toggle) |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
163 ;; Simulate checkboxes. |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
164 (setq name (concat "Toggle " name))) |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
165 (if active |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
166 (put command 'menu-enable active) |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
167 (and (eq style 'radio) |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
168 selected |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
169 ;; Simulate radio buttons with menu-enable. |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
170 (put command 'menu-enable |
11833
0813e063f926
(easy-menu-create-keymaps): Set menu-enable prop.
Karl Heuer <kwzh@gnu.org>
parents:
11512
diff
changeset
|
171 (list 'not selected))))) |
0813e063f926
(easy-menu-create-keymaps): Set menu-enable prop.
Karl Heuer <kwzh@gnu.org>
parents:
11512
diff
changeset
|
172 (put command 'menu-enable keyword))) |
6600
f75ac1f3d99c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6542
diff
changeset
|
173 (if (keymapp callback) |
f75ac1f3d99c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6542
diff
changeset
|
174 (setq name (concat name " ..."))) |
6529 | 175 (if (symbolp callback) |
176 (fset command callback) | |
177 (fset command (list 'lambda () '(interactive) callback))))) | |
178 (if (null command) | |
179 ;; Handle inactive strings specially--allow any number | |
180 ;; of identical ones. | |
181 (setcdr menu (cons (list nil name) (cdr menu))) | |
182 (if name | |
183 (define-key menu (vector (intern name)) (cons name command))))) | |
184 (setq menu-items (cdr menu-items))) | |
185 menu)) | |
186 | |
8085
c7eb887a1e78
(easy-menu-change): New function.
Richard M. Stallman <rms@gnu.org>
parents:
7614
diff
changeset
|
187 (defun easy-menu-change (path name items) |
c7eb887a1e78
(easy-menu-change): New function.
Richard M. Stallman <rms@gnu.org>
parents:
7614
diff
changeset
|
188 "Change menu found at PATH as item NAME to contain ITEMS. |
c7eb887a1e78
(easy-menu-change): New function.
Richard M. Stallman <rms@gnu.org>
parents:
7614
diff
changeset
|
189 PATH is a list of strings for locating the menu containing NAME in the |
c7eb887a1e78
(easy-menu-change): New function.
Richard M. Stallman <rms@gnu.org>
parents:
7614
diff
changeset
|
190 menu bar. ITEMS is a list of menu items, as in `easy-menu-define'. |
c7eb887a1e78
(easy-menu-change): New function.
Richard M. Stallman <rms@gnu.org>
parents:
7614
diff
changeset
|
191 These items entirely replace the previous items in that map. |
c7eb887a1e78
(easy-menu-change): New function.
Richard M. Stallman <rms@gnu.org>
parents:
7614
diff
changeset
|
192 |
c7eb887a1e78
(easy-menu-change): New function.
Richard M. Stallman <rms@gnu.org>
parents:
7614
diff
changeset
|
193 Call this from `activate-menubar-hook' to implement dynamic menus." |
c7eb887a1e78
(easy-menu-change): New function.
Richard M. Stallman <rms@gnu.org>
parents:
7614
diff
changeset
|
194 (let ((map (key-binding (apply 'vector |
c7eb887a1e78
(easy-menu-change): New function.
Richard M. Stallman <rms@gnu.org>
parents:
7614
diff
changeset
|
195 'menu-bar |
c7eb887a1e78
(easy-menu-change): New function.
Richard M. Stallman <rms@gnu.org>
parents:
7614
diff
changeset
|
196 (mapcar 'intern (append path (list name))))))) |
c7eb887a1e78
(easy-menu-change): New function.
Richard M. Stallman <rms@gnu.org>
parents:
7614
diff
changeset
|
197 (if (keymapp map) |
c7eb887a1e78
(easy-menu-change): New function.
Richard M. Stallman <rms@gnu.org>
parents:
7614
diff
changeset
|
198 (setcdr map (cdr (easy-menu-create-keymaps name items))) |
c7eb887a1e78
(easy-menu-change): New function.
Richard M. Stallman <rms@gnu.org>
parents:
7614
diff
changeset
|
199 (error "Malformed menu in `easy-menu-change'")))) |
c7eb887a1e78
(easy-menu-change): New function.
Richard M. Stallman <rms@gnu.org>
parents:
7614
diff
changeset
|
200 |
9733
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
201 (defun easy-menu-remove (menu)) |
6600
f75ac1f3d99c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6542
diff
changeset
|
202 |
9733
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
203 (defun easy-menu-add (menu &optional map)) |
6600
f75ac1f3d99c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6542
diff
changeset
|
204 |
6529 | 205 (provide 'easymenu) |
206 | |
207 ;;; easymenu.el ends here |