3a815dd308b689b2e9ed09cf0081245645082ae9
[chise/xemacs-chise.git.1] / man / lispref / menus.texi
1 @c -*-texinfo-*-
2 @c This is part of the XEmacs Lisp Reference Manual.
3 @c Copyright (C) 1990, 1991, 1992, 1993, 1997 Free Software Foundation, Inc. 
4 @c Copyright (C) 1995 Sun Microsystems.
5 @c See the file lispref.texi for copying conditions.
6 @setfilename ../../info/menu.info
7 @node Menus, Dialog Boxes, Keymaps, Top
8 @chapter Menus
9 @cindex menu
10
11 @menu
12 * Menu Format::         Format of a menu description.
13 * Menubar Format::      How to specify a menubar.
14 * Menubar::             Functions for controlling the menubar.
15 * Modifying Menus::     Modifying a menu description.
16 * Pop-Up Menus::        Functions for specifying pop-up menus.
17 * Menu Filters::        Filter functions for the default menubar.
18 * Menu Accelerators::   Using and controlling menu accelerator keys
19 * Buffers Menu::        The menu that displays the list of buffers.
20 @end menu
21
22 @node Menu Format
23 @section Format of Menus
24 @cindex menu format
25 @cindex format of menus
26
27 A menu is described using a @dfn{menu description}, which is a list of
28 menu items, keyword-value pairs, strings, and submenus.  The menu
29 description specifies which items are present in the menu, what function
30 each item invokes, and whether the item is selectable or not.  Pop-up
31 menus are directly described with a menu description, while menubars are
32 described slightly differently (see below).
33
34 The first element of a menu must be a string, which is the name of the
35 menu.  This is the string that will be displayed in the parent menu or
36 menubar, if any.  This string is not displayed in the menu itself,
37 except in the case of the top level pop-up menu, where there is no
38 parent.  In this case, the string will be displayed at the top of the
39 menu if @code{popup-menu-titles} is non-@code{nil}.
40
41 Immediately following the first element there may optionally be up
42 to four keyword-value pairs, as follows:
43
44 @table @code
45 @item :included @var{form}
46 This can be used to control the visibility of a menu.  The form is
47 evaluated and the menu will be omitted if the result is @code{nil}.
48
49 @item :config @var{symbol}
50 This is an efficient shorthand for @code{:included (memq @var{symbol}
51 menubar-configuration)}.  See the variable @code{menubar-configuration}.
52
53 @item :filter @var{function}
54 A menu filter is used to sensitize or incrementally create a submenu
55 only when it is selected by the user and not every time the menubar is
56 activated.  The filter function is passed the list of menu items in the
57 submenu and must return a list of menu items to be used for the menu.
58 It is called only when the menu is about to be displayed, so other menus
59 may already be displayed.  Vile and terrible things will happen if a
60 menu filter function changes the current buffer, window, or frame.  It
61 also should not raise, lower, or iconify any frames.  Basically, the
62 filter function should have no side-effects.
63
64 @item :accelerator @var{key}
65 A menu accelerator is a keystroke which can be pressed while the menu is
66 visible which will immediately activate the item.  @var{key} must be a char
67 or the symbol name of a key.  @xref{Menu Accelerators}.
68 @end table
69
70 The rest of the menu consists of elements as follows:
71
72 @itemize @bullet
73 @item
74 A @dfn{menu item}, which is a vector in the following form:
75
76 @example
77 @code{[ @var{name} @var{callback} @var{:keyword} @var{value} @var{:keyword} @var{value} ... ]}
78 @end example
79
80 @var{name} is a string, the name of the menu item; it is the string to
81 display on the menu.  It is filtered through the resource database, so
82 it is possible for resources to override what string is actually
83 displayed.
84
85 @var{callback} is a form that will be invoked when the menu item is
86 selected.  If the callback of a menu item is a symbol, then it must name
87 a command.  It will be invoked with @code{call-interactively}.  If it is
88 a list, then it is evaluated with @code{eval}.
89
90 The valid keywords and their meanings are described below.
91
92 Note that for compatibility purposes, the form
93
94 @example
95 @code{[ @var{name} @var{callback} @var{active-p} ]}
96 @end example
97
98 is also accepted and is equivalent to
99
100 @example
101 @code{[ @var{name} @var{callback} :active @var{active-p} ]}
102 @end example
103
104 and the form
105
106 @example
107 @code{[ @var{name} @var{callback} @var{active-p} @var{suffix}]}
108 @end example
109
110 is accepted and is equivalent to
111
112 @example
113 @code{[ @var{name} @var{callback} :active @var{active-p} :suffix @var{suffix}]}
114 @end example
115
116 However, these older forms are deprecated and should generally not be used.
117
118 @item
119 If an element of a menu is a string, then that string will be presented
120 in the menu as unselectable text.
121
122 @item
123 If an element of a menu is a string consisting solely of hyphens, then
124 that item will be presented as a solid horizontal line.
125
126 @item
127 If an element of a menu is a string beginning with @samp{--:}, then
128 a particular sort of horizontal line will be displayed, as follows:
129
130 @table @samp
131 @item "--:singleLine"
132 A solid horizontal line.  This is equivalent to a string consisting
133 solely of hyphens.
134 @item "--:doubleLine"
135 A solid double horizontal line.
136 @item "--:singleDashedLine"
137 A dashed horizontal line.
138 @item "--:doubleDashedLine"
139 A dashed double horizontal line.
140 @item "--:noLine"
141 No line (but a small space is left).
142 @item "--:shadowEtchedIn"
143 A solid horizontal line with a 3-d recessed appearance.
144 @item "--:shadowEtchedOut"
145 A solid horizontal line with a 3-d pushed-out appearance.
146 @item "--:shadowDoubleEtchedIn"
147 A solid double horizontal line with a 3-d recessed appearance.
148 @item "--:shadowDoubleEtchedOut"
149 A solid double horizontal line with a 3-d pushed-out appearance.
150 @item "--:shadowEtchedInDash"
151 A dashed horizontal line with a 3-d recessed appearance.
152 @item "--:shadowEtchedOutDash"
153 A dashed horizontal line with a 3-d pushed-out appearance.
154 @item "--:shadowDoubleEtchedInDash"
155 A dashed double horizontal line with a 3-d recessed appearance.
156 @item "--:shadowDoubleEtchedOutDash"
157 A dashed double horizontal line with a 3-d pushed-out appearance.
158 @end table
159
160 @item
161 If an element of a menu is a list, it is treated as a submenu.  The name
162 of that submenu (the first element in the list) will be used as the name
163 of the item representing this menu on the parent.
164 @end itemize
165
166 The possible keywords are as follows:
167
168 @table @asis
169 @item :active @var{form}
170 @var{form} will be evaluated when the menu that this item is a part of
171 is about to be displayed, and the item will be selectable only if the
172 result is non-@code{nil}.  If the item is unselectable, it will
173 usually be displayed grayed-out to indicate this.
174
175 @item :suffix @var{form}
176 @var{form} will be evaluated when the menu that this item is a part of
177 is about to be displayed, and the resulting string is appended to the
178 displayed name.  This provides a convenient way of adding the name of a
179 command's ``argument'' to the menu, like @samp{Kill Buffer NAME}.
180
181 @item :keys @var{string}
182 Normally, the keyboard equivalents of commands in menus are displayed
183 when the ``callback'' is a symbol.  This can be used to specify keys for
184 more complex menu items.  It is passed through
185 @code{substitute-command-keys} first.
186
187 @item :style @var{style}
188 Specifies what kind of object this menu item is.  @var{style} be one
189 of the symbols
190
191 @table @code
192 @item nil
193 A normal menu item.
194 @item toggle
195 A toggle button.
196 @item radio
197 A radio button.
198 @item button
199 A menubar button.
200 @end table
201
202 The only difference between toggle and radio buttons is how they are
203 displayed.  But for consistency, a toggle button should be used when
204 there is one option whose value can be turned on or off, and radio
205 buttons should be used when there is a set of mutually exclusive options.
206 When using a group of radio buttons, you should arrange for no more than
207 one to be marked as selected at a time.
208
209 @item :selected @var{form}
210 Meaningful only when @var{style} is @code{toggle}, @code{radio} or
211 @code{button}.  This specifies whether the button will be in the
212 selected or unselected state.  @var{form} is evaluated, as for
213 @code{:active}.
214
215 @item :included @var{form}
216 This can be used to control the visibility of a menu item.  The form is
217 evaluated and the menu item is only displayed if the result is
218 non-@code{nil}.  Note that this is different from @code{:active}: If
219 @code{:active} evaluates to @code{nil}, the item will be displayed
220 grayed out, while if @code{:included} evaluates to @code{nil}, the item
221 will be omitted entirely.
222
223 @item :config @var{symbol}
224 This is an efficient shorthand for @code{:included (memq @var{symbol}
225 menubar-configuration)}.  See the variable @code{menubar-configuration}.
226
227 @item :accelerator @var{key}
228 A menu accelerator is a keystroke which can be pressed while the menu is
229 visible which will immediately activate the item.  @var{key} must be a char
230 or the symbol name of a key.  @xref{Menu Accelerators}.
231 @end table
232
233 @defvar menubar-configuration
234 This variable holds a list of symbols, against which the value of the
235 @code{:config} tag for each menubar item will be compared.  If a menubar
236 item has a @code{:config} tag, then it is omitted from the menubar if
237 that tag is not a member of the @code{menubar-configuration} list.
238 @end defvar
239
240 For example:
241
242 @example
243  ("File"
244   :filter file-menu-filter      ; file-menu-filter is a function that takes
245                                 ; one argument (a list of menu items) and
246                                 ; returns a list of menu items
247   [ "Save As..."    write-file]
248   [ "Revert Buffer" revert-buffer :active (buffer-modified-p) ]
249   [ "Read Only"     toggle-read-only :style toggle :selected buffer-read-only ]
250   )
251 @end example
252
253 @node Menubar Format
254 @section Format of the Menubar
255 @cindex menubar format
256 @cindex format of the menubar
257
258 A menubar is a list of menus, menu items, and strings.  The format is
259 similar to that of a menu, except:
260
261 @itemize @bullet
262 @item
263 The first item need not be a string, and is not treated specially.
264
265 @item
266 A string consisting solely of hyphens is not treated specially.
267
268 @item
269 If an element of a menubar is @code{nil}, then it is used to represent
270 the division between the set of menubar items which are flush-left and
271 those which are flush-right.  (Note: this isn't completely implemented
272 yet.)
273 @end itemize
274
275 @node Menubar
276 @section Menubar
277 @cindex menubar
278
279 @defvar current-menubar
280 This variable holds the description of the current menubar.  This may be
281 buffer-local.  When the menubar is changed, the function
282 @code{set-menubar-dirty-flag} has to be called in order for the menubar
283 to be updated on the screen.
284 @end defvar
285
286 @defvr Constant default-menubar
287 This variable holds the menubar description of the menubar that is
288 visible at startup.  This is the value that @code{current-menubar}
289 has at startup.
290 @end defvr
291
292 @defun set-menubar-dirty-flag
293 This function tells XEmacs that the menubar widget has to be updated.
294 Changes to the menubar will generally not be visible until this function
295 is called.
296 @end defun
297
298 The following convenience functions are provided for setting the
299 menubar.  They are equivalent to doing the appropriate action to change
300 @code{current-menubar}, and then calling @code{set-menubar-dirty-flag}.
301 Note that these functions copy their argument using
302 @code{copy-sequence}.
303
304 @defun set-menubar menubar
305 This function sets the default menubar to be @var{menubar} (@pxref{Menu
306 Format}).  This is the menubar that will be visible in buffers that
307 have not defined their own, buffer-local menubar.
308 @end defun
309
310 @defun set-buffer-menubar menubar
311 This function sets the buffer-local menubar to be @var{menubar}.  This
312 does not change the menubar in any buffers other than the current one.
313 @end defun
314
315 Miscellaneous:
316
317 @defvar menubar-show-keybindings
318 If true, the menubar will display keyboard equivalents.  If false, only
319 the command names will be displayed.
320 @end defvar
321
322 @defvar activate-menubar-hook
323 Function or functions called before a menubar menu is pulled down.
324 These functions are called with no arguments, and should interrogate and
325 modify the value of @code{current-menubar} as desired.
326
327 The functions on this hook are invoked after the mouse goes down, but
328 before the menu is mapped, and may be used to activate, deactivate, add,
329 or delete items from the menus.  However, using a filter (with the
330 @code{:filter} keyword in a menu description) is generally a more
331 efficient way of accomplishing the same thing, because the filter is
332 invoked only when the actual menu goes down.  With a complex menu,
333 there can be a quite noticeable and sometimes aggravating delay if
334 all menu modification is implemented using the @code{activate-menubar-hook}.
335 See above.
336
337 These functions may return the symbol @code{t} to assert that they have
338 made no changes to the menubar.  If any other value is returned, the
339 menubar is recomputed.  If @code{t} is returned but the menubar has been
340 changed, then the changes may not show up right away.  Returning
341 @code{nil} when the menubar has not changed is not so bad; more
342 computation will be done, but redisplay of the menubar will still be
343 performed optimally.
344 @end defvar
345
346 @defvar menu-no-selection-hook
347 Function or functions to call when a menu or dialog box is dismissed
348 without a selection having been made.
349 @end defvar
350
351 @node Modifying Menus
352 @section Modifying Menus
353
354 The following functions are provided to modify the menubar of one of its
355 submenus.  Note that these functions modify the menu in-place, rather
356 than copying it and making a new menu.
357
358 Some of these functions take a @dfn{menu path}, which is a list of
359 strings identifying the menu to be modified.  For example,
360 @code{("File")} names the top-level ``File'' menu.  @code{("File"
361 "Foo")} names a hypothetical submenu of ``File''.
362
363 Others take a @dfn{menu item path}, which is similar to a menu path but
364 also specifies a particular item to be modified.  For example,
365 @code{("File" "Save")} means the menu item called ``Save'' under the
366 top-level ``File'' menu.  @code{("Menu" "Foo" "Item")} means the menu
367 item called ``Item'' under the ``Foo'' submenu of ``Menu''.
368
369 @defun add-submenu menu-path submenu &optional before
370 This function adds a menu to the menubar or one of its submenus.  If the
371 named menu exists already, it is changed.
372
373 @var{menu-path} identifies the menu under which the new menu should be
374 inserted.  If @var{menu-path} is @code{nil}, then the menu will be added
375 to the menubar itself.
376
377 @var{submenu} is the new menu to add (@pxref{Menu Format}).
378
379 @var{before}, if provided, is the name of a menu before which this menu
380 should be added, if this menu is not on its parent already.  If the menu
381 is already present, it will not be moved.
382 @end defun
383
384 @defun add-menu-button menu-path menu-leaf &optional before
385 This function adds a menu item to some menu, creating the menu first if
386 necessary.  If the named item exists already, it is changed.
387
388 @var{menu-path} identifies the menu under which the new menu item should
389 be inserted.
390
391 @var{menu-leaf} is a menubar leaf node (@pxref{Menu Format}).
392
393 @var{before}, if provided, is the name of a menu before which this item
394 should be added, if this item is not on the menu already.  If the item
395 is already present, it will not be moved.
396 @end defun
397
398 @defun delete-menu-item menu-item-path
399 This function removes the menu item specified by @var{menu-item-path}
400 from the menu hierarchy.
401 @end defun
402
403 @defun enable-menu-item menu-item-path
404 This function makes the menu item specified by @var{menu-item-path} be
405 selectable.
406 @end defun
407
408 @defun disable-menu-item menu-item-path
409 This function makes the menu item specified by @var{menu-item-path} be
410 unselectable.
411 @end defun
412
413 @defun relabel-menu-item menu-item-path new-name
414 This function changes the string of the menu item specified by
415 @var{menu-item-path}.  @var{new-name} is the string that the menu item
416 will be printed as from now on.
417 @end defun
418
419 The following function can be used to search for a particular item in
420 a menubar specification, given a path to the item.
421
422 @defun find-menu-item menubar menu-item-path &optional parent
423 This function searches @var{menubar} for the item given by
424 @var{menu-item-path} starting from @var{parent} (@code{nil} means start
425 at the top of @var{menubar}).  This function returns @code{(@var{item}
426 . @var{parent})}, where @var{parent} is the immediate parent of the item
427 found (a menu description), and @var{item} is either a vector, list, or
428 string, depending on the nature of the menu item.
429
430 This function signals an error if the item is not found.
431 @end defun
432
433 The following deprecated functions are also documented, so that
434 existing code can be understood.  You should not use these functions
435 in new code.
436
437 @defun add-menu menu-path menu-name menu-items &optional before
438 This function adds a menu to the menubar or one of its submenus.  If the
439 named menu exists already, it is changed.  This is obsolete; use
440 @code{add-submenu} instead.
441
442 @var{menu-path} identifies the menu under which the new menu should be
443 inserted.  If @var{menu-path} is @code{nil}, then the menu will be added
444 to the menubar itself.
445
446 @var{menu-name} is the string naming the menu to be added;
447 @var{menu-items} is a list of menu items, strings, and submenus.  These
448 two arguments are the same as the first and following elements of a menu
449 description (@pxref{Menu Format}).
450
451 @var{before}, if provided, is the name of a menu before which this
452 menu should be added, if this menu is not on its parent already.  If the
453 menu is already present, it will not be moved.
454 @end defun
455
456 @defun add-menu-item menu-path item-name function enabled-p &optional before
457 This function adds a menu item to some menu, creating the menu first if
458 necessary.  If the named item exists already, it is changed.  This is
459 obsolete; use @code{add-menu-button} instead.
460
461 @var{menu-path} identifies the menu under which the new menu item should
462 be inserted. @var{item-name}, @var{function}, and @var{enabled-p} are
463 the first, second, and third elements of a menu item vector (@pxref{Menu
464 Format}).
465
466 @var{before}, if provided, is the name of a menu item before which this
467 item should be added, if this item is not on the menu already.  If the
468 item is already present, it will not be moved.
469 @end defun
470
471 @node Menu Filters
472 @section Menu Filters
473 @cindex menu filters
474
475 The following filter functions are provided for use in
476 @code{default-menubar}.  You may want to use them in your own menubar
477 description.
478
479 @defun file-menu-filter menu-items
480 This function changes the arguments and sensitivity of these File menu items:
481
482 @table @samp
483 @item Delete Buffer
484 Has the name of the current buffer appended to it.
485 @item Print Buffer
486 Has the name of the current buffer appended to it.
487 @item Pretty-Print Buffer
488 Has the name of the current buffer appended to it.
489 @item Save Buffer
490 Has the name of the current buffer appended to it, and is sensitive only
491 when the current buffer is modified.
492 @item Revert Buffer
493 Has the name of the current buffer appended to it, and is sensitive only
494 when the current buffer has a file.
495 @item Delete Frame
496 Sensitive only when there is more than one visible frame.
497 @end table
498 @end defun
499
500 @defun edit-menu-filter menu-items
501 This function changes the arguments and sensitivity of these Edit menu items:
502
503 @table @samp
504 @item Cut
505 Sensitive only when XEmacs owns the primary X Selection (if
506 @code{zmacs-regions} is @code{t}, this is equivalent to saying that
507 there is a region selected).
508 @item Copy
509 Sensitive only when XEmacs owns the primary X Selection.
510 @item Clear
511 Sensitive only when XEmacs owns the primary X Selection.
512 @item Paste
513 Sensitive only when there is an owner for the X Clipboard Selection.
514 @item Undo
515 Sensitive only when there is undo information.  While in the midst of an
516 undo, this is changed to @samp{Undo More}.
517 @end table
518 @end defun
519
520 @defun buffers-menu-filter menu-items
521 This function sets up the Buffers menu.  @xref{Buffers Menu}, for
522 more information.
523 @end defun
524
525 @node Pop-Up Menus
526 @section Pop-Up Menus
527 @cindex pop-up menu
528
529 @defun popup-menu menu-desc
530 This function pops up a menu specified by @var{menu-desc}, which is a
531 menu description (@pxref{Menu Format}).  The menu is displayed at the
532 current mouse position.
533 @end defun
534
535 @defun popup-menu-up-p
536 This function returns @code{t} if a pop-up menu is up, @code{nil}
537 otherwise.
538 @end defun
539
540 @defvar popup-menu-titles
541 If true (the default), pop-up menus will have title bars at the top.
542 @end defvar
543
544 Some machinery is provided that attempts to provide a higher-level
545 mechanism onto pop-up menus.  This only works if you do not redefine
546 the binding for button3.
547
548 @deffn Command popup-mode-menu
549 This function pops up a menu of global and mode-specific commands.  The
550 menu is computed by combining @code{global-popup-menu} and
551 @code{mode-popup-menu}.  This is the default binding for button3.
552 You should generally not change this binding.
553 @end deffn
554
555 @defvar global-popup-menu
556 This holds the global popup menu.  This is present in all modes.
557 (This is @code{nil} by default.)
558 @end defvar
559
560 @defvar mode-popup-menu
561 The mode-specific popup menu.  Automatically buffer local.
562 This is appended to the default items in @code{global-popup-menu}.
563 @end defvar
564
565 @defvr Constant default-popup-menu
566 This holds the default value of @code{mode-popup-menu}.
567 @end defvr
568
569 @defvar activate-popup-menu-hook
570 Function or functions run before a mode-specific popup menu is made
571 visible.  These functions are called with no arguments, and should
572 interrogate and modify the value of @code{global-popup-menu} or
573 @code{mode-popup-menu} as desired.  Note: this hook is only run if you
574 use @code{popup-mode-menu} for activating the global and mode-specific
575 commands; if you have your own binding for button3, this hook won't be
576 run.
577 @end defvar
578
579 The following convenience functions are provided for displaying
580 pop-up menus.
581
582 @defun popup-buffer-menu event
583 This function pops up a copy of the @samp{Buffers} menu (from the menubar)
584 where the mouse is clicked.
585 @end defun
586
587 @defun popup-menubar-menu event
588 This function pops up a copy of menu that also appears in the menubar.
589 @end defun
590
591 @node Menu Accelerators
592 @section Menu Accelerators
593 @cindex menu accelerators
594 @cindex keyboard menu accelerators
595
596 Menu accelerators are keyboard shortcuts for accessing the menubar.
597 Accelerator keys can be specified for menus as well as for menu items.  An
598 accelerator key for a menu is used to activate that menu when it appears as a
599 submenu of another menu.  An accelerator key for a menu item is used to
600 activate that item.
601
602 @menu
603 * Creating Menu Accelerators::  How to add accelerator keys to a menu.
604 * Keyboard Menu Traversal::     How to use and modify the keys which are used
605                                 to traverse the menu structure.
606 * Menu Accelerator Functions::  Functions for working with menu accelerators.
607 @end menu
608
609 @node Creating Menu Accelerators
610 @subsection Creating Menu Accelerators
611
612 Menu accelerators are specified as part of the menubar format using the
613 :accelerator tag to specify a key or by placing "%_" in the menu or menu item
614 name prior to the letter which is to be used as the accelerator key.  The
615 advantage of the second method is that the menu rendering code then knows to
616 draw an underline under that character, which is the canonical way of
617 indicating an accelerator key to a user.
618
619 For example, the command
620
621 @example
622 (add-submenu nil '("%_Test"
623                    ["One" (insert "1") :accelerator ?1 :active t]
624                    ["%_Two" (insert "2")]
625                    ["%_3" (insert "3")]))
626 @end example
627
628 will add a new menu to the top level menubar.  The new menu can be reached
629 by pressing "t" while the top level menubar is active.  When the menu is
630 active, pressing "1" will activate the first item and insert the character
631 "1" into the buffer.  Pressing "2" will activate the second item and insert
632 the character "2" into the buffer.  Pressing "3" will activate the third item
633 and insert the character "3" into the buffer.
634
635 It is possible to activate the top level menubar itself using accelerator keys.
636 @xref{Menu Accelerator Functions}.
637
638 @node Keyboard Menu Traversal
639 @subsection Keyboard Menu Traversal
640
641 In addition to immediately activating a menu or menu item, the keyboard can
642 be used to traverse the menus without activating items.  The keyboard arrow
643 keys, the return key and the escape key are defined to traverse the menus in a
644 way that should be familiar to users of any of a certain family of popular PC
645 operating systems.
646
647 This behavior can be changed by modifying the bindings in
648 menu-accelerator-map.  At this point, the online help is your best bet
649 for more information about how to modify the menu traversal keys.
650
651 @node Menu Accelerator Functions
652 @subsection Menu Accelerator Functions
653
654 @defun accelerate-menu
655 Make the menubar immediately active and place the cursor on the left most entry
656 in the top level menu.  Menu items can be selected as usual.
657 @end defun
658
659 @defvar menu-accelerator-enabled
660 Whether menu accelerator keys can cause the menubar to become active.
661
662 If @code{menu-force} or @code{menu-fallback}, then menu accelerator keys can
663 be used to activate the top level menu.  Once the menubar becomes active, the
664 accelerator keys can be used regardless of the value of this variable.
665
666 @code{menu-force} is used to indicate that the menu accelerator key takes
667 precedence over bindings in the current keymap(s).  @code{menu-fallback} means
668 that bindings in the current keymap take precedence over menu accelerator keys.
669 Thus a top level menu with an accelerator of "T" would be activated on a
670 keypress of Meta-t if @var{menu-accelerator-enabled} is @code{menu-force}.
671 However, if @var{menu-accelerator-enabled} is @code{menu-fallback}, then
672 Meta-t will not activate the menubar and will instead run the function
673 transpose-words, to which it is normally bound.
674
675 The default value is @code{nil}.
676
677 See also @var{menu-accelerator-modifiers} and @var{menu-accelerator-prefix}.
678 @end defvar
679
680 @defvar menu-accelerator-map
681 Keymap consulted to determine the commands to run in response to keypresses
682 occurring while the menubar is active.  @xref{Keyboard Menu Traversal}.
683 @end defvar
684
685 @defvar menu-accelerator-modifiers
686 A list of modifier keys which must be pressed in addition to a valid menu
687 accelerator in order for the top level menu to be activated in response to
688 a keystroke.  The default value of @code{(meta)} mirrors the usage of the alt key
689 as a menu accelerator in popular PC operating systems.
690
691 The modifier keys in @var{menu-accelerator-modifiers} must match exactly the
692 modifiers present in the keypress.  The only exception is that the shift
693 modifier is accepted in conjunction with alphabetic keys even if it is not
694 a menu accelerator modifier.
695
696 See also @var{menu-accelerator-enabled} and @var{menu-accelerator-prefix}.
697 @end defvar
698
699 @defvar menu-accelerator-prefix
700 Prefix key(s) that must be typed before menu accelerators will be activated.
701 Must be a valid key descriptor.
702
703 The default value is @code{nil}.
704 @end defvar
705
706 @example
707 (setq menu-accelerator-prefix ?\C-x)
708 (setq menu-accelerator-modifiers '(meta control))
709 (setq menu-accelerator-enabled 'menu-force)
710 (add-submenu nil '("%_Test"
711                    ["One" (insert "1") :accelerator ?1 :active t]
712                    ["%_Two" (insert "2")]
713                    ["%_3" (insert "3")]))
714 @end example
715
716 will add the menu "Test" to the top level menubar.  Pressing C-x followed by
717 C-M-T will activate the menubar and display the "Test" menu.  Pressing
718 C-M-T by itself will not activate the menubar.  Neither will pressing C-x
719 followed by anything else.
720
721 @node Buffers Menu
722 @section Buffers Menu
723 @cindex buffers menu
724
725 The following options control how the @samp{Buffers} menu is displayed.
726 This is a list of all (or a subset of) the buffers currently in existence,
727 and is updated dynamically.
728
729 @defopt buffers-menu-max-size
730 This user option holds the maximum number of entries which may appear on
731 the @samp{Buffers} menu.  If this is 10, then only the ten
732 most-recently-selected buffers will be shown.  If this is @code{nil},
733 then all buffers will be shown.  Setting this to a large number or
734 @code{nil} will slow down menu responsiveness.
735 @end defopt
736
737 @defun format-buffers-menu-line buffer
738 This function returns a string to represent @var{buffer} in the
739 @samp{Buffers} menu.  @code{nil} means the buffer shouldn't be listed.
740 You can redefine this.
741 @end defun
742
743 @defopt complex-buffers-menu-p
744 If true, the @samp{Buffers} menu will contain several commands, as submenus
745 of each buffer line.  If this is false, then there will be only one command:
746 select that buffer.
747 @end defopt
748
749 @defopt buffers-menu-switch-to-buffer-function
750 This user option holds the function to call to select a buffer from the
751 @samp{Buffers} menu.  @code{switch-to-buffer} is a good choice, as is
752 @code{pop-to-buffer}.
753 @end defopt
754