Mercurial > emacs
comparison lisp/emacs-lisp/easymenu.el @ 21689:95c0fe8d25a7
(easy-menu-do-add-item):
Do the right thing when nil is specified as criterion for activeness.
Fix string used to report an invalid item.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Tue, 21 Apr 1998 04:54:46 +0000 |
parents | 517de9005275 |
children | 38a6d62cddb9 |
comparison
equal
deleted
inserted
replaced
21688:855aedeb0742 | 21689:95c0fe8d25a7 |
---|---|
185 (easy-menu-create-menu name item)))) | 185 (easy-menu-create-menu name item)))) |
186 ((vectorp item) | 186 ((vectorp item) |
187 (setq name (setq item-string (aref item 0))) | 187 (setq name (setq item-string (aref item 0))) |
188 (setq command (easy-menu-make-symbol (aref item 1) t)) | 188 (setq command (easy-menu-make-symbol (aref item 1) t)) |
189 (let ((active (if (> (length item) 2) (aref item 2) t)) | 189 (let ((active (if (> (length item) 2) (aref item 2) t)) |
190 (active-specified (> (length item) 2)) | |
190 (count 2) | 191 (count 2) |
191 style selected) | 192 style selected) |
192 (if (and (symbolp active) (= ?: (aref (symbol-name active) 0))) | 193 (if (and (symbolp active) (= ?: (aref (symbol-name active) 0))) |
193 (let ((count 2) keyword arg suffix keys) | 194 (let ((count 2) keyword arg suffix keys) |
194 (setq active nil) | 195 (setq active-specified nil) |
195 (while (> (length item) count) | 196 (while (> (length item) count) |
196 (setq keyword (aref item count)) | 197 (setq keyword (aref item count)) |
197 (setq arg (aref item (1+ count))) | 198 (setq arg (aref item (1+ count))) |
198 (setq count (+ 2 count)) | 199 (setq count (+ 2 count)) |
199 (cond | 200 (cond |
200 ((eq keyword ':keys) (setq keys arg)) | 201 ((eq keyword ':keys) (setq keys arg)) |
201 ((eq keyword ':active) (setq active arg)) | 202 ((eq keyword ':active) (setq active arg active-specified t)) |
202 ((eq keyword ':suffix) (setq suffix (concat " " arg))) | 203 ((eq keyword ':suffix) (setq suffix (concat " " arg))) |
203 ((eq keyword ':style) (setq style arg)) | 204 ((eq keyword ':style) (setq style arg)) |
204 ((eq keyword ':selected) (setq selected arg)))) | 205 ((eq keyword ':selected) (setq selected arg)))) |
205 (if keys (setq suffix (concat suffix " (" keys ")"))) | 206 (if keys (setq suffix (concat suffix " (" keys ")"))) |
206 (if suffix (setq item-string (concat item-string " " suffix))) | 207 (if suffix (setq item-string (concat item-string " " suffix))) |
212 `(easy-menu-update-button ,item-string | 213 `(easy-menu-update-button ,item-string |
213 ,(cadr style) | 214 ,(cadr style) |
214 ,selected | 215 ,selected |
215 ,(or active t))) | 216 ,(or active t))) |
216 (setq is-button t) | 217 (setq is-button t) |
217 (setq active nil) ; Already taken care of active. | 218 (setq active-specified nil) ; Already taken care of active. |
218 (when (not (or have-buttons top)) | 219 (when (not (or have-buttons top)) |
219 (setq have-buttons " ") | 220 (setq have-buttons " ") |
220 ;; Add prefix to menu items defined so far. | 221 ;; Add prefix to menu items defined so far. |
221 (easy-menu-change-prefix menu t))))) | 222 (easy-menu-change-prefix menu t)))) |
222 (if active (put command 'menu-enable active)))) | 223 (and (null active) active-specified |
223 (t "Illegal menu item in easy menu.")) | 224 (setq active ''nil))) |
225 (if active-specified (put command 'menu-enable active)))) | |
226 (t "Invalid menu item in easymenu")) | |
224 (when name | 227 (when name |
225 (and (not is-button) have-buttons | 228 (and (not is-button) have-buttons |
226 (setq item-string (concat have-buttons item-string))) | 229 (setq item-string (concat have-buttons item-string))) |
227 (setq name (intern name))) | 230 (setq name (intern name))) |
228 (setq item (cons item-string command)) | 231 (setq item (cons item-string command)) |