1 ;;; menu-bar.el --- define a default menu bar
3 ;; Copyright (C) 1993-1995, 2000-2015 Free Software Foundation, Inc.
5 ;; Author: Richard M. Stallman
6 ;; Maintainer: emacs-devel@gnu.org
7 ;; Keywords: internal, mouse
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software: you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation, either version 3 of the License, or
15 ;; (at your option) any later version.
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
25 ;; Avishai Yacobi suggested some menu rearrangements.
31 ;; This is referenced by some code below; it is defined in uniquify.el
32 (defvar uniquify-buffer-name-style
)
34 ;; From emulation/cua-base.el; used below
35 (defvar cua-enable-cua-keys
)
38 ;; Don't clobber an existing menu-bar keymap, to preserve any menu-bar key
39 ;; definitions made in loaddefs.el.
40 (or (lookup-key global-map
[menu-bar
])
41 (define-key global-map
[menu-bar
] (make-sparse-keymap "menu-bar")))
43 ;; Force Help item to come last, after the major mode's own items.
44 ;; The symbol used to be called `help', but that gets confused with the
46 (setq menu-bar-final-items
'(help-menu))
48 ;; This definition is just to show what this looks like.
49 ;; It gets modified in place when menu-bar-update-buffers is called.
50 (defvar global-buffers-menu-map
(make-sparse-keymap "Buffers"))
52 ;; Only declared obsolete (and only made a proper alias) in 23.3.
53 (define-obsolete-variable-alias
54 'menu-bar-files-menu
'menu-bar-file-menu
"22.1")
55 (defvar menu-bar-file-menu
56 (let ((menu (make-sparse-keymap "File")))
58 ;; The "File" menu items
59 (bindings--define-key menu
[exit-emacs
]
60 '(menu-item "Quit" save-buffers-kill-terminal
61 :help
"Save unsaved buffers, then exit"))
63 (bindings--define-key menu
[separator-exit
]
66 ;; Don't use delete-frame as event name because that is a special
68 (bindings--define-key menu
[delete-this-frame
]
69 '(menu-item "Delete Frame" delete-frame
70 :visible
(fboundp 'delete-frame
)
71 :enable
(delete-frame-enabled-p)
72 :help
"Delete currently selected frame"))
73 (bindings--define-key menu
[make-frame-on-display
]
74 '(menu-item "New Frame on Display..." make-frame-on-display
75 :visible
(fboundp 'make-frame-on-display
)
76 :help
"Open a new frame on another display"))
77 (bindings--define-key menu
[make-frame
]
78 '(menu-item "New Frame" make-frame-command
79 :visible
(fboundp 'make-frame-command
)
80 :help
"Open a new frame"))
82 (bindings--define-key menu
[separator-frame
]
85 (bindings--define-key menu
[one-window
]
86 '(menu-item "Remove Other Windows" delete-other-windows
87 :enable
(not (one-window-p t nil
))
88 :help
"Make selected window fill whole frame"))
90 (bindings--define-key menu
[new-window-on-right
]
91 '(menu-item "New Window on Right" split-window-right
92 :enable
(and (menu-bar-menu-frame-live-and-visible-p)
93 (menu-bar-non-minibuffer-window-p))
94 :help
"Make new window on right of selected one"))
96 (bindings--define-key menu
[new-window-below
]
97 '(menu-item "New Window Below" split-window-below
98 :enable
(and (menu-bar-menu-frame-live-and-visible-p)
99 (menu-bar-non-minibuffer-window-p))
100 :help
"Make new window below selected one"))
102 (bindings--define-key menu
[separator-window
]
105 (bindings--define-key menu
[ps-print-region
]
106 '(menu-item "PostScript Print Region (B+W)" ps-print-region
108 :help
"Pretty-print marked region in black and white to PostScript printer"))
109 (bindings--define-key menu
[ps-print-buffer
]
110 '(menu-item "PostScript Print Buffer (B+W)" ps-print-buffer
111 :enable
(menu-bar-menu-frame-live-and-visible-p)
112 :help
"Pretty-print current buffer in black and white to PostScript printer"))
113 (bindings--define-key menu
[ps-print-region-faces
]
114 '(menu-item "PostScript Print Region"
115 ps-print-region-with-faces
117 :help
"Pretty-print marked region to PostScript printer"))
118 (bindings--define-key menu
[ps-print-buffer-faces
]
119 '(menu-item "PostScript Print Buffer"
120 ps-print-buffer-with-faces
121 :enable
(menu-bar-menu-frame-live-and-visible-p)
122 :help
"Pretty-print current buffer to PostScript printer"))
123 (bindings--define-key menu
[print-region
]
124 '(menu-item "Print Region" print-region
126 :help
"Print region between mark and current position"))
127 (bindings--define-key menu
[print-buffer
]
128 '(menu-item "Print Buffer" print-buffer
129 :enable
(menu-bar-menu-frame-live-and-visible-p)
130 :help
"Print current buffer with page headings"))
132 (bindings--define-key menu
[separator-print
]
135 (bindings--define-key menu
[recover-session
]
136 '(menu-item "Recover Crashed Session" recover-session
138 (and auto-save-list-file-prefix
140 (file-name-directory auto-save-list-file-prefix
))
142 (file-name-directory auto-save-list-file-prefix
)
146 (file-name-nondirectory
147 auto-save-list-file-prefix
)))
149 :help
"Recover edits from a crashed session"))
150 (bindings--define-key menu
[revert-buffer
]
151 '(menu-item "Revert Buffer" revert-buffer
152 :enable
(or (not (eq revert-buffer-function
153 'revert-buffer--default
))
155 revert-buffer-insert-file-contents-function
156 'revert-buffer-insert-file-contents--default-function
))
157 (and buffer-file-number
158 (or (buffer-modified-p)
159 (not (verify-visited-file-modtime
160 (current-buffer))))))
161 :help
"Re-read current buffer from its file"))
162 (bindings--define-key menu
[write-file
]
163 '(menu-item "Save As..." write-file
164 :enable
(and (menu-bar-menu-frame-live-and-visible-p)
165 (menu-bar-non-minibuffer-window-p))
166 :help
"Write current buffer to another file"))
167 (bindings--define-key menu
[save-buffer
]
168 '(menu-item "Save" save-buffer
169 :enable
(and (buffer-modified-p)
171 (menu-bar-non-minibuffer-window-p))
172 :help
"Save current buffer to its file"))
174 (bindings--define-key menu
[separator-save
]
178 (bindings--define-key menu
[kill-buffer
]
179 '(menu-item "Close" kill-this-buffer
180 :enable
(kill-this-buffer-enabled-p)
181 :help
"Discard (kill) current buffer"))
182 (bindings--define-key menu
[insert-file
]
183 '(menu-item "Insert File..." insert-file
184 :enable
(menu-bar-non-minibuffer-window-p)
185 :help
"Insert another file into current buffer"))
186 (bindings--define-key menu
[dired]
187 '(menu-item "Open Directory..." dired
188 :enable (menu-bar-non-minibuffer-window-p)
189 :help "Read a directory, to operate on its files"))
190 (bindings--define-key menu [open-file]
191 '(menu-item "Open File..." menu-find-file-existing
192 :enable (menu-bar-non-minibuffer-window-p)
193 :help "Read an existing file into an Emacs buffer"))
194 (bindings--define-key menu [new-file]
195 '(menu-item "Visit New File..." find-file
196 :enable (menu-bar-non-minibuffer-window-p)
197 :help "Specify a new file's name, to edit the file"))
201 (defun menu-find-file-existing ()
202 "Edit the existing file FILENAME."
204 (let* ((mustmatch (not (and (fboundp 'x-uses-old-gtk-dialog)
205 (x-uses-old-gtk-dialog))))
206 (filename (car (find-file-read-args "Find file: " mustmatch))))
208 (find-file-existing filename)
209 (find-file filename))))
211 ;; The "Edit->Search" submenu
212 (defvar menu-bar-last-search-type nil
213 "Type of last non-incremental search command called from the menu.")
215 (defun nonincremental-repeat-search-forward ()
216 "Search forward for the previous search string or regexp."
219 ((and (eq menu-bar-last-search-type 'string)
221 (search-forward (car search-ring)))
222 ((and (eq menu-bar-last-search-type 'regexp)
224 (re-search-forward (car regexp-search-ring)))
226 (error "No previous search"))))
228 (defun nonincremental-repeat-search-backward ()
229 "Search backward for the previous search string or regexp."
232 ((and (eq menu-bar-last-search-type 'string)
234 (search-backward (car search-ring)))
235 ((and (eq menu-bar-last-search-type 'regexp)
237 (re-search-backward (car regexp-search-ring)))
239 (error "No previous search"))))
241 (defun nonincremental-search-forward (string)
242 "Read a string and search for it nonincrementally."
243 (interactive "sSearch for string: ")
244 (setq menu-bar-last-search-type 'string)
245 (if (equal string "")
246 (search-forward (car search-ring))
247 (isearch-update-ring string nil)
248 (search-forward string)))
250 (defun nonincremental-search-backward (string)
251 "Read a string and search backward for it nonincrementally."
252 (interactive "sSearch for string: ")
253 (setq menu-bar-last-search-type 'string)
254 (if (equal string "")
255 (search-backward (car search-ring))
256 (isearch-update-ring string nil)
257 (search-backward string)))
259 (defun nonincremental-re-search-forward (string)
260 "Read a regular expression and search for it nonincrementally."
261 (interactive "sSearch for regexp: ")
262 (setq menu-bar-last-search-type 'regexp)
263 (if (equal string "")
264 (re-search-forward (car regexp-search-ring))
265 (isearch-update-ring string t)
266 (re-search-forward string)))
268 (defun nonincremental-re-search-backward (string)
269 "Read a regular expression and search backward for it nonincrementally."
270 (interactive "sSearch for regexp: ")
271 (setq menu-bar-last-search-type 'regexp)
272 (if (equal string "")
273 (re-search-backward (car regexp-search-ring))
274 (isearch-update-ring string t)
275 (re-search-backward string)))
277 ;; The Edit->Search->Incremental Search menu
278 (defvar menu-bar-i-search-menu
279 (let ((menu (make-sparse-keymap "Incremental Search")))
280 (bindings--define-key menu [isearch-backward-regexp]
281 '(menu-item "Backward Regexp..." isearch-backward-regexp
282 :help "Search backwards for a regular expression as you type it"))
283 (bindings--define-key menu [isearch-forward-regexp]
284 '(menu-item "Forward Regexp..." isearch-forward-regexp
285 :help "Search forward for a regular expression as you type it"))
286 (bindings--define-key menu [isearch-backward]
287 '(menu-item "Backward String..." isearch-backward
288 :help "Search backwards for a string as you type it"))
289 (bindings--define-key menu [isearch-forward]
290 '(menu-item "Forward String..." isearch-forward
291 :help "Search forward for a string as you type it"))
294 (defvar menu-bar-search-menu
295 (let ((menu (make-sparse-keymap "Search")))
297 (bindings--define-key menu [i-search]
298 `(menu-item "Incremental Search" ,menu-bar-i-search-menu))
299 (bindings--define-key menu [separator-tag-isearch]
302 (bindings--define-key menu [tags-continue]
303 '(menu-item "Continue Tags Search" tags-loop-continue
304 :help "Continue last tags search operation"))
305 (bindings--define-key menu [tags-srch]
306 '(menu-item "Search Tagged Files..." tags-search
307 :help "Search for a regexp in all tagged files"))
308 (bindings--define-key menu [separator-tag-search] menu-bar-separator)
310 (bindings--define-key menu [repeat-search-back]
311 '(menu-item "Repeat Backwards"
312 nonincremental-repeat-search-backward
313 :enable (or (and (eq menu-bar-last-search-type 'string)
315 (and (eq menu-bar-last-search-type 'regexp)
317 :help "Repeat last search backwards"))
318 (bindings--define-key menu [repeat-search-fwd]
319 '(menu-item "Repeat Forward"
320 nonincremental-repeat-search-forward
321 :enable (or (and (eq menu-bar-last-search-type 'string)
323 (and (eq menu-bar-last-search-type 'regexp)
325 :help "Repeat last search forward"))
326 (bindings--define-key menu [separator-repeat-search]
329 (bindings--define-key menu [re-search-backward]
330 '(menu-item "Regexp Backwards..."
331 nonincremental-re-search-backward
332 :help "Search backwards for a regular expression"))
333 (bindings--define-key menu [re-search-forward]
334 '(menu-item "Regexp Forward..."
335 nonincremental-re-search-forward
336 :help "Search forward for a regular expression"))
338 (bindings--define-key menu [search-backward]
339 '(menu-item "String Backwards..."
340 nonincremental-search-backward
341 :help "Search backwards for a string"))
342 (bindings--define-key menu [search-forward]
343 '(menu-item "String Forward..." nonincremental-search-forward
344 :help "Search forward for a string"))
347 ;; The Edit->Replace submenu
349 (defvar menu-bar-replace-menu
350 (let ((menu (make-sparse-keymap "Replace")))
351 (bindings--define-key menu [tags-repl-continue]
352 '(menu-item "Continue Replace" tags-loop-continue
353 :help "Continue last tags replace operation"))
354 (bindings--define-key menu [tags-repl]
355 '(menu-item "Replace in Tagged Files..." tags-query-replace
356 :help "Interactively replace a regexp in all tagged files"))
357 (bindings--define-key menu [separator-replace-tags]
360 (bindings--define-key menu [query-replace-regexp]
361 '(menu-item "Replace Regexp..." query-replace-regexp
362 :enable (not buffer-read-only)
363 :help "Replace regular expression interactively, ask about each occurrence"))
364 (bindings--define-key menu [query-replace]
365 '(menu-item "Replace String..." query-replace
366 :enable (not buffer-read-only)
367 :help "Replace string interactively, ask about each occurrence"))
370 ;;; Assemble the top-level Edit menu items.
371 (defvar menu-bar-goto-menu
372 (let ((menu (make-sparse-keymap "Go To")))
374 (bindings--define-key menu [set-tags-name]
375 '(menu-item "Set Tags File Name..." visit-tags-table
376 :visible (menu-bar-goto-uses-etags-p)
377 :help "Tell navigation commands which tag table file to use"))
379 (bindings--define-key menu [separator-tag-file]
380 '(menu-item "--" nil :visible (menu-bar-goto-uses-etags-p)))
382 (bindings--define-key menu [xref-pop]
383 '(menu-item "Back" xref-pop-marker-stack
384 :visible (and (featurep 'xref)
385 (not (xref-marker-stack-empty-p)))
386 :help "Back to the position of the last search"))
388 (bindings--define-key menu [xref-apropos]
389 '(menu-item "Find Apropos..." xref-find-apropos
390 :help "Find function/variables whose names match regexp"))
392 (bindings--define-key menu [xref-find-otherw]
393 '(menu-item "Find Definition in Other Window..."
394 xref-find-definitions-other-window
395 :help "Find function/variable definition in another window"))
396 (bindings--define-key menu [xref-find-def]
397 '(menu-item "Find Definition..." xref-find-definitions
398 :help "Find definition of function or variable"))
400 (bindings--define-key menu [separator-xref]
403 (bindings--define-key menu [end-of-buf]
404 '(menu-item "Goto End of Buffer" end-of-buffer))
405 (bindings--define-key menu [beg-of-buf]
406 '(menu-item "Goto Beginning of Buffer" beginning-of-buffer))
407 (bindings--define-key menu [go-to-pos]
408 '(menu-item "Goto Buffer Position..." goto-char
409 :help "Read a number N and go to buffer position N"))
410 (bindings--define-key menu [go-to-line]
411 '(menu-item "Goto Line..." goto-line
412 :help "Read a line number and go to that line"))
415 (defun menu-bar-goto-uses-etags-p ()
416 (or (not (boundp 'xref-find-function))
417 (eq xref-find-function 'etags-xref-find)))
419 (defvar yank-menu (cons (purecopy "Select Yank") nil))
420 (fset 'yank-menu (cons 'keymap yank-menu))
422 (defvar menu-bar-edit-menu
423 (let ((menu (make-sparse-keymap "Edit")))
425 (bindings--define-key menu [props]
426 `(menu-item "Text Properties" facemenu-menu))
428 ;; ns-win.el said: Add spell for platform consistency.
430 (bindings--define-key menu [spell]
431 `(menu-item "Spell" ispell-menu-map)))
433 (bindings--define-key menu [fill]
434 `(menu-item "Fill" fill-region
435 :enable (and mark-active (not buffer-read-only))
437 "Fill text in region to fit between left and right margin"))
439 (bindings--define-key menu [separator-bookmark]
442 (bindings--define-key menu [bookmark]
443 `(menu-item "Bookmarks" menu-bar-bookmark-map))
445 (bindings--define-key menu [goto]
446 `(menu-item "Go To" ,menu-bar-goto-menu))
448 (bindings--define-key menu [replace]
449 `(menu-item "Replace" ,menu-bar-replace-menu))
451 (bindings--define-key menu [search]
452 `(menu-item "Search" ,menu-bar-search-menu))
454 (bindings--define-key menu [separator-search]
457 (bindings--define-key menu [mark-whole-buffer]
458 '(menu-item "Select All" mark-whole-buffer
459 :help "Mark the whole buffer for a subsequent cut/copy"))
460 (bindings--define-key menu [clear]
461 '(menu-item "Clear" delete-region
462 :enable (and mark-active
463 (not buffer-read-only))
465 "Delete the text in region between mark and current position"))
468 (bindings--define-key menu (if (featurep 'ns) [select-paste]
470 ;; ns-win.el said: Change text to be more consistent with
471 ;; surrounding menu items `paste', etc."
472 `(menu-item ,(if (featurep 'ns) "Select and Paste" "Paste from Kill Menu")
474 :enable (and (cdr yank-menu) (not buffer-read-only))
475 :help "Choose a string from the kill ring and paste it"))
476 (bindings--define-key menu [paste]
477 `(menu-item "Paste" yank
481 (gui-backend-selection-exists-p 'CLIPBOARD)
482 (if (featurep 'ns) ; like paste-from-menu
485 (not buffer-read-only))))
486 :help "Paste (yank) text most recently cut/copied"))
487 (bindings--define-key menu [copy]
488 ;; ns-win.el said: Substitute a Copy function that works better
489 ;; under X (for GNUstep).
490 `(menu-item "Copy" ,(if (featurep 'ns)
491 'ns-copy-including-secondary
494 :help "Copy text in region between mark and current position"
495 :keys ,(if (featurep 'ns)
496 "\\[ns-copy-including-secondary]"
497 "\\[kill-ring-save]")))
498 (bindings--define-key menu [cut]
499 '(menu-item "Cut" kill-region
500 :enable (and mark-active (not buffer-read-only))
502 "Cut (kill) text in region between mark and current position"))
503 ;; ns-win.el said: Separate undo from cut/paste section.
505 (bindings--define-key menu [separator-undo] menu-bar-separator))
507 (bindings--define-key menu [undo]
508 '(menu-item "Undo" undo
509 :enable (and (not buffer-read-only)
510 (not (eq t buffer-undo-list))
511 (if (eq last-command 'undo)
512 (listp pending-undo-list)
513 (consp buffer-undo-list)))
514 :help "Undo last operation"))
518 (define-obsolete-function-alias
519 'menu-bar-kill-ring-save 'kill-ring-save "24.1")
521 ;; These are alternative definitions for the cut, paste and copy
522 ;; menu items. Use them if your system expects these to use the clipboard.
524 (put 'clipboard-kill-region 'menu-enable
525 '(and mark-active (not buffer-read-only)))
526 (put 'clipboard-kill-ring-save 'menu-enable 'mark-active)
527 (put 'clipboard-yank 'menu-enable
528 `(funcall ',(lambda ()
529 (and (or (gui-backend-selection-exists-p 'PRIMARY)
530 (gui-backend-selection-exists-p 'CLIPBOARD))
531 (not buffer-read-only)))))
533 (defvar gui-select-enable-clipboard)
535 (defun clipboard-yank ()
536 "Insert the clipboard contents, or the last stretch of killed text."
538 (let ((gui-select-enable-clipboard t))
541 (defun clipboard-kill-ring-save (beg end &optional region)
542 "Copy region to kill ring, and save in the GUI's clipboard."
544 (let ((gui-select-enable-clipboard t))
545 (kill-ring-save beg end region)))
547 (defun clipboard-kill-region (beg end &optional region)
548 "Kill the region, and save it in the GUI's clipboard."
550 (let ((gui-select-enable-clipboard t))
551 (kill-region beg end region)))
553 (defun menu-bar-enable-clipboard ()
554 "Make CUT, PASTE and COPY (keys and menu bar items) use the clipboard.
555 Do the same for the keys of the same name."
557 ;; These are Sun server keysyms for the Cut, Copy and Paste keys
558 ;; (also for XFree86 on Sun keyboard):
559 (define-key global-map [f20] 'clipboard-kill-region)
560 (define-key global-map [f16] 'clipboard-kill-ring-save)
561 (define-key global-map [f18] 'clipboard-yank)
563 (define-key global-map [cut] 'clipboard-kill-region)
564 (define-key global-map [copy] 'clipboard-kill-ring-save)
565 (define-key global-map [paste] 'clipboard-yank))
567 ;; The "Options" menu items
569 (defvar menu-bar-custom-menu
570 (let ((menu (make-sparse-keymap "Customize")))
572 (bindings--define-key menu [customize-apropos-faces]
573 '(menu-item "Faces Matching..." customize-apropos-faces
574 :help "Browse faces matching a regexp or word list"))
575 (bindings--define-key menu [customize-apropos-options]
576 '(menu-item "Options Matching..." customize-apropos-options
577 :help "Browse options matching a regexp or word list"))
578 (bindings--define-key menu [customize-apropos]
579 '(menu-item "All Settings Matching..." customize-apropos
580 :help "Browse customizable settings matching a regexp or word list"))
581 (bindings--define-key menu [separator-1]
583 (bindings--define-key menu [customize-group]
584 '(menu-item "Specific Group..." customize-group
585 :help "Customize settings of specific group"))
586 (bindings--define-key menu [customize-face]
587 '(menu-item "Specific Face..." customize-face
588 :help "Customize attributes of specific face"))
589 (bindings--define-key menu [customize-option]
590 '(menu-item "Specific Option..." customize-option
591 :help "Customize value of specific option"))
592 (bindings--define-key menu [separator-2]
594 (bindings--define-key menu [customize-changed-options]
595 '(menu-item "New Options..." customize-changed-options
596 :help "Options added or changed in recent Emacs versions"))
597 (bindings--define-key menu [customize-saved]
598 '(menu-item "Saved Options" customize-saved
599 :help "Customize previously saved options"))
600 (bindings--define-key menu [separator-3]
602 (bindings--define-key menu [customize-browse]
603 '(menu-item "Browse Customization Groups" customize-browse
604 :help "Browse all customization groups"))
605 (bindings--define-key menu [customize]
606 '(menu-item "Top-level Customization Group" customize
607 :help "The master group called `Emacs'"))
608 (bindings--define-key menu [customize-themes]
609 '(menu-item "Custom Themes" customize-themes
610 :help "Choose a pre-defined customization theme"))
612 ;(defvar menu-bar-preferences-menu (make-sparse-keymap "Preferences"))
614 (defmacro menu-bar-make-mm-toggle (fname doc help &optional props)
615 "Make a menu-item for a global minor mode toggle.
616 FNAME is the minor mode's name (variable and function).
617 DOC is the text to use for the menu entry.
618 HELP is the text to use for the tooltip.
619 PROPS are additional properties."
620 `'(menu-item ,doc ,fname
623 :button (:toggle . (and (default-boundp ',fname)
624 (default-value ',fname)))))
626 (defmacro menu-bar-make-toggle (name variable doc message help &rest body)
628 (defun ,name (&optional interactively)
629 ,(concat "Toggle whether to " (downcase (substring help 0 1))
630 (substring help 1) ".
631 In an interactive call, record this option as a candidate for saving
632 by \"Save Options\" in Custom buffers.")
634 (if ,(if body `(progn . ,body)
636 (custom-load-symbol ',variable)
637 (let ((set (or (get ',variable 'custom-set) 'set-default))
638 (get (or (get ',variable 'custom-get) 'default-value)))
639 (funcall set ',variable (not (funcall get ',variable))))))
640 (message ,message "enabled globally")
641 (message ,message "disabled globally"))
642 ;; The function `customize-mark-as-set' must only be called when
643 ;; a variable is set interactively, as the purpose is to mark it as
644 ;; a candidate for "Save Options", and we do not want to save options
645 ;; the user have already set explicitly in his init file.
646 (if interactively (customize-mark-as-set ',variable)))
647 '(menu-item ,doc ,name
649 :button (:toggle . (and (default-boundp ',variable)
650 (default-value ',variable))))))
652 ;; Function for setting/saving default font.
654 (defun menu-set-font ()
655 "Interactively select a font and make it the default on all existing frames."
657 (set-frame-font (if (fboundp 'x-select-font)
662 (defun menu-bar-options-save ()
663 "Save current values of Options menu items using Custom."
665 (let ((need-save nil))
666 ;; These are set with menu-bar-make-mm-toggle, which does not
667 ;; put on a customized-value property.
668 (dolist (elt '(line-number-mode column-number-mode size-indication-mode
669 cua-mode show-paren-mode transient-mark-mode
670 blink-cursor-mode display-time-mode display-battery-mode
671 ;; These are set by other functions that don't set
672 ;; the customized state. Having them here has the
673 ;; side-effect that turning them off via X
674 ;; resources acts like having customized them, but
675 ;; that seems harmless.
676 menu-bar-mode tool-bar-mode))
677 ;; FIXME ? It's a little annoying that running this command
678 ;; always loads cua-base, paren, time, and battery, even if they
679 ;; have not been customized in any way. (Due to custom-load-symbol.)
680 (and (customize-mark-to-save elt)
682 ;; These are set with `customize-set-variable'.
683 (dolist (elt '(scroll-bar-mode
684 debug-on-quit debug-on-error
685 ;; Somehow this works, when tool-bar and menu-bar don't.
686 tooltip-mode window-divider-mode
687 save-place uniquify-buffer-name-style fringe-mode
688 indicate-empty-lines indicate-buffer-boundaries
689 case-fold-search font-use-system-font
690 current-language-environment default-input-method
691 ;; Saving `text-mode-hook' is somewhat questionable,
692 ;; as we might get more than we bargain for, if
693 ;; other code may has added hooks as well.
694 ;; Nonetheless, not saving it would like be confuse
696 ;; -- Per Abrahamsen <abraham@dina.kvl.dk> 2002-02-11.
697 text-mode-hook tool-bar-position))
698 (and (get elt 'customized-value)
699 (customize-mark-to-save elt)
701 (when (get 'default 'customized-face)
702 (put 'default 'saved-face (get 'default 'customized-face))
703 (put 'default 'customized-face nil)
705 ;; Save if we changed anything.
710 ;;; Assemble all the top-level items of the "Options" menu
712 ;; The "Show/Hide" submenu of menu "Options"
714 (defun menu-bar-window-divider-customize ()
715 "Show customization buffer for `window-divider' group."
717 (customize-group 'window-divider))
719 (defun menu-bar-bottom-and-right-window-divider ()
720 "Display dividers on the bottom and right of each window."
722 (customize-set-variable 'window-divider-mode t))
724 (defun menu-bar-right-window-divider ()
725 "Display dividers only on the right of each window."
727 (customize-set-variable 'window-divider-mode 'right-only))
729 (defun menu-bar-bottom-window-divider ()
730 "Display dividers only at the bottom of each window."
732 (customize-set-variable 'window-divider-mode 'bottom-only))
734 (defun menu-bar-no-window-divider ()
735 "Do not display window dividers."
737 (customize-set-variable 'window-divider-mode nil))
739 ;; For the radio buttons below we check whether the respective dividers
740 ;; are displayed on the selected frame. This is not fully congruent
741 ;; with `window-divder-mode' but makes the menu entries work also when
742 ;; dividers are displayed by manipulating frame parameters directly.
743 (defvar menu-bar-showhide-window-divider-menu
744 (let ((menu (make-sparse-keymap "Window Divider")))
745 (bindings--define-key menu [customize]
746 '(menu-item "Customize" menu-bar-window-divider-customize
747 :help "Customize window dividers"
748 :visible (memq (window-system) '(x w32))))
750 (bindings--define-key menu [bottom-and-right]
751 '(menu-item "Bottom and Right"
752 menu-bar-bottom-and-right-window-divider
753 :help "Display window divider on the bottom and right of each window"
754 :visible (memq (window-system) '(x w32))
756 . (and (frame-window-divider-width-valid-p
757 (cdr (assq 'bottom-divider-width
758 (frame-parameters))))
759 (frame-window-divider-width-valid-p
760 (cdr (assq 'right-divider-width
761 (frame-parameters))))))))
762 (bindings--define-key menu [right-only]
763 '(menu-item "Right Only"
764 menu-bar-right-window-divider
765 :help "Display window divider on the right of each window only"
766 :visible (memq (window-system) '(x w32))
768 . (and (not (frame-window-divider-width-valid-p
769 (cdr (assq 'bottom-divider-width
770 (frame-parameters)))))
771 (frame-window-divider-width-valid-p
772 (cdr (assq 'right-divider-width
773 (frame-parameters))))))))
774 (bindings--define-key menu [bottom-only]
775 '(menu-item "Bottom Only"
776 menu-bar-bottom-window-divider
777 :help "Display window divider on the bottom of each window only"
778 :visible (memq (window-system) '(x w32))
780 . (and (frame-window-divider-width-valid-p
781 (cdr (assq 'bottom-divider-width
782 (frame-parameters))))
783 (not (frame-window-divider-width-valid-p
784 (cdr (assq 'right-divider-width
785 (frame-parameters)))))))))
786 (bindings--define-key menu [no-divider]
788 menu-bar-no-window-divider
789 :help "Do not display window dividers"
790 :visible (memq (window-system) '(x w32))
792 . (and (not (frame-window-divider-width-valid-p
793 (cdr (assq 'bottom-divider-width
794 (frame-parameters)))))
795 (not (frame-window-divider-width-valid-p
796 (cdr (assq 'right-divider-width
797 (frame-parameters)))))))))
800 (defun menu-bar-showhide-fringe-ind-customize ()
801 "Show customization buffer for `indicate-buffer-boundaries'."
803 (customize-variable 'indicate-buffer-boundaries))
805 (defun menu-bar-showhide-fringe-ind-mixed ()
806 "Display top and bottom indicators in opposite fringes, arrows in right."
808 (customize-set-variable 'indicate-buffer-boundaries
809 '((t . right) (top . left))))
811 (defun menu-bar-showhide-fringe-ind-box ()
812 "Display top and bottom indicators in opposite fringes."
814 (customize-set-variable 'indicate-buffer-boundaries
815 '((top . left) (bottom . right))))
817 (defun menu-bar-showhide-fringe-ind-right ()
818 "Display buffer boundaries and arrows in the right fringe."
820 (customize-set-variable 'indicate-buffer-boundaries 'right))
822 (defun menu-bar-showhide-fringe-ind-left ()
823 "Display buffer boundaries and arrows in the left fringe."
825 (customize-set-variable 'indicate-buffer-boundaries 'left))
827 (defun menu-bar-showhide-fringe-ind-none ()
828 "Do not display any buffer boundary indicators."
830 (customize-set-variable 'indicate-buffer-boundaries nil))
832 (defvar menu-bar-showhide-fringe-ind-menu
833 (let ((menu (make-sparse-keymap "Buffer boundaries")))
835 (bindings--define-key menu [customize]
836 '(menu-item "Other (Customize)"
837 menu-bar-showhide-fringe-ind-customize
838 :help "Additional choices available through Custom buffer"
839 :visible (display-graphic-p)
840 :button (:radio . (not (member indicate-buffer-boundaries
842 ((top . left) (bottom . right))
843 ((t . right) (top . left))))))))
845 (bindings--define-key menu [mixed]
846 '(menu-item "Opposite, Arrows Right" menu-bar-showhide-fringe-ind-mixed
848 "Show top/bottom indicators in opposite fringes, arrows in right"
849 :visible (display-graphic-p)
850 :button (:radio . (equal indicate-buffer-boundaries
851 '((t . right) (top . left))))))
853 (bindings--define-key menu [box]
854 '(menu-item "Opposite, No Arrows" menu-bar-showhide-fringe-ind-box
855 :help "Show top/bottom indicators in opposite fringes, no arrows"
856 :visible (display-graphic-p)
857 :button (:radio . (equal indicate-buffer-boundaries
858 '((top . left) (bottom . right))))))
860 (bindings--define-key menu [right]
861 '(menu-item "In Right Fringe" menu-bar-showhide-fringe-ind-right
862 :help "Show buffer boundaries and arrows in right fringe"
863 :visible (display-graphic-p)
864 :button (:radio . (eq indicate-buffer-boundaries 'right))))
866 (bindings--define-key menu [left]
867 '(menu-item "In Left Fringe" menu-bar-showhide-fringe-ind-left
868 :help "Show buffer boundaries and arrows in left fringe"
869 :visible (display-graphic-p)
870 :button (:radio . (eq indicate-buffer-boundaries 'left))))
872 (bindings--define-key menu [none]
873 '(menu-item "No Indicators" menu-bar-showhide-fringe-ind-none
874 :help "Hide all buffer boundary indicators and arrows"
875 :visible (display-graphic-p)
876 :button (:radio . (eq indicate-buffer-boundaries nil))))
879 (defun menu-bar-showhide-fringe-menu-customize ()
880 "Show customization buffer for `fringe-mode'."
882 (customize-variable 'fringe-mode))
884 (defun menu-bar-showhide-fringe-menu-customize-reset ()
885 "Reset the fringe mode: display fringes on both sides of a window."
887 (customize-set-variable 'fringe-mode nil))
889 (defun menu-bar-showhide-fringe-menu-customize-right ()
890 "Display fringes only on the right of each window."
893 (customize-set-variable 'fringe-mode '(0 . nil)))
895 (defun menu-bar-showhide-fringe-menu-customize-left ()
896 "Display fringes only on the left of each window."
899 (customize-set-variable 'fringe-mode '(nil . 0)))
901 (defun menu-bar-showhide-fringe-menu-customize-disable ()
902 "Do not display window fringes."
905 (customize-set-variable 'fringe-mode 0))
907 (defvar menu-bar-showhide-fringe-menu
908 (let ((menu (make-sparse-keymap "Fringe")))
910 (bindings--define-key menu [showhide-fringe-ind]
911 `(menu-item "Buffer Boundaries" ,menu-bar-showhide-fringe-ind-menu
912 :visible (display-graphic-p)
913 :help "Indicate buffer boundaries in fringe"))
915 (bindings--define-key menu [indicate-empty-lines]
916 (menu-bar-make-toggle toggle-indicate-empty-lines indicate-empty-lines
917 "Empty Line Indicators"
918 "Indicating of empty lines %s"
919 "Indicate trailing empty lines in fringe, globally"))
921 (bindings--define-key menu [customize]
922 '(menu-item "Customize Fringe" menu-bar-showhide-fringe-menu-customize
923 :help "Detailed customization of fringe"
924 :visible (display-graphic-p)))
926 (bindings--define-key menu [default]
927 '(menu-item "Default" menu-bar-showhide-fringe-menu-customize-reset
928 :help "Default width fringe on both left and right side"
929 :visible (display-graphic-p)
930 :button (:radio . (eq fringe-mode nil))))
932 (bindings--define-key menu [right]
933 '(menu-item "On the Right" menu-bar-showhide-fringe-menu-customize-right
934 :help "Fringe only on the right side"
935 :visible (display-graphic-p)
936 :button (:radio . (equal fringe-mode '(0 . nil)))))
938 (bindings--define-key menu [left]
939 '(menu-item "On the Left" menu-bar-showhide-fringe-menu-customize-left
940 :help "Fringe only on the left side"
941 :visible (display-graphic-p)
942 :button (:radio . (equal fringe-mode '(nil . 0)))))
944 (bindings--define-key menu [none]
945 '(menu-item "None" menu-bar-showhide-fringe-menu-customize-disable
946 :help "Turn off fringe"
947 :visible (display-graphic-p)
948 :button (:radio . (eq fringe-mode 0))))
951 (defun menu-bar-right-scroll-bar ()
952 "Display scroll bars on the right of each window."
954 (customize-set-variable 'scroll-bar-mode 'right))
956 (defun menu-bar-left-scroll-bar ()
957 "Display scroll bars on the left of each window."
959 (customize-set-variable 'scroll-bar-mode 'left))
961 (defun menu-bar-no-scroll-bar ()
962 "Turn off scroll bars."
964 (customize-set-variable 'scroll-bar-mode nil))
966 (defun menu-bar-horizontal-scroll-bar ()
967 "Display horizontal scroll bars on each window."
969 (customize-set-variable 'horizontal-scroll-bar-mode t))
971 (defun menu-bar-no-horizontal-scroll-bar ()
972 "Turn off horizontal scroll bars."
974 (customize-set-variable 'horizontal-scroll-bar-mode nil))
976 (defvar menu-bar-showhide-scroll-bar-menu
977 (let ((menu (make-sparse-keymap "Scroll-bar")))
978 (bindings--define-key menu [horizontal]
979 '(menu-item "Horizontal"
980 menu-bar-horizontal-scroll-bar
981 :help "Horizontal scroll bar"
982 :visible (horizontal-scroll-bars-available-p)
983 :button (:radio . (cdr (assq 'horizontal-scroll-bars
984 (frame-parameters))))))
986 (bindings--define-key menu [none-horizontal]
987 '(menu-item "None-horizontal"
988 menu-bar-no-horizontal-scroll-bar
989 :help "Turn off horizontal scroll bars"
990 :visible (horizontal-scroll-bars-available-p)
991 :button (:radio . (not (cdr (assq 'horizontal-scroll-bars
992 (frame-parameters)))))))
994 (bindings--define-key menu [right]
995 '(menu-item "On the Right"
996 menu-bar-right-scroll-bar
997 :help "Scroll-bar on the right side"
998 :visible (display-graphic-p)
999 :button (:radio . (eq (cdr (assq 'vertical-scroll-bars
1000 (frame-parameters)))
1003 (bindings--define-key menu [left]
1004 '(menu-item "On the Left"
1005 menu-bar-left-scroll-bar
1006 :help "Scroll-bar on the left side"
1007 :visible (display-graphic-p)
1008 :button (:radio . (eq (cdr (assq 'vertical-scroll-bars
1009 (frame-parameters)))
1012 (bindings--define-key menu [none]
1014 menu-bar-no-scroll-bar
1015 :help "Turn off scroll-bar"
1016 :visible (display-graphic-p)
1017 :button (:radio . (eq (cdr (assq 'vertical-scroll-bars
1018 (frame-parameters)))
1022 (defun menu-bar-frame-for-menubar ()
1023 "Return the frame suitable for updating the menu bar."
1024 (or (and (framep menu-updating-frame)
1025 menu-updating-frame)
1028 (defun menu-bar-positive-p (val)
1029 "Return non-nil if VAL is a positive number."
1033 (defun menu-bar-set-tool-bar-position (position)
1034 (customize-set-variable 'tool-bar-mode t)
1035 (customize-set-variable 'tool-bar-position position))
1036 (defun menu-bar-showhide-tool-bar-menu-customize-disable ()
1037 "Do not display tool bars."
1039 (customize-set-variable 'tool-bar-mode nil))
1040 (defun menu-bar-showhide-tool-bar-menu-customize-enable-left ()
1041 "Display tool bars on the left side."
1043 (menu-bar-set-tool-bar-position 'left))
1044 (defun menu-bar-showhide-tool-bar-menu-customize-enable-right ()
1045 "Display tool bars on the right side."
1047 (menu-bar-set-tool-bar-position 'right))
1048 (defun menu-bar-showhide-tool-bar-menu-customize-enable-top ()
1049 "Display tool bars on the top side."
1051 (menu-bar-set-tool-bar-position 'top))
1052 (defun menu-bar-showhide-tool-bar-menu-customize-enable-bottom ()
1053 "Display tool bars on the bottom side."
1055 (menu-bar-set-tool-bar-position 'bottom))
1057 (when (featurep 'move-toolbar)
1058 (defvar menu-bar-showhide-tool-bar-menu
1059 (let ((menu (make-sparse-keymap "Tool-bar")))
1061 (bindings--define-key menu [showhide-tool-bar-left]
1062 '(menu-item "On the Left"
1063 menu-bar-showhide-tool-bar-menu-customize-enable-left
1064 :help "Tool-bar at the left side"
1065 :visible (display-graphic-p)
1067 (:radio . (and tool-bar-mode
1068 (eq (frame-parameter
1069 (menu-bar-frame-for-menubar)
1073 (bindings--define-key menu [showhide-tool-bar-right]
1074 '(menu-item "On the Right"
1075 menu-bar-showhide-tool-bar-menu-customize-enable-right
1076 :help "Tool-bar at the right side"
1077 :visible (display-graphic-p)
1079 (:radio . (and tool-bar-mode
1080 (eq (frame-parameter
1081 (menu-bar-frame-for-menubar)
1085 (bindings--define-key menu [showhide-tool-bar-bottom]
1086 '(menu-item "On the Bottom"
1087 menu-bar-showhide-tool-bar-menu-customize-enable-bottom
1088 :help "Tool-bar at the bottom"
1089 :visible (display-graphic-p)
1091 (:radio . (and tool-bar-mode
1092 (eq (frame-parameter
1093 (menu-bar-frame-for-menubar)
1097 (bindings--define-key menu [showhide-tool-bar-top]
1098 '(menu-item "On the Top"
1099 menu-bar-showhide-tool-bar-menu-customize-enable-top
1100 :help "Tool-bar at the top"
1101 :visible (display-graphic-p)
1103 (:radio . (and tool-bar-mode
1104 (eq (frame-parameter
1105 (menu-bar-frame-for-menubar)
1109 (bindings--define-key menu [showhide-tool-bar-none]
1111 menu-bar-showhide-tool-bar-menu-customize-disable
1112 :help "Turn tool-bar off"
1113 :visible (display-graphic-p)
1114 :button (:radio . (eq tool-bar-mode nil))))
1117 (defvar menu-bar-showhide-menu
1118 (let ((menu (make-sparse-keymap "Show/Hide")))
1120 (bindings--define-key menu [column-number-mode]
1121 (menu-bar-make-mm-toggle column-number-mode
1123 "Show the current column number in the mode line"))
1125 (bindings--define-key menu [line-number-mode]
1126 (menu-bar-make-mm-toggle line-number-mode
1128 "Show the current line number in the mode line"))
1130 (bindings--define-key menu [size-indication-mode]
1131 (menu-bar-make-mm-toggle size-indication-mode
1133 "Show the size of the buffer in the mode line"))
1135 (bindings--define-key menu [linecolumn-separator]
1138 (bindings--define-key menu [showhide-battery]
1139 (menu-bar-make-mm-toggle display-battery-mode
1141 "Display battery status information in mode line"))
1143 (bindings--define-key menu [showhide-date-time]
1144 (menu-bar-make-mm-toggle display-time-mode
1145 "Time, Load and Mail"
1146 "Display time, system load averages and \
1147 mail status in mode line"))
1149 (bindings--define-key menu [datetime-separator]
1152 (bindings--define-key menu [showhide-speedbar]
1153 '(menu-item "Speedbar" speedbar-frame-mode
1154 :help "Display a Speedbar quick-navigation frame"
1156 . (and (boundp 'speedbar-frame)
1157 (frame-live-p (symbol-value 'speedbar-frame))
1159 (symbol-value 'speedbar-frame))))))
1161 (bindings--define-key menu [showhide-window-divider]
1162 `(menu-item "Window Divider" ,menu-bar-showhide-window-divider-menu
1163 :visible (memq (window-system) '(x w32))))
1165 (bindings--define-key menu [showhide-fringe]
1166 `(menu-item "Fringe" ,menu-bar-showhide-fringe-menu
1167 :visible (display-graphic-p)))
1169 (bindings--define-key menu [showhide-scroll-bar]
1170 `(menu-item "Scroll-bar" ,menu-bar-showhide-scroll-bar-menu
1171 :visible (display-graphic-p)))
1173 (bindings--define-key menu [showhide-tooltip-mode]
1174 '(menu-item "Tooltips" tooltip-mode
1175 :help "Turn tooltips on/off"
1176 :visible (and (display-graphic-p) (fboundp 'x-show-tip))
1177 :button (:toggle . tooltip-mode)))
1179 (bindings--define-key menu [menu-bar-mode]
1180 '(menu-item "Menu-bar" toggle-menu-bar-mode-from-frame
1181 :help "Turn menu-bar on/off"
1183 (:toggle . (menu-bar-positive-p
1184 (frame-parameter (menu-bar-frame-for-menubar)
1185 'menu-bar-lines)))))
1187 (if (and (boundp 'menu-bar-showhide-tool-bar-menu)
1188 (keymapp menu-bar-showhide-tool-bar-menu))
1189 (bindings--define-key menu [showhide-tool-bar]
1190 `(menu-item "Tool-bar" ,menu-bar-showhide-tool-bar-menu
1191 :visible (display-graphic-p)))
1192 ;; else not tool bar that can move.
1193 (bindings--define-key menu [showhide-tool-bar]
1194 '(menu-item "Tool-bar" toggle-tool-bar-mode-from-frame
1195 :help "Turn tool-bar on/off"
1196 :visible (display-graphic-p)
1198 (:toggle . (menu-bar-positive-p
1199 (frame-parameter (menu-bar-frame-for-menubar)
1200 'tool-bar-lines))))))
1203 (defvar menu-bar-line-wrapping-menu
1204 (let ((menu (make-sparse-keymap "Line Wrapping")))
1206 (bindings--define-key menu [word-wrap]
1207 `(menu-item "Word Wrap (Visual Line mode)"
1210 (unless visual-line-mode
1211 (visual-line-mode 1))
1212 (message "Visual-Line mode enabled"))
1213 :help "Wrap long lines at word boundaries"
1215 . (and (null truncate-lines)
1216 (not (truncated-partial-width-window-p))
1218 :visible (menu-bar-menu-frame-live-and-visible-p)))
1220 (bindings--define-key menu [truncate]
1221 `(menu-item "Truncate Long Lines"
1224 (if visual-line-mode (visual-line-mode 0))
1225 (setq word-wrap nil)
1226 (toggle-truncate-lines 1))
1227 :help "Truncate long lines at window edge"
1228 :button (:radio . (or truncate-lines
1229 (truncated-partial-width-window-p)))
1230 :visible (menu-bar-menu-frame-live-and-visible-p)
1231 :enable (not (truncated-partial-width-window-p))))
1233 (bindings--define-key menu [window-wrap]
1234 `(menu-item "Wrap at Window Edge"
1235 ,(lambda () (interactive)
1236 (if visual-line-mode (visual-line-mode 0))
1237 (setq word-wrap nil)
1238 (if truncate-lines (toggle-truncate-lines -1)))
1239 :help "Wrap long lines at window edge"
1241 . (and (null truncate-lines)
1242 (not (truncated-partial-width-window-p))
1244 :visible (menu-bar-menu-frame-live-and-visible-p)
1245 :enable (not (truncated-partial-width-window-p))))
1248 (defvar menu-bar-options-menu
1249 (let ((menu (make-sparse-keymap "Options")))
1250 (bindings--define-key menu [customize]
1251 `(menu-item "Customize Emacs" ,menu-bar-custom-menu))
1253 (bindings--define-key menu [package]
1254 '(menu-item "Manage Emacs Packages" package-list-packages
1255 :help "Install or uninstall additional Emacs packages"))
1257 (bindings--define-key menu [save]
1258 '(menu-item "Save Options" menu-bar-options-save
1259 :help "Save options set from the menu above"))
1261 (bindings--define-key menu [custom-separator]
1264 (bindings--define-key menu [menu-set-font]
1265 '(menu-item "Set Default Font..." menu-set-font
1266 :visible (display-multi-font-p)
1267 :help "Select a default font"))
1269 (if (featurep 'system-font-setting)
1270 (bindings--define-key menu [menu-system-font]
1271 (menu-bar-make-toggle
1272 toggle-use-system-font font-use-system-font
1274 "Use system font: %s"
1275 "Use the monospaced font defined by the system")))
1277 (bindings--define-key menu [showhide]
1278 `(menu-item "Show/Hide" ,menu-bar-showhide-menu))
1280 (bindings--define-key menu [showhide-separator]
1283 (bindings--define-key menu [mule]
1284 ;; It is better not to use backquote here,
1285 ;; because that makes a bootstrapping problem
1286 ;; if you need to recompile all the Lisp files using interpreted code.
1287 `(menu-item "Multilingual Environment" ,mule-menu-keymap
1288 ;; Most of the MULE menu actually does make sense in
1289 ;; unibyte mode, e.g. language selection.
1290 ;; :visible '(default-value 'enable-multibyte-characters)
1292 ;;(setq menu-bar-final-items (cons 'mule menu-bar-final-items))
1293 ;;(bindings--define-key menu [preferences]
1294 ;; `(menu-item "Preferences" ,menu-bar-preferences-menu
1295 ;; :help "Toggle important global options"))
1297 (bindings--define-key menu [mule-separator]
1300 (bindings--define-key menu [debug-on-quit]
1301 (menu-bar-make-toggle toggle-debug-on-quit debug-on-quit
1302 "Enter Debugger on Quit/C-g" "Debug on Quit %s"
1303 "Enter Lisp debugger when C-g is pressed"))
1304 (bindings--define-key menu [debug-on-error]
1305 (menu-bar-make-toggle toggle-debug-on-error debug-on-error
1306 "Enter Debugger on Error" "Debug on Error %s"
1307 "Enter Lisp debugger when an error is signaled"))
1308 (bindings--define-key menu [debugger-separator]
1311 (bindings--define-key menu [blink-cursor-mode]
1312 (menu-bar-make-mm-toggle
1315 "Whether the cursor blinks (Blink Cursor mode)"))
1316 (bindings--define-key menu [cursor-separator]
1319 (bindings--define-key menu [save-place]
1320 (menu-bar-make-toggle
1321 toggle-save-place-globally save-place
1322 "Save Place in Files between Sessions"
1323 "Saving place in files %s"
1324 "Visit files of previous session when restarting Emacs"
1325 (require 'saveplace)
1326 ;; Do it by name, to avoid a free-variable
1327 ;; warning during byte compilation.
1329 'save-place (not (symbol-value 'save-place)))))
1331 (bindings--define-key menu [uniquify]
1332 (menu-bar-make-toggle
1333 toggle-uniquify-buffer-names uniquify-buffer-name-style
1334 "Use Directory Names in Buffer Names"
1335 "Directory name in buffer names (uniquify) %s"
1336 "Uniquify buffer names by adding parent directory names"
1337 (setq uniquify-buffer-name-style
1338 (if (not uniquify-buffer-name-style)
1339 'post-forward-angle-brackets))))
1341 (bindings--define-key menu [edit-options-separator]
1343 (bindings--define-key menu [cua-mode]
1344 (menu-bar-make-mm-toggle
1346 "Use CUA Keys (Cut/Paste with C-x/C-c/C-v)"
1347 "Use C-z/C-x/C-c/C-v keys for undo/cut/copy/paste"
1348 (:visible (or (not (boundp 'cua-enable-cua-keys))
1349 cua-enable-cua-keys))))
1351 (bindings--define-key menu [cua-emulation-mode]
1352 (menu-bar-make-mm-toggle
1354 "Shift movement mark region (CUA)"
1355 "Use shifted movement keys to set and extend the region"
1356 (:visible (and (boundp 'cua-enable-cua-keys)
1357 (not cua-enable-cua-keys)))))
1359 (bindings--define-key menu [case-fold-search]
1360 (menu-bar-make-toggle
1361 toggle-case-fold-search case-fold-search
1362 "Ignore Case for Search"
1363 "Case-Insensitive Search %s"
1364 "Ignore letter-case in search commands"))
1366 (bindings--define-key menu [line-wrapping]
1367 `(menu-item "Line Wrapping in This Buffer"
1368 ,menu-bar-line-wrapping-menu))
1371 (bindings--define-key menu [highlight-separator]
1373 (bindings--define-key menu [highlight-paren-mode]
1374 (menu-bar-make-mm-toggle
1376 "Highlight Matching Parentheses"
1377 "Highlight matching/mismatched parentheses at cursor (Show Paren mode)"))
1378 (bindings--define-key menu [transient-mark-mode]
1379 (menu-bar-make-mm-toggle
1381 "Highlight Active Region"
1382 "Make text in active region stand out in color (Transient Mark mode)"
1383 (:enable (not cua-mode))))
1387 ;; The "Tools" menu items
1389 (defvar menu-bar-games-menu
1390 (let ((menu (make-sparse-keymap "Games")))
1392 (bindings--define-key menu [zone]
1393 '(menu-item "Zone Out" zone
1394 :help "Play tricks with Emacs display when Emacs is idle"))
1395 (bindings--define-key menu [tetris]
1396 '(menu-item "Tetris" tetris
1397 :help "Falling blocks game"))
1398 (bindings--define-key menu [solitaire]
1399 '(menu-item "Solitaire" solitaire
1400 :help "Get rid of all the stones"))
1401 (bindings--define-key menu [snake]
1402 '(menu-item "Snake" snake
1403 :help "Move snake around avoiding collisions"))
1404 (bindings--define-key menu [pong]
1405 '(menu-item "Pong" pong
1406 :help "Bounce the ball to your opponent"))
1407 (bindings--define-key menu [mult]
1408 '(menu-item "Multiplication Puzzle" mpuz
1409 :help "Exercise brain with multiplication"))
1410 (bindings--define-key menu [life]
1411 '(menu-item "Life" life
1412 :help "Watch how John Conway's cellular automaton evolves"))
1413 (bindings--define-key menu [hanoi]
1414 '(menu-item "Towers of Hanoi" hanoi
1415 :help "Watch Towers-of-Hanoi puzzle solved by Emacs"))
1416 (bindings--define-key menu [gomoku]
1417 '(menu-item "Gomoku" gomoku
1418 :help "Mark 5 contiguous squares (like tic-tac-toe)"))
1419 (bindings--define-key menu [bubbles]
1420 '(menu-item "Bubbles" bubbles
1421 :help "Remove all bubbles using the fewest moves"))
1422 (bindings--define-key menu [black-box]
1423 '(menu-item "Blackbox" blackbox
1424 :help "Find balls in a black box by shooting rays"))
1425 (bindings--define-key menu [adventure]
1426 '(menu-item "Adventure" dunnet
1427 :help "Dunnet, a text Adventure game for Emacs"))
1428 (bindings--define-key menu [5x5]
1429 '(menu-item "5x5" 5x5
1430 :help "Fill in all the squares on a 5x5 board"))
1433 (defvar menu-bar-encryption-decryption-menu
1434 (let ((menu (make-sparse-keymap "Encryption/Decryption")))
1435 (bindings--define-key menu [insert-keys]
1436 '(menu-item "Insert Keys" epa-insert-keys
1437 :help "Insert public keys after the current point"))
1439 (bindings--define-key menu [export-keys]
1440 '(menu-item "Export Keys" epa-export-keys
1441 :help "Export public keys to a file"))
1443 (bindings--define-key menu [import-keys-region]
1444 '(menu-item "Import Keys from Region" epa-import-keys-region
1445 :help "Import public keys from the current region"))
1447 (bindings--define-key menu [import-keys]
1448 '(menu-item "Import Keys from File..." epa-import-keys
1449 :help "Import public keys from a file"))
1451 (bindings--define-key menu [list-keys]
1452 '(menu-item "List Keys" epa-list-keys
1453 :help "Browse your public keyring"))
1455 (bindings--define-key menu [separator-keys]
1458 (bindings--define-key menu [sign-region]
1459 '(menu-item "Sign Region" epa-sign-region
1460 :help "Create digital signature of the current region"))
1462 (bindings--define-key menu [verify-region]
1463 '(menu-item "Verify Region" epa-verify-region
1464 :help "Verify digital signature of the current region"))
1466 (bindings--define-key menu [encrypt-region]
1467 '(menu-item "Encrypt Region" epa-encrypt-region
1468 :help "Encrypt the current region"))
1470 (bindings--define-key menu [decrypt-region]
1471 '(menu-item "Decrypt Region" epa-decrypt-region
1472 :help "Decrypt the current region"))
1474 (bindings--define-key menu [separator-file]
1477 (bindings--define-key menu [sign-file]
1478 '(menu-item "Sign File..." epa-sign-file
1479 :help "Create digital signature of a file"))
1481 (bindings--define-key menu [verify-file]
1482 '(menu-item "Verify File..." epa-verify-file
1483 :help "Verify digital signature of a file"))
1485 (bindings--define-key menu [encrypt-file]
1486 '(menu-item "Encrypt File..." epa-encrypt-file
1487 :help "Encrypt a file"))
1489 (bindings--define-key menu [decrypt-file]
1490 '(menu-item "Decrypt File..." epa-decrypt-file
1491 :help "Decrypt a file"))
1495 (defun menu-bar-read-mail ()
1496 "Read mail using `read-mail-command'."
1498 (call-interactively read-mail-command))
1500 (defvar menu-bar-tools-menu
1501 (let ((menu (make-sparse-keymap "Tools")))
1503 (bindings--define-key menu [games]
1504 `(menu-item "Games" ,menu-bar-games-menu))
1506 (bindings--define-key menu [separator-games]
1509 (bindings--define-key menu [encryption-decryption]
1510 `(menu-item "Encryption/Decryption"
1511 ,menu-bar-encryption-decryption-menu))
1513 (bindings--define-key menu [separator-encryption-decryption]
1516 (bindings--define-key menu [simple-calculator]
1517 '(menu-item "Simple Calculator" calculator
1518 :help "Invoke the Emacs built-in quick calculator"))
1519 (bindings--define-key menu [calc]
1520 '(menu-item "Programmable Calculator" calc
1521 :help "Invoke the Emacs built-in full scientific calculator"))
1522 (bindings--define-key menu [calendar]
1523 '(menu-item "Calendar" calendar
1524 :help "Invoke the Emacs built-in calendar"))
1526 (bindings--define-key menu [separator-net]
1529 (bindings--define-key menu [browse-web]
1530 '(menu-item "Browse the Web..." browse-web))
1531 (bindings--define-key menu [directory-search]
1532 '(menu-item "Directory Search" eudc-tools-menu))
1533 (bindings--define-key menu [compose-mail]
1534 '(menu-item "Compose New Mail" compose-mail
1535 :visible (and mail-user-agent (not (eq mail-user-agent 'ignore)))
1536 :help "Start writing a new mail message"))
1537 (bindings--define-key menu [rmail]
1538 '(menu-item "Read Mail" menu-bar-read-mail
1539 :visible (and read-mail-command
1540 (not (eq read-mail-command 'ignore)))
1541 :help "Read your mail"))
1543 (bindings--define-key menu [gnus]
1544 '(menu-item "Read Net News" gnus
1545 :help "Read network news groups"))
1547 (bindings--define-key menu [separator-vc]
1550 (bindings--define-key menu [vc] nil) ;Create the place for the VC menu.
1552 (bindings--define-key menu [separator-compare]
1555 (bindings--define-key menu [epatch]
1556 '(menu-item "Apply Patch" menu-bar-epatch-menu))
1557 (bindings--define-key menu [ediff-merge]
1558 '(menu-item "Merge" menu-bar-ediff-merge-menu))
1559 (bindings--define-key menu [compare]
1560 '(menu-item "Compare (Ediff)" menu-bar-ediff-menu))
1562 (bindings--define-key menu [separator-spell]
1565 (bindings--define-key menu [spell]
1566 '(menu-item "Spell Checking" ispell-menu-map))
1568 (bindings--define-key menu [separator-prog]
1571 (bindings--define-key menu [semantic]
1572 '(menu-item "Source Code Parsers (Semantic)"
1574 :help "Toggle automatic parsing in source code buffers (Semantic mode)"
1575 :button (:toggle . (bound-and-true-p semantic-mode))))
1577 (bindings--define-key menu [ede]
1578 '(menu-item "Project Support (EDE)"
1580 :help "Toggle the Emacs Development Environment (Global EDE mode)"
1581 :button (:toggle . (bound-and-true-p global-ede-mode))))
1583 (bindings--define-key menu [gdb]
1584 '(menu-item "Debugger (GDB)..." gdb
1585 :help "Debug a program from within Emacs with GDB"))
1586 (bindings--define-key menu [shell-on-region]
1587 '(menu-item "Shell Command on Region..." shell-command-on-region
1589 :help "Pass marked region to a shell command"))
1590 (bindings--define-key menu [shell]
1591 '(menu-item "Shell Command..." shell-command
1592 :help "Invoke a shell command and catch its output"))
1593 (bindings--define-key menu [compile]
1594 '(menu-item "Compile..." compile
1595 :help "Invoke compiler or Make, view compilation errors"))
1596 (bindings--define-key menu [grep]
1597 '(menu-item "Search Files (Grep)..." grep
1598 :help "Search files for strings or regexps (with Grep)"))
1601 ;; The "Help" menu items
1603 (defvar menu-bar-describe-menu
1604 (let ((menu (make-sparse-keymap "Describe")))
1606 (bindings--define-key menu [mule-diag]
1607 '(menu-item "Show All of Mule Status" mule-diag
1608 :visible (default-value 'enable-multibyte-characters)
1609 :help "Display multilingual environment settings"))
1610 (bindings--define-key menu [describe-coding-system-briefly]
1611 '(menu-item "Describe Coding System (Briefly)"
1612 describe-current-coding-system-briefly
1613 :visible (default-value 'enable-multibyte-characters)))
1614 (bindings--define-key menu [describe-coding-system]
1615 '(menu-item "Describe Coding System..." describe-coding-system
1616 :visible (default-value 'enable-multibyte-characters)))
1617 (bindings--define-key menu [describe-input-method]
1618 '(menu-item "Describe Input Method..." describe-input-method
1619 :visible (default-value 'enable-multibyte-characters)
1620 :help "Keyboard layout for specific input method"))
1621 (bindings--define-key menu [describe-language-environment]
1622 `(menu-item "Describe Language Environment"
1623 ,describe-language-environment-map))
1625 (bindings--define-key menu [separator-desc-mule]
1628 (bindings--define-key menu [list-keybindings]
1629 '(menu-item "List Key Bindings" describe-bindings
1630 :help "Display all current key bindings (keyboard shortcuts)"))
1631 (bindings--define-key menu [describe-current-display-table]
1632 '(menu-item "Describe Display Table" describe-current-display-table
1633 :help "Describe the current display table"))
1634 (bindings--define-key menu [describe-package]
1635 '(menu-item "Describe Package..." describe-package
1636 :help "Display documentation of a Lisp package"))
1637 (bindings--define-key menu [describe-face]
1638 '(menu-item "Describe Face..." describe-face
1639 :help "Display the properties of a face"))
1640 (bindings--define-key menu [describe-variable]
1641 '(menu-item "Describe Variable..." describe-variable
1642 :help "Display documentation of variable/option"))
1643 (bindings--define-key menu [describe-function]
1644 '(menu-item "Describe Function..." describe-function
1645 :help "Display documentation of function/command"))
1646 (bindings--define-key menu [describe-key-1]
1647 '(menu-item "Describe Key or Mouse Operation..." describe-key
1648 ;; Users typically don't identify keys and menu items...
1649 :help "Display documentation of command bound to a \
1650 key, a click, or a menu-item"))
1651 (bindings--define-key menu [describe-mode]
1652 '(menu-item "Describe Buffer Modes" describe-mode
1653 :help "Describe this buffer's major and minor mode"))
1656 (defun menu-bar-read-lispref ()
1657 "Display the Emacs Lisp Reference manual in Info mode."
1661 (defun menu-bar-read-lispintro ()
1662 "Display the Introduction to Emacs Lisp Programming in Info mode."
1666 (defun search-emacs-glossary ()
1667 "Display the Glossary node of the Emacs manual in Info mode."
1669 (info "(emacs)Glossary"))
1671 (defun emacs-index-search (topic)
1672 "Look up TOPIC in the indices of the Emacs User Manual."
1673 (interactive "sSubject to look up: ")
1677 (defun elisp-index-search (topic)
1678 "Look up TOPIC in the indices of the Emacs Lisp Reference Manual."
1679 (interactive "sSubject to look up: ")
1683 (defvar menu-bar-search-documentation-menu
1684 (let ((menu (make-sparse-keymap "Search Documentation")))
1686 (bindings--define-key menu [search-documentation-strings]
1687 '(menu-item "Search Documentation Strings..." apropos-documentation
1689 "Find functions and variables whose doc strings match a regexp"))
1690 (bindings--define-key menu [find-any-object-by-name]
1691 '(menu-item "Find Any Object by Name..." apropos
1692 :help "Find symbols of any kind whose names match a regexp"))
1693 (bindings--define-key menu [find-option-by-value]
1694 '(menu-item "Find Options by Value..." apropos-value
1695 :help "Find variables whose values match a regexp"))
1696 (bindings--define-key menu [find-options-by-name]
1697 '(menu-item "Find Options by Name..." apropos-user-option
1698 :help "Find user options whose names match a regexp"))
1699 (bindings--define-key menu [find-commands-by-name]
1700 '(menu-item "Find Commands by Name..." apropos-command
1701 :help "Find commands whose names match a regexp"))
1702 (bindings--define-key menu [sep1]
1704 (bindings--define-key menu [lookup-command-in-manual]
1705 '(menu-item "Look Up Command in User Manual..." Info-goto-emacs-command-node
1706 :help "Display manual section that describes a command"))
1707 (bindings--define-key menu [lookup-key-in-manual]
1708 '(menu-item "Look Up Key in User Manual..." Info-goto-emacs-key-command-node
1709 :help "Display manual section that describes a key"))
1710 (bindings--define-key menu [lookup-subject-in-elisp-manual]
1711 '(menu-item "Look Up Subject in ELisp Manual..." elisp-index-search
1712 :help "Find description of a subject in Emacs Lisp manual"))
1713 (bindings--define-key menu [lookup-subject-in-emacs-manual]
1714 '(menu-item "Look Up Subject in User Manual..." emacs-index-search
1715 :help "Find description of a subject in Emacs User manual"))
1716 (bindings--define-key menu [emacs-terminology]
1717 '(menu-item "Emacs Terminology" search-emacs-glossary
1718 :help "Display the Glossary section of the Emacs manual"))
1721 (defvar menu-bar-manuals-menu
1722 (let ((menu (make-sparse-keymap "More Manuals")))
1724 (bindings--define-key menu [man]
1725 '(menu-item "Read Man Page..." manual-entry
1726 :help "Man-page docs for external commands and libraries"))
1727 (bindings--define-key menu [sep2]
1729 (bindings--define-key menu [order-emacs-manuals]
1730 '(menu-item "Ordering Manuals" view-order-manuals
1731 :help "How to order manuals from the Free Software Foundation"))
1732 (bindings--define-key menu [lookup-subject-in-all-manuals]
1733 '(menu-item "Lookup Subject in all Manuals..." info-apropos
1734 :help "Find description of a subject in all installed manuals"))
1735 (bindings--define-key menu [other-manuals]
1736 '(menu-item "All Other Manuals (Info)" Info-directory
1737 :help "Read any of the installed manuals"))
1738 (bindings--define-key menu [emacs-lisp-reference]
1739 '(menu-item "Emacs Lisp Reference" menu-bar-read-lispref
1740 :help "Read the Emacs Lisp Reference manual"))
1741 (bindings--define-key menu [emacs-lisp-intro]
1742 '(menu-item "Introduction to Emacs Lisp" menu-bar-read-lispintro
1743 :help "Read the Introduction to Emacs Lisp Programming"))
1746 (defun help-with-tutorial-spec-language ()
1747 "Use the Emacs tutorial, specifying which language you want."
1749 (help-with-tutorial t))
1751 (defvar menu-bar-help-menu
1752 (let ((menu (make-sparse-keymap "Help")))
1753 (bindings--define-key menu [about-gnu-project]
1754 '(menu-item "About GNU" describe-gnu-project
1755 :help "About the GNU System, GNU Project, and GNU/Linux"))
1756 (bindings--define-key menu [about-emacs]
1757 '(menu-item "About Emacs" about-emacs
1758 :help "Display version number, copyright info, and basic help"))
1759 (bindings--define-key menu [sep4]
1761 (bindings--define-key menu [describe-no-warranty]
1762 '(menu-item "(Non)Warranty" describe-no-warranty
1763 :help "Explain that Emacs has NO WARRANTY"))
1764 (bindings--define-key menu [describe-copying]
1765 '(menu-item "Copying Conditions" describe-copying
1766 :help "Show the Emacs license (GPL)"))
1767 (bindings--define-key menu [getting-new-versions]
1768 '(menu-item "Getting New Versions" describe-distribution
1769 :help "How to get the latest version of Emacs"))
1770 (bindings--define-key menu [sep2]
1772 (bindings--define-key menu [external-packages]
1773 '(menu-item "Finding Extra Packages" view-external-packages
1774 :help "How to get more Lisp packages for use in Emacs"))
1775 (bindings--define-key menu [find-emacs-packages]
1776 '(menu-item "Search Built-in Packages" finder-by-keyword
1777 :help "Find built-in packages and features by keyword"))
1778 (bindings--define-key menu [more-manuals]
1779 `(menu-item "More Manuals" ,menu-bar-manuals-menu))
1780 (bindings--define-key menu [emacs-manual]
1781 '(menu-item "Read the Emacs Manual" info-emacs-manual
1782 :help "Full documentation of Emacs features"))
1783 (bindings--define-key menu [describe]
1784 `(menu-item "Describe" ,menu-bar-describe-menu))
1785 (bindings--define-key menu [search-documentation]
1786 `(menu-item "Search Documentation" ,menu-bar-search-documentation-menu))
1787 (bindings--define-key menu [sep1]
1789 (bindings--define-key menu [emacs-psychotherapist]
1790 '(menu-item "Emacs Psychotherapist" doctor
1791 :help "Our doctor will help you feel better"))
1792 (bindings--define-key menu [send-emacs-bug-report]
1793 '(menu-item "Send Bug Report..." report-emacs-bug
1794 :help "Send e-mail to Emacs maintainers"))
1795 (bindings--define-key menu [emacs-manual-bug]
1796 '(menu-item "How to Report a Bug" info-emacs-bug
1797 :help "Read about how to report an Emacs bug"))
1798 (bindings--define-key menu [emacs-known-problems]
1799 '(menu-item "Emacs Known Problems" view-emacs-problems
1800 :help "Read about known problems with Emacs"))
1801 (bindings--define-key menu [emacs-news]
1802 '(menu-item "Emacs News" view-emacs-news
1803 :help "New features of this version"))
1804 (bindings--define-key menu [emacs-faq]
1805 '(menu-item "Emacs FAQ" view-emacs-FAQ
1806 :help "Frequently asked (and answered) questions about Emacs"))
1808 (bindings--define-key menu [emacs-tutorial-language-specific]
1809 '(menu-item "Emacs Tutorial (choose language)..."
1810 help-with-tutorial-spec-language
1811 :help "Learn how to use Emacs (choose a language)"))
1812 (bindings--define-key menu [emacs-tutorial]
1813 '(menu-item "Emacs Tutorial" help-with-tutorial
1814 :help "Learn how to use Emacs"))
1816 ;; In OS X it's in the app menu already.
1817 ;; FIXME? There already is an "About Emacs" (sans ...) entry in the Help menu.
1819 (not (eq system-type 'darwin))
1820 (bindings--define-key menu [info-panel]
1821 '(menu-item "About Emacs..." ns-do-emacs-info-panel)))
1824 (bindings--define-key global-map [menu-bar tools]
1825 (cons "Tools" menu-bar-tools-menu))
1826 (bindings--define-key global-map [menu-bar buffer]
1827 (cons "Buffers" global-buffers-menu-map))
1828 (bindings--define-key global-map [menu-bar options]
1829 (cons "Options" menu-bar-options-menu))
1830 (bindings--define-key global-map [menu-bar edit]
1831 (cons "Edit" menu-bar-edit-menu))
1832 (bindings--define-key global-map [menu-bar file]
1833 (cons "File" menu-bar-file-menu))
1834 (bindings--define-key global-map [menu-bar help-menu]
1835 (cons (purecopy "Help") menu-bar-help-menu))
1837 (defun menu-bar-menu-frame-live-and-visible-p ()
1838 "Return non-nil if the menu frame is alive and visible.
1839 The menu frame is the frame for which we are updating the menu."
1840 (let ((menu-frame (or menu-updating-frame (selected-frame))))
1841 (and (frame-live-p menu-frame)
1842 (frame-visible-p menu-frame))))
1844 (defun menu-bar-non-minibuffer-window-p ()
1845 "Return non-nil if the menu frame's selected window is no minibuffer window.
1846 Return nil if the menu frame is dead or its selected window is a
1847 minibuffer window. The menu frame is the frame for which we are
1849 (let ((menu-frame (or menu-updating-frame (selected-frame))))
1850 (and (frame-live-p menu-frame)
1851 (not (window-minibuffer-p
1852 (frame-selected-window menu-frame))))))
1854 (defun kill-this-buffer () ; for the menu bar
1855 "Kill the current buffer.
1856 When called in the minibuffer, get out of the minibuffer
1857 using `abort-recursive-edit'."
1860 ;; Don't do anything when `menu-frame' is not alive or visible
1862 ((not (menu-bar-menu-frame-live-and-visible-p)))
1863 ((menu-bar-non-minibuffer-window-p)
1864 (kill-buffer (current-buffer)))
1866 (abort-recursive-edit))))
1868 (defun kill-this-buffer-enabled-p ()
1869 "Return non-nil if the `kill-this-buffer' menu item should be enabled."
1870 (or (not (menu-bar-non-minibuffer-window-p))
1872 ;; Instead of looping over entire buffer list, stop once we've
1873 ;; found two "killable" buffers (Bug#8184).
1875 (dolist (buffer (buffer-list))
1876 (unless (string-match-p "^ " (buffer-name buffer))
1879 (throw 'found-2 t))))))))
1881 (put 'dired 'menu-enable '(menu-bar-non-minibuffer-window-p))
1883 ;; Permit deleting frame if it would leave a visible or iconified frame.
1884 (defun delete-frame-enabled-p ()
1885 "Return non-nil if `delete-frame' should be enabled in the menu bar."
1886 (let ((frames (frame-list))
1889 (if (frame-visible-p (car frames))
1890 (setq count (1+ count)))
1891 (setq frames (cdr frames)))
1894 (defcustom yank-menu-length 20
1895 "Maximum length to display in the yank-menu."
1899 (defun menu-bar-update-yank-menu (string old)
1900 (let ((front (car (cdr yank-menu)))
1901 (menu-string (if (<= (length string) yank-menu-length)
1904 (substring string 0 (/ yank-menu-length 2))
1906 (substring string (- (/ yank-menu-length 2)))))))
1907 ;; Don't let the menu string be all dashes
1908 ;; because that has a special meaning in a menu.
1909 (if (string-match "\\`-+\\'" menu-string)
1910 (setq menu-string (concat menu-string " ")))
1911 ;; If we're supposed to be extending an existing string, and that
1912 ;; string really is at the front of the menu, then update it in place.
1913 (if (and old (or (eq old (car front))
1914 (string= old (car front))))
1916 (setcar front string)
1917 (setcar (cdr front) menu-string))
1920 (cons string (cons menu-string 'menu-bar-select-yank))
1922 (if (> (length (cdr yank-menu)) kill-ring-max)
1923 (setcdr (nthcdr kill-ring-max yank-menu) nil)))
1925 (put 'menu-bar-select-yank 'apropos-inhibit t)
1926 (defun menu-bar-select-yank ()
1927 "Insert the stretch of previously-killed text selected from menu.
1928 The menu shows all the killed text sequences stored in `kill-ring'."
1931 (insert last-command-event))
1936 (defcustom buffers-menu-max-size 10
1937 "Maximum number of entries which may appear on the Buffers menu.
1938 If this is 10, then only the ten most-recently-selected buffers are shown.
1939 If this is nil, then all buffers are shown.
1940 A large number or nil slows down menu responsiveness."
1941 :type '(choice integer
1942 (const :tag "All" nil))
1945 (defcustom buffers-menu-buffer-name-length 30
1946 "Maximum length of the buffer name on the Buffers menu.
1947 If this is a number, then buffer names are truncated to this length.
1948 If this is nil, then buffer names are shown in full.
1949 A large number or nil makes the menu too wide."
1950 :type '(choice integer
1951 (const :tag "Full length" nil))
1954 (defcustom buffers-menu-show-directories 'unless-uniquify
1955 "If non-nil, show directories in the Buffers menu for buffers that have them.
1956 The special value `unless-uniquify' means that directories will be shown
1957 unless `uniquify-buffer-name-style' is non-nil (in which case, buffer
1958 names should include enough of a buffer's directory to distinguish it
1959 from other buffers).
1961 Setting this variable directly does not take effect until next time the
1962 Buffers menu is regenerated."
1963 :set (lambda (symbol value)
1965 (menu-bar-update-buffers t))
1966 :initialize 'custom-initialize-default
1967 :type '(choice (const :tag "Never" nil)
1968 (const :tag "Unless uniquify is enabled" unless-uniquify)
1969 (const :tag "Always" t))
1972 (defcustom buffers-menu-show-status t
1973 "If non-nil, show modified/read-only status of buffers in the Buffers menu.
1974 Setting this variable directly does not take effect until next time the
1975 Buffers menu is regenerated."
1976 :set (lambda (symbol value)
1978 (menu-bar-update-buffers t))
1979 :initialize 'custom-initialize-default
1983 (defvar list-buffers-directory nil
1984 "String to display in buffer listings for buffers not visiting a file.")
1985 (make-variable-buffer-local 'list-buffers-directory)
1987 (defun menu-bar-select-buffer ()
1989 (switch-to-buffer last-command-event))
1991 (defun menu-bar-select-frame (frame)
1992 (make-frame-visible frame)
1994 (select-frame frame))
1996 (defun menu-bar-update-buffers-1 (elt)
1997 (let* ((buf (car elt))
1999 (and (if (eq buffers-menu-show-directories 'unless-uniquify)
2000 (or (not (boundp 'uniquify-buffer-name-style))
2001 (null uniquify-buffer-name-style))
2002 buffers-menu-show-directories)
2003 (or (buffer-file-name buf)
2004 (buffer-local-value 'list-buffers-directory buf)))))
2006 (setq file (file-name-directory file)))
2007 (when (and file (> (length file) 20))
2008 (setq file (concat "..." (substring file -17))))
2009 (cons (if buffers-menu-show-status
2010 (let ((mod (if (buffer-modified-p buf) "*" ""))
2011 (ro (if (buffer-local-value 'buffer-read-only buf) "%" "")))
2013 (format "%s %s%s -- %s" (cdr elt) mod ro file)
2014 (format "%s %s%s" (cdr elt) mod ro)))
2016 (format "%s -- %s" (cdr elt) file)
2020 ;; Used to cache the menu entries for commands in the Buffers menu
2021 (defvar menu-bar-buffers-menu-command-entries nil)
2023 (defvar menu-bar-select-buffer-function 'switch-to-buffer
2024 "Function to select the buffer chosen from the `Buffers' menu-bar menu.
2025 It must accept a buffer as its only required argument.")
2027 (defun menu-bar-buffer-vector (alist)
2028 ;; turn ((name . buffer) ...) into a menu
2029 (let ((buffers-vec (make-vector (length alist) nil))
2031 (dolist (pair alist)
2037 (funcall menu-bar-select-buffer-function ,(cdr pair))))))
2040 (defun menu-bar-update-buffers (&optional force)
2041 ;; If user discards the Buffers item, play along.
2042 (and (lookup-key (current-global-map) [menu-bar buffer])
2043 (or force (frame-or-buffer-changed-p))
2044 (let ((buffers (buffer-list))
2045 (frames (frame-list))
2048 ;; Make the menu of buffers proper.
2051 (limit (if (and (integerp buffers-menu-max-size)
2052 (> buffers-menu-max-size 1))
2053 buffers-menu-max-size most-positive-fixnum))
2055 ;; Put into each element of buffer-list
2056 ;; the name for actual display,
2057 ;; perhaps truncated in the middle.
2059 (let* ((buf (pop buffers))
2060 (name (buffer-name buf)))
2061 (unless (eq ?\s (aref name 0))
2062 (push (menu-bar-update-buffers-1
2064 (if (and (integerp buffers-menu-buffer-name-length)
2065 (> (length name) buffers-menu-buffer-name-length))
2068 name 0 (/ buffers-menu-buffer-name-length 2))
2071 name (- (/ buffers-menu-buffer-name-length 2))))
2075 ;; If requested, list only the N most recently
2076 ;; selected buffers.
2077 (when (= limit (setq i (1+ i)))
2078 (setq buffers nil)))))
2079 (list (menu-bar-buffer-vector alist))))
2081 ;; Make a Frames menu if we have more than one frame.
2083 (let* ((frames-vec (make-vector (length frames) nil))
2086 (list "Select Frame" frames-vec)))
2088 (dolist (frame frames)
2091 (frame-parameter frame 'name)
2093 (interactive) (menu-bar-select-frame ,frame))))
2095 ;; Put it after the normal buffers
2098 `((frames-separator "--")
2099 (frames menu-item "Frames" ,frames-menu))))))
2101 ;; Add in some normal commands at the end of the menu. We use
2102 ;; the copy cached in `menu-bar-buffers-menu-command-entries'
2103 ;; if it's been set already. Note that we can't use constant
2104 ;; lists for the menu-entries, because the low-level menu-code
2106 (unless menu-bar-buffers-menu-command-entries
2107 (setq menu-bar-buffers-menu-command-entries
2108 (list '(command-separator "--")
2113 :help "Switch to the \"next\" buffer in a cyclic order")
2114 (list 'previous-buffer
2118 :help "Switch to the \"previous\" buffer in a cyclic order")
2119 (list 'select-named-buffer
2121 "Select Named Buffer..."
2123 :help "Prompt for a buffer name, and select that buffer in the current window")
2124 (list 'list-all-buffers
2128 :help "Pop up a window listing all Emacs buffers"
2131 (nconc buffers-menu menu-bar-buffers-menu-command-entries))
2133 ;; We used to "(define-key (current-global-map) [menu-bar buffer]"
2134 ;; but that did not do the right thing when the [menu-bar buffer]
2135 ;; entry above had been moved (e.g. to a parent keymap).
2136 (setcdr global-buffers-menu-map (cons "Buffers" buffers-menu)))))
2138 (add-hook 'menu-bar-update-hook 'menu-bar-update-buffers)
2140 (menu-bar-update-buffers)
2142 ;; this version is too slow
2143 ;;(defun format-buffers-menu-line (buffer)
2144 ;; "Returns a string to represent the given buffer in the Buffer menu.
2145 ;;nil means the buffer shouldn't be listed. You can redefine this."
2146 ;; (if (string-match "\\` " (buffer-name buffer))
2148 ;; (with-current-buffer buffer
2149 ;; (let ((size (buffer-size)))
2150 ;; (format "%s%s %-19s %6s %-15s %s"
2151 ;; (if (buffer-modified-p) "*" " ")
2152 ;; (if buffer-read-only "%" " ")
2156 ;; (or (buffer-file-name) ""))))))
2158 ;;; Set up a menu bar menu for the minibuffer.
2160 (dolist (map (list minibuffer-local-map
2161 ;; This shouldn't be necessary, but there's a funny
2162 ;; bug in keymap.c that I don't understand yet. -stef
2163 minibuffer-local-completion-map))
2164 (bindings--define-key map [menu-bar minibuf]
2165 (cons "Minibuf" (make-sparse-keymap "Minibuf"))))
2167 (let ((map minibuffer-local-completion-map))
2168 (bindings--define-key map [menu-bar minibuf ?\?]
2169 '(menu-item "List Completions" minibuffer-completion-help
2170 :help "Display all possible completions"))
2171 (bindings--define-key map [menu-bar minibuf space]
2172 '(menu-item "Complete Word" minibuffer-complete-word
2173 :help "Complete at most one word"))
2174 (bindings--define-key map [menu-bar minibuf tab]
2175 '(menu-item "Complete" minibuffer-complete
2176 :help "Complete as far as possible")))
2178 (let ((map minibuffer-local-map))
2179 (bindings--define-key map [menu-bar minibuf quit]
2180 '(menu-item "Quit" abort-recursive-edit
2181 :help "Abort input and exit minibuffer"))
2182 (bindings--define-key map [menu-bar minibuf return]
2183 '(menu-item "Enter" exit-minibuffer
2185 :help "Terminate input and exit minibuffer"))
2186 (bindings--define-key map [menu-bar minibuf isearch-forward]
2187 '(menu-item "Isearch History Forward" isearch-forward
2188 :help "Incrementally search minibuffer history forward"))
2189 (bindings--define-key map [menu-bar minibuf isearch-backward]
2190 '(menu-item "Isearch History Backward" isearch-backward
2191 :help "Incrementally search minibuffer history backward"))
2192 (bindings--define-key map [menu-bar minibuf next]
2193 '(menu-item "Next History Item" next-history-element
2194 :help "Put next minibuffer history element in the minibuffer"))
2195 (bindings--define-key map [menu-bar minibuf previous]
2196 '(menu-item "Previous History Item" previous-history-element
2197 :help "Put previous minibuffer history element in the minibuffer")))
2199 (define-minor-mode menu-bar-mode
2200 "Toggle display of a menu bar on each frame (Menu Bar mode).
2201 With a prefix argument ARG, enable Menu Bar mode if ARG is
2202 positive, and disable it otherwise. If called from Lisp, enable
2203 Menu Bar mode if ARG is omitted or nil.
2205 This command applies to all frames that exist and frames to be
2206 created in the future."
2209 ;; It's defined in C/cus-start, this stops the d-m-m macro defining it again.
2210 :variable menu-bar-mode
2212 ;; Turn the menu-bars on all frames on or off.
2213 (let ((val (if menu-bar-mode 1 0)))
2214 (dolist (frame (frame-list))
2215 (set-frame-parameter frame 'menu-bar-lines val))
2216 ;; If the user has given `default-frame-alist' a `menu-bar-lines'
2217 ;; parameter, replace it.
2218 (if (assq 'menu-bar-lines default-frame-alist)
2219 (setq default-frame-alist
2220 (cons (cons 'menu-bar-lines val)
2221 (assq-delete-all 'menu-bar-lines
2222 default-frame-alist)))))
2223 ;; Make the message appear when Emacs is idle. We can not call message
2224 ;; directly. The minor-mode message "Menu-bar mode disabled" comes
2225 ;; after this function returns, overwriting any message we do here.
2226 (when (and (called-interactively-p 'interactive) (not menu-bar-mode))
2227 (run-with-idle-timer 0 nil 'message
2228 "Menu-bar mode disabled. Use M-x menu-bar-mode to make the menu bar appear.")))
2231 ;; (This does not work right unless it comes after the above definition.)
2232 ;; This comment is taken from tool-bar.el near
2233 ;; (put 'tool-bar-mode ...)
2234 ;; We want to pretend the menu bar by standard is on, as this will make
2235 ;; customize consider disabling the menu bar a customization, and save
2236 ;; that. We could do this for real by setting :init-value above, but
2237 ;; that would overwrite disabling the menu bar from X resources.
2238 (put 'menu-bar-mode 'standard-value '(t))
2240 (defun toggle-menu-bar-mode-from-frame (&optional arg)
2241 "Toggle menu bar on or off, based on the status of the current frame.
2242 See `menu-bar-mode' for more information."
2243 (interactive (list (or current-prefix-arg 'toggle)))
2244 (if (eq arg 'toggle)
2246 (if (menu-bar-positive-p
2247 (frame-parameter (menu-bar-frame-for-menubar) 'menu-bar-lines))
2249 (menu-bar-mode arg)))
2251 (declare-function x-menu-bar-open "term/x-win" (&optional frame))
2252 (declare-function w32-menu-bar-open "term/w32-win" (&optional frame))
2254 (defun lookup-key-ignore-too-long (map key)
2255 "Call `lookup-key' and convert numeric values to nil."
2256 (let ((binding (lookup-key map key)))
2257 (if (numberp binding) ; `too long'
2261 (defun popup-menu (menu &optional position prefix from-menu-bar)
2262 "Popup the given menu and call the selected option.
2263 MENU can be a keymap, an easymenu-style menu or a list of keymaps as for
2265 The menu is shown at the place where POSITION specifies. About
2266 the form of POSITION, see `popup-menu-normalize-position'.
2267 PREFIX is the prefix argument (if any) to pass to the command.
2268 FROM-MENU-BAR, if non-nil, means we are dropping one of menu-bar's menus."
2270 ((keymapp menu) menu)
2271 ((and (listp menu) (keymapp (car menu))) menu)
2272 (t (let* ((map (easy-menu-create-menu (car menu) (cdr menu)))
2273 (filter (when (symbolp map)
2274 (plist-get (get map 'menu-prop) :filter))))
2275 (if filter (funcall filter (symbol-function map)) map)))))
2276 (frame (selected-frame))
2279 (let* ((xy (posn-x-y position))
2280 (menu-symbol (menu-bar-menu-at-x-y (car xy) (cdr xy))))
2281 (setq position (list menu-symbol (list frame '(menu-bar)
2283 (setq position (popup-menu-normalize-position position)))
2284 ;; The looping behavior was taken from lmenu's popup-menu-popup
2285 (while (and map (setq event
2286 ;; map could be a prefix key, in which case
2287 ;; we need to get its function cell
2289 (x-popup-menu position (indirect-function map))))
2290 ;; Strangely x-popup-menu returns a list.
2291 ;; mouse-major-mode-menu was using a weird:
2292 ;; (key-binding (apply 'vector (append '(menu-bar) menu-prefix events)))
2297 (numberp (car event))
2298 (numberp (cdr event)))
2299 (let ((x (car event))
2302 (setq menu-symbol (menu-bar-menu-at-x-y x y))
2303 (setq position (list menu-symbol (list frame '(menu-bar)
2306 (key-binding (vector 'menu-bar menu-symbol)))))
2307 ((and (not (keymapp map)) (listp map))
2308 ;; We were given a list of keymaps. Search them all
2309 ;; in sequence until a first binding is found.
2310 (let ((mouse-click (apply 'vector event))
2312 (while (and map (null binding))
2313 (setq binding (lookup-key-ignore-too-long (car map) mouse-click))
2314 (setq map (cdr map)))
2317 ;; We were given a single keymap.
2318 (lookup-key map (apply 'vector event)))))
2319 ;; Clear out echoing, which perhaps shows a prefix arg.
2321 ;; Maybe try again but with the submap.
2322 (setq map (if (keymapp cmd) cmd)))
2323 ;; If the user did not cancel by refusing to select,
2324 ;; and if the result is a command, run it.
2325 (when (and (null map) (commandp cmd))
2326 (setq prefix-arg prefix)
2327 ;; `setup-specified-language-environment', for instance,
2328 ;; expects this to be set from a menu keymap.
2329 (setq last-command-event (car (last event)))
2330 ;; mouse-major-mode-menu was using `command-execute' instead.
2331 (call-interactively cmd))))
2333 (defun popup-menu-normalize-position (position)
2334 "Convert the POSITION to the form which `popup-menu' expects internally.
2335 POSITION can an event, a posn- value, a value having
2336 form ((XOFFSET YOFFSET) WINDOW), or nil.
2337 If nil, the current mouse position is used."
2339 ;; nil -> mouse cursor position
2341 (let ((mp (mouse-pixel-position)))
2342 (list (list (cadr mp) (cddr mp)) (car mp))))
2343 ;; Value returned from `event-end' or `posn-at-point'.
2345 (let ((xy (posn-x-y position)))
2346 (list (list (car xy) (cdr xy))
2347 (posn-window position))))
2350 (popup-menu-normalize-position (event-end position)))
2353 (defcustom tty-menu-open-use-tmm nil
2354 "If non-nil, \\[menu-bar-open] on a TTY will invoke `tmm-menubar'.
2356 If nil, \\[menu-bar-open] will drop down the menu corresponding to the
2357 first (leftmost) menu-bar item; you can select other items by typing
2358 \\[forward-char], \\[backward-char], \\[right-char] and \\[left-char]."
2359 :type '(choice (const :tag "F10 drops down TTY menus" nil)
2360 (const :tag "F10 invokes tmm-menubar" t))
2364 (defvar tty-menu--initial-menu-x 1
2365 "X coordinate of the first menu-bar menu dropped by F10.
2367 This is meant to be used only for debugging TTY menus.")
2369 (defun menu-bar-open (&optional frame)
2370 "Start key navigation of the menu bar in FRAME.
2372 This function decides which method to use to access the menu
2373 depending on FRAME's terminal device. On X displays, it calls
2374 `x-menu-bar-open'; on Windows, `w32-menu-bar-open'; otherwise it
2375 calls either `popup-menu' or `tmm-menubar' depending on whether
2376 `tty-menu-open-use-tmm' is nil or not.
2378 If FRAME is nil or not given, use the selected frame."
2380 (let ((type (framep (or frame (selected-frame)))))
2382 ((eq type 'x) (x-menu-bar-open frame))
2383 ((eq type 'w32) (w32-menu-bar-open frame))
2384 ((and (null tty-menu-open-use-tmm)
2385 (not (zerop (or (frame-parameter nil 'menu-bar-lines) 0))))
2386 ;; Make sure the menu bar is up to date. One situation where
2387 ;; this is important is when this function is invoked by name
2388 ;; via M-x, in which case the menu bar includes the "Minibuf"
2389 ;; menu item that should be removed when we exit the minibuffer.
2390 (force-mode-line-update)
2392 (let* ((x tty-menu--initial-menu-x)
2393 (menu (menu-bar-menu-at-x-y x 0 frame)))
2395 (lookup-key-ignore-too-long
2396 global-map (vector 'menu-bar menu))
2397 (lookup-key-ignore-too-long
2398 (current-local-map) (vector 'menu-bar menu))
2399 (cdar (minor-mode-key-binding (vector 'menu-bar menu)))
2400 (mouse-menu-bar-map))
2401 (posn-at-x-y x 0 nil t) nil t)))
2402 (t (with-selected-frame (or frame (selected-frame))
2405 (global-set-key [f10] 'menu-bar-open)
2407 (defun buffer-menu-open ()
2408 "Start key navigation of the buffer menu.
2409 This is the keyboard interface to \\[mouse-buffer-menu]."
2411 (popup-menu (mouse-buffer-menu-keymap)
2412 (posn-at-x-y 0 0 nil t)))
2414 (global-set-key [C-f10] 'buffer-menu-open)
2416 (defun mouse-buffer-menu-keymap ()
2417 (let* ((menu (mouse-buffer-menu-map))
2418 (km (make-sparse-keymap (pop menu))))
2419 (dolist (item (nreverse menu))
2420 (let* ((name (pop item)))
2421 (define-key km (vector (intern name))
2422 (list name 'keymap name
2423 (menu-bar-buffer-vector item)))))
2426 (defvar tty-menu-navigation-map
2427 (let ((map (make-sparse-keymap)))
2428 ;; The next line is disabled because it breaks interpretation of
2429 ;; escape sequences, produced by TTY arrow keys, as tty-menu-*
2430 ;; commands. Instead, we explicitly bind some keys to
2432 ;;(define-key map [t] 'tty-menu-exit)
2434 ;; The tty-menu-* are just symbols interpreted by term.c, they are
2435 ;; not real commands.
2436 (dolist (bind '((keyboard-quit . tty-menu-exit)
2437 (keyboard-escape-quit . tty-menu-exit)
2438 ;; The following two will need to be revised if we ever
2439 ;; support a right-to-left menu bar.
2440 (forward-char . tty-menu-next-menu)
2441 (backward-char . tty-menu-prev-menu)
2442 (right-char . tty-menu-next-menu)
2443 (left-char . tty-menu-prev-menu)
2444 (next-line . tty-menu-next-item)
2445 (previous-line . tty-menu-prev-item)
2446 (newline . tty-menu-select)
2447 (newline-and-indent . tty-menu-select)
2448 (menu-bar-open . tty-menu-exit)))
2449 (substitute-key-definition (car bind) (cdr bind)
2450 map (current-global-map)))
2452 ;; The bindings of menu-bar items are so that clicking on the menu
2453 ;; bar when a menu is already shown pops down that menu.
2454 (define-key map [menu-bar t] 'tty-menu-exit)
2456 (define-key map [?\C-r] 'tty-menu-select)
2457 (define-key map [?\C-j] 'tty-menu-select)
2458 (define-key map [return] 'tty-menu-select)
2459 (define-key map [linefeed] 'tty-menu-select)
2460 (define-key map [mouse-1] 'tty-menu-select)
2461 (define-key map [drag-mouse-1] 'tty-menu-select)
2462 (define-key map [mouse-2] 'tty-menu-select)
2463 (define-key map [drag-mouse-2] 'tty-menu-select)
2464 (define-key map [mouse-3] 'tty-menu-select)
2465 (define-key map [drag-mouse-3] 'tty-menu-select)
2466 (define-key map [wheel-down] 'tty-menu-next-item)
2467 (define-key map [wheel-up] 'tty-menu-prev-item)
2468 (define-key map [wheel-left] 'tty-menu-prev-menu)
2469 (define-key map [wheel-right] 'tty-menu-next-menu)
2470 ;; The following 4 bindings are for those whose text-mode mouse
2472 (define-key map [S-mouse-1] 'tty-menu-next-item)
2473 (define-key map [S-drag-mouse-1] 'tty-menu-next-item)
2474 (define-key map [S-mouse-2] 'tty-menu-prev-item)
2475 (define-key map [S-drag-mouse-2] 'tty-menu-prev-item)
2476 (define-key map [S-mouse-3] 'tty-menu-prev-item)
2477 (define-key map [S-drag-mouse-3] 'tty-menu-prev-item)
2478 (define-key map [header-line mouse-1] 'tty-menu-select)
2479 (define-key map [header-line drag-mouse-1] 'tty-menu-select)
2480 ;; The down-mouse events must be bound to tty-menu-ignore, so that
2481 ;; only releasing the mouse button pops up the menu.
2482 (define-key map [mode-line down-mouse-1] 'tty-menu-ignore)
2483 (define-key map [mode-line down-mouse-2] 'tty-menu-ignore)
2484 (define-key map [mode-line down-mouse-3] 'tty-menu-ignore)
2485 (define-key map [mode-line C-down-mouse-1] 'tty-menu-ignore)
2486 (define-key map [mode-line C-down-mouse-2] 'tty-menu-ignore)
2487 (define-key map [mode-line C-down-mouse-3] 'tty-menu-ignore)
2488 (define-key map [down-mouse-1] 'tty-menu-ignore)
2489 (define-key map [C-down-mouse-1] 'tty-menu-ignore)
2490 (define-key map [C-down-mouse-2] 'tty-menu-ignore)
2491 (define-key map [C-down-mouse-3] 'tty-menu-ignore)
2492 (define-key map [mouse-movement] 'tty-menu-mouse-movement)
2494 "Keymap used while processing TTY menus.")
2498 ;;; menu-bar.el ends here