Mercurial > emacs
annotate lisp/emacs-lisp/easymenu.el @ 10415:72031f772d96
(easy-menu-define): Doc fix.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Fri, 13 Jan 1995 00:35:28 +0000 |
parents | a721dbc48e10 |
children | a196f05240a9 |
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 | |
21 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
23 | |
24 ;;; This is compatible with easymenu.el by Per Abrahamsen | |
25 ;;; but it is much simpler as it doesn't try to support other Emacs versions. | |
26 ;;; The code was mostly derived from lmenu.el. | |
27 | |
28 ;;; Code: | |
29 | |
6542
1d9da8160357
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6529
diff
changeset
|
30 ;;;###autoload |
6600
f75ac1f3d99c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6542
diff
changeset
|
31 (defmacro easy-menu-define (symbol maps doc menu) |
6529 | 32 "Define a menu bar submenu in maps MAPS, according to MENU. |
10415 | 33 SYMBOL is used as a variable to hold the menu data. It is not evaluated. |
34 DOC is a doc string for that variable. | |
6529 | 35 |
36 The first element of MENU must be a string. It is the menu bar item name. | |
37 The rest of the elements are menu items. | |
38 | |
6600
f75ac1f3d99c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6542
diff
changeset
|
39 A menu item is usually a vector of three elements: [NAME CALLBACK ENABLE] |
6529 | 40 |
6542
1d9da8160357
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6529
diff
changeset
|
41 NAME is a string--the menu item name. |
6529 | 42 |
6542
1d9da8160357
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6529
diff
changeset
|
43 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
|
44 or a list to evaluate when the item is chosen. |
6529 | 45 |
8541
39e8d792604f
(easy-menu-define): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
8085
diff
changeset
|
46 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
|
47 whenever this expression's value is non-nil. |
6600
f75ac1f3d99c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6542
diff
changeset
|
48 |
9733
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
49 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
|
50 |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
51 [ 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
|
52 |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
53 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
|
54 |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
55 :keys KEYS |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
56 |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
57 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
|
58 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
|
59 computed automatically. |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
60 |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
61 :active ENABLE |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
62 |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
63 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
|
64 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
|
65 |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
66 :suffix NAME |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
67 |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
68 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
|
69 |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
70 :style |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
71 |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
72 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
|
73 defined: |
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 toggle: A checkbox. |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
76 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
|
77 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
|
78 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
|
79 |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
80 :selected SELECTED |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
81 |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
82 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
|
83 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
|
84 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
|
85 |
6542
1d9da8160357
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6529
diff
changeset
|
86 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
|
87 unselectable text. A string consisting solely of hyphens is displayed |
1d9da8160357
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6529
diff
changeset
|
88 as a solid horizontal line. |
6529 | 89 |
6542
1d9da8160357
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6529
diff
changeset
|
90 A menu item can be a list. It is treated as a submenu. |
6529 | 91 The first element should be the submenu name. That's used as the |
92 menu item in the top-level menu. The cdr of the submenu list | |
93 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
|
94 (` (progn |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
95 (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
|
96 (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
|
97 |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
98 (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
|
99 ;; 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
|
100 ;; `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
|
101 ;; 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
|
102 ;; function. |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
103 (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
|
104 (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
|
105 (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
|
106 (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
|
107 (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
|
108 (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
|
109 (if (keymapp maps) (list maps) maps))) |
6542
1d9da8160357
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6529
diff
changeset
|
110 |
1d9da8160357
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6529
diff
changeset
|
111 (defvar easy-menu-item-count 0) |
6529 | 112 |
113 ;; Return a menu keymap corresponding to a Lucid-style menu list | |
114 ;; 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
|
115 ;;;###autoload |
7614
877b3aeaa9b5
(easy-menu-create-keymaps):
Richard M. Stallman <rms@gnu.org>
parents:
6794
diff
changeset
|
116 (defun easy-menu-create-keymaps (menu-name menu-items) |
6529 | 117 (let ((menu (make-sparse-keymap menu-name))) |
118 ;; Process items in reverse order, | |
119 ;; since the define-key loop reverses them again. | |
120 (setq menu-items (reverse menu-items)) | |
121 (while menu-items | |
122 (let* ((item (car menu-items)) | |
123 (callback (if (vectorp item) (aref item 1))) | |
124 command enabler name) | |
125 (cond ((stringp item) | |
126 (setq command nil) | |
127 (setq name (if (string-match "^-+$" item) "" item))) | |
128 ((consp item) | |
7614
877b3aeaa9b5
(easy-menu-create-keymaps):
Richard M. Stallman <rms@gnu.org>
parents:
6794
diff
changeset
|
129 (setq command (easy-menu-create-keymaps (car item) (cdr item))) |
6794 | 130 (setq name (car item))) |
6529 | 131 ((vectorp item) |
132 (setq command (make-symbol (format "menu-function-%d" | |
6542
1d9da8160357
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6529
diff
changeset
|
133 easy-menu-item-count))) |
1d9da8160357
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6529
diff
changeset
|
134 (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
|
135 (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
|
136 (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
|
137 (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
|
138 (= ?: (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
|
139 (let ((count 2) |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
140 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
|
141 arg) |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
142 (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
|
143 (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
|
144 (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
|
145 (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
|
146 (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
|
147 (setq keys arg)) |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
148 ((eq keyword ':active) |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
149 (setq active arg)) |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
150 ((eq keyword ':suffix) |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
151 (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
|
152 ((eq keyword ':style) |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
153 (setq style 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 ':selected) |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
155 (setq selected arg)))) |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
156 (if keys |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
157 (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
|
158 (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
|
159 ;; Simulate checkboxes. |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
160 (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
|
161 (if active |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
162 (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
|
163 (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
|
164 selected |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
165 ;; 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
|
166 (put command 'menu-enable |
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
167 (list 'not selected))))))) |
6600
f75ac1f3d99c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6542
diff
changeset
|
168 (if (keymapp callback) |
f75ac1f3d99c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6542
diff
changeset
|
169 (setq name (concat name " ..."))) |
6529 | 170 (if (symbolp callback) |
171 (fset command callback) | |
172 (fset command (list 'lambda () '(interactive) callback))))) | |
173 (if (null command) | |
174 ;; Handle inactive strings specially--allow any number | |
175 ;; of identical ones. | |
176 (setcdr menu (cons (list nil name) (cdr menu))) | |
177 (if name | |
178 (define-key menu (vector (intern name)) (cons name command))))) | |
179 (setq menu-items (cdr menu-items))) | |
180 menu)) | |
181 | |
8085
c7eb887a1e78
(easy-menu-change): New function.
Richard M. Stallman <rms@gnu.org>
parents:
7614
diff
changeset
|
182 (defun easy-menu-change (path name items) |
c7eb887a1e78
(easy-menu-change): New function.
Richard M. Stallman <rms@gnu.org>
parents:
7614
diff
changeset
|
183 "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
|
184 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
|
185 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
|
186 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
|
187 |
c7eb887a1e78
(easy-menu-change): New function.
Richard M. Stallman <rms@gnu.org>
parents:
7614
diff
changeset
|
188 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
|
189 (let ((map (key-binding (apply 'vector |
c7eb887a1e78
(easy-menu-change): New function.
Richard M. Stallman <rms@gnu.org>
parents:
7614
diff
changeset
|
190 'menu-bar |
c7eb887a1e78
(easy-menu-change): New function.
Richard M. Stallman <rms@gnu.org>
parents:
7614
diff
changeset
|
191 (mapcar 'intern (append path (list name))))))) |
c7eb887a1e78
(easy-menu-change): New function.
Richard M. Stallman <rms@gnu.org>
parents:
7614
diff
changeset
|
192 (if (keymapp map) |
c7eb887a1e78
(easy-menu-change): New function.
Richard M. Stallman <rms@gnu.org>
parents:
7614
diff
changeset
|
193 (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
|
194 (error "Malformed menu in `easy-menu-change'")))) |
c7eb887a1e78
(easy-menu-change): New function.
Richard M. Stallman <rms@gnu.org>
parents:
7614
diff
changeset
|
195 |
9733
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
196 (defun easy-menu-remove (menu)) |
6600
f75ac1f3d99c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6542
diff
changeset
|
197 |
9733
a721dbc48e10
(easy-menu-define): Call `easy-menu-do-define' to do
Richard M. Stallman <rms@gnu.org>
parents:
9586
diff
changeset
|
198 (defun easy-menu-add (menu &optional map)) |
6600
f75ac1f3d99c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6542
diff
changeset
|
199 |
6529 | 200 (provide 'easymenu) |
201 | |
202 ;;; easymenu.el ends here |