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