1 ;;; menu-bar.el --- define a default menu bar
3 ;; Copyright (C) 1993, 1994, 1995, 2000, 2001, 2002, 2003, 2004,
4 ;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
8 ;; 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, or (at your option)
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; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25 ;; Boston, MA 02110-1301, USA.
27 ;; Avishai Yacobi suggested some menu rearrangements.
33 ;; Don't clobber an existing menu-bar keymap, to preserve any menu-bar key
34 ;; definitions made in loaddefs.el.
35 (or (lookup-key global-map
[menu-bar
])
36 (define-key global-map
[menu-bar
] (make-sparse-keymap "menu-bar")))
37 (defvar menu-bar-help-menu
(make-sparse-keymap "Help"))
39 ;; Force Help item to come last, after the major mode's own items.
40 ;; The symbol used to be called `help', but that gets confused with the
42 (setq menu-bar-final-items
'(help-menu))
44 (define-key global-map
[menu-bar help-menu
] (cons "Help" menu-bar-help-menu
))
45 (defvar menu-bar-tools-menu
(make-sparse-keymap "Tools"))
46 (define-key global-map
[menu-bar tools
] (cons "Tools" menu-bar-tools-menu
))
47 ;; This definition is just to show what this looks like.
48 ;; It gets modified in place when menu-bar-update-buffers is called.
49 (defvar global-buffers-menu-map
(make-sparse-keymap "Buffers"))
50 (define-key global-map
[menu-bar buffer
]
51 (cons "Buffers" global-buffers-menu-map
))
52 (defvar menu-bar-options-menu
(make-sparse-keymap "Options"))
53 (define-key global-map
[menu-bar options
]
54 (cons "Options" menu-bar-options-menu
))
55 (defvar menu-bar-edit-menu
(make-sparse-keymap "Edit"))
56 (define-key global-map
[menu-bar edit
] (cons "Edit" menu-bar-edit-menu
))
57 (defvar menu-bar-file-menu
(make-sparse-keymap "File"))
58 (define-key global-map
[menu-bar file
] (cons "File" menu-bar-file-menu
))
60 ;; This alias is for compatibility with 19.28 and before.
61 (defvar menu-bar-files-menu menu-bar-file-menu
)
63 ;; This is referenced by some code below; it is defined in uniquify.el
64 (defvar uniquify-buffer-name-style
)
67 ;; The "File" menu items
68 (define-key menu-bar-file-menu
[exit-emacs
]
69 '(menu-item "Exit Emacs" save-buffers-kill-emacs
70 :help
"Save unsaved buffers, then exit"))
72 (define-key menu-bar-file-menu
[separator-exit
]
75 ;; Don't use delete-frame as event name because that is a special
77 (define-key menu-bar-file-menu
[delete-this-frame
]
78 '(menu-item "Delete Frame" delete-frame
79 :visible
(fboundp 'delete-frame
)
80 :enable
(delete-frame-enabled-p)
81 :help
"Delete currently selected frame"))
82 (define-key menu-bar-file-menu
[make-frame-on-display
]
83 '(menu-item "New Frame on Display..." make-frame-on-display
84 :visible
(fboundp 'make-frame-on-display
)
85 :help
"Open a new frame on another display"))
86 (define-key menu-bar-file-menu
[make-frame
]
87 '(menu-item "New Frame" make-frame-command
88 :visible
(fboundp 'make-frame-command
)
89 :help
"Open a new frame"))
91 (define-key menu-bar-file-menu
[one-window
]
92 '(menu-item "Remove Splits" delete-other-windows
93 :enable
(not (one-window-p t nil
))
94 :help
"Selected window grows to fill the whole frame"))
96 (define-key menu-bar-file-menu
[split-window
]
97 '(menu-item "Split Window" split-window-vertically
98 :enable
(and (menu-bar-menu-frame-live-and-visible-p)
99 (menu-bar-non-minibuffer-window-p))
100 :help
"Split selected window in two windows"))
102 (define-key menu-bar-file-menu
[separator-window
]
105 (define-key menu-bar-file-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 (define-key menu-bar-file-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 (define-key menu-bar-file-menu
[ps-print-region-faces
]
114 '(menu-item "Postscript Print Region" ps-print-region-with-faces
116 :help
"Pretty-print marked region to PostScript printer"))
117 (define-key menu-bar-file-menu
[ps-print-buffer-faces
]
118 '(menu-item "Postscript Print Buffer" ps-print-buffer-with-faces
119 :enable
(menu-bar-menu-frame-live-and-visible-p)
120 :help
"Pretty-print current buffer to PostScript printer"))
121 (define-key menu-bar-file-menu
[print-region
]
122 '(menu-item "Print Region" print-region
124 :help
"Print region between mark and current position"))
125 (define-key menu-bar-file-menu
[print-buffer
]
126 '(menu-item "Print Buffer" print-buffer
127 :enable
(menu-bar-menu-frame-live-and-visible-p)
128 :help
"Print current buffer with page headings"))
130 (define-key menu-bar-file-menu
[separator-print
]
133 (define-key menu-bar-file-menu
[recover-session
]
134 '(menu-item "Recover Crashed Session" recover-session
135 :enable
(and auto-save-list-file-prefix
137 (file-name-directory auto-save-list-file-prefix
))
139 (file-name-directory auto-save-list-file-prefix
)
143 (file-name-nondirectory
144 auto-save-list-file-prefix
)))
146 :help
"Recover edits from a crashed session"))
147 (define-key menu-bar-file-menu
[revert-buffer
]
148 '(menu-item "Revert Buffer" revert-buffer
149 :enable
(or revert-buffer-function
150 revert-buffer-insert-file-contents-function
151 (and buffer-file-number
152 (or (buffer-modified-p)
153 (not (verify-visited-file-modtime
154 (current-buffer))))))
155 :help
"Re-read current buffer from its file"))
156 (define-key menu-bar-file-menu
[write-file
]
157 '(menu-item "Save As..." write-file
158 :enable
(and (menu-bar-menu-frame-live-and-visible-p)
159 (menu-bar-non-minibuffer-window-p))
160 :help
"Write current buffer to another file"))
161 (define-key menu-bar-file-menu
[save-buffer
]
162 '(menu-item "Save" save-buffer
163 :enable
(and (buffer-modified-p)
165 (menu-bar-non-minibuffer-window-p))
166 :help
"Save current buffer to its file"))
168 (define-key menu-bar-file-menu
[separator-save
]
171 (defun menu-find-file-existing ()
172 "Edit the existing file FILENAME."
174 (let* ((mustmatch (not (and (fboundp 'x-uses-old-gtk-dialog
)
175 (x-uses-old-gtk-dialog))))
176 (filename (car (find-file-read-args "Find file: " mustmatch
))))
178 (find-file-existing filename
)
179 (find-file filename
))))
182 (define-key menu-bar-file-menu
[kill-buffer
]
183 '(menu-item "Close" kill-this-buffer
184 :enable
(kill-this-buffer-enabled-p)
185 :help
"Discard (kill) current buffer"))
186 (define-key menu-bar-file-menu
[insert-file
]
187 '(menu-item "Insert File..." insert-file
188 :enable
(menu-bar-non-minibuffer-window-p)
189 :help
"Insert another file into current buffer"))
190 (define-key menu-bar-file-menu
[dired]
191 '(menu-item "Open Directory..." dired
192 :enable (menu-bar-non-minibuffer-window-p)
193 :help "Read a directory, to operate on its files"))
194 (define-key menu-bar-file-menu [open-file]
195 '(menu-item "Open File..." menu-find-file-existing
196 :enable (menu-bar-non-minibuffer-window-p)
197 :help "Read an existing file into an Emacs buffer"))
198 (define-key menu-bar-file-menu [new-file]
199 '(menu-item "Visit New File..." find-file
200 :enable (menu-bar-non-minibuffer-window-p)
201 :help "Specify a new file's name, to edit the file"))
204 ;; The "Edit" menu items
206 ;; The "Edit->Search" submenu
207 (defvar menu-bar-last-search-type nil
208 "Type of last non-incremental search command called from the menu.")
210 (defun nonincremental-repeat-search-forward ()
211 "Search forward for the previous search string or regexp."
214 ((and (eq menu-bar-last-search-type 'string)
216 (search-forward (car search-ring)))
217 ((and (eq menu-bar-last-search-type 'regexp)
219 (re-search-forward (car regexp-search-ring)))
221 (error "No previous search"))))
223 (defun nonincremental-repeat-search-backward ()
224 "Search backward for the previous search string or regexp."
227 ((and (eq menu-bar-last-search-type 'string)
229 (search-backward (car search-ring)))
230 ((and (eq menu-bar-last-search-type 'regexp)
232 (re-search-backward (car regexp-search-ring)))
234 (error "No previous search"))))
236 (defun nonincremental-search-forward (string)
237 "Read a string and search for it nonincrementally."
238 (interactive "sSearch for string: ")
239 (setq menu-bar-last-search-type 'string)
240 (if (equal string "")
241 (search-forward (car search-ring))
242 (isearch-update-ring string nil)
243 (search-forward string)))
245 (defun nonincremental-search-backward (string)
246 "Read a string and search backward for it nonincrementally."
247 (interactive "sSearch for string: ")
248 (setq menu-bar-last-search-type 'string)
249 (if (equal string "")
250 (search-backward (car search-ring))
251 (isearch-update-ring string nil)
252 (search-backward string)))
254 (defun nonincremental-re-search-forward (string)
255 "Read a regular expression and search for it nonincrementally."
256 (interactive "sSearch for regexp: ")
257 (setq menu-bar-last-search-type 'regexp)
258 (if (equal string "")
259 (re-search-forward (car regexp-search-ring))
260 (isearch-update-ring string t)
261 (re-search-forward string)))
263 (defun nonincremental-re-search-backward (string)
264 "Read a regular expression and search backward for it nonincrementally."
265 (interactive "sSearch for regexp: ")
266 (setq menu-bar-last-search-type 'regexp)
267 (if (equal string "")
268 (re-search-backward (car regexp-search-ring))
269 (isearch-update-ring string t)
270 (re-search-backward string)))
272 (defvar menu-bar-search-menu (make-sparse-keymap "Search"))
274 ;; The Edit->Search->Incremental Search menu
275 (defvar menu-bar-i-search-menu
276 (make-sparse-keymap "Incremental Search"))
278 (define-key menu-bar-i-search-menu [isearch-backward-regexp]
279 '(menu-item "Backward Regexp..." isearch-backward-regexp
280 :help "Search backwards for a regular expression as you type it"))
281 (define-key menu-bar-i-search-menu [isearch-forward-regexp]
282 '(menu-item "Forward Regexp..." isearch-forward-regexp
283 :help "Search forward for a regular expression as you type it"))
284 (define-key menu-bar-i-search-menu [isearch-backward]
285 '(menu-item "Backward String..." isearch-backward
286 :help "Search backwards for a string as you type it"))
287 (define-key menu-bar-i-search-menu [isearch-forward]
288 '(menu-item "Forward String..." isearch-forward
289 :help "Search forward for a string as you type it"))
292 (define-key menu-bar-search-menu [i-search]
293 (list 'menu-item "Incremental Search" menu-bar-i-search-menu))
294 (define-key menu-bar-search-menu [separator-tag-isearch]
297 (define-key menu-bar-search-menu [tags-continue]
298 '(menu-item "Continue Tags Search" tags-loop-continue
299 :help "Continue last tags search operation"))
300 (define-key menu-bar-search-menu [tags-srch]
301 '(menu-item "Search Tagged Files..." tags-search
302 :help "Search for a regexp in all tagged files"))
303 (define-key menu-bar-search-menu [separator-tag-search]
306 (define-key menu-bar-search-menu [repeat-search-back]
307 '(menu-item "Repeat Backwards" nonincremental-repeat-search-backward
308 :enable (or (and (eq menu-bar-last-search-type 'string)
310 (and (eq menu-bar-last-search-type 'regexp)
312 :help "Repeat last search backwards"))
313 (define-key menu-bar-search-menu [repeat-search-fwd]
314 '(menu-item "Repeat Forward" nonincremental-repeat-search-forward
315 :enable (or (and (eq menu-bar-last-search-type 'string)
317 (and (eq menu-bar-last-search-type 'regexp)
319 :help "Repeat last search forward"))
320 (define-key menu-bar-search-menu [separator-repeat-search]
323 (define-key menu-bar-search-menu [re-search-backward]
324 '(menu-item "Regexp Backwards..." nonincremental-re-search-backward
325 :help "Search backwards for a regular expression"))
326 (define-key menu-bar-search-menu [re-search-forward]
327 '(menu-item "Regexp Forward..." nonincremental-re-search-forward
328 :help "Search forward for a regular expression"))
330 (define-key menu-bar-search-menu [search-backward]
331 '(menu-item "String Backwards..." nonincremental-search-backward
332 :help "Search backwards for a string"))
333 (define-key menu-bar-search-menu [search-forward]
334 '(menu-item "String Forward..." nonincremental-search-forward
335 :help "Search forward for a string"))
337 ;; The Edit->Replace submenu
339 (defvar menu-bar-replace-menu (make-sparse-keymap "Replace"))
341 (define-key menu-bar-replace-menu [tags-repl-continue]
342 '(menu-item "Continue Replace" tags-loop-continue
343 :help "Continue last tags replace operation"))
344 (define-key menu-bar-replace-menu [tags-repl]
345 '(menu-item "Replace in Tagged Files..." tags-query-replace
346 :help "Interactively replace a regexp in all tagged files"))
347 (define-key menu-bar-replace-menu [separator-replace-tags]
350 (define-key menu-bar-replace-menu [query-replace-regexp]
351 '(menu-item "Replace Regexp..." query-replace-regexp
352 :enable (not buffer-read-only)
353 :help "Replace regular expression interactively, ask about each occurrence"))
354 (define-key menu-bar-replace-menu [query-replace]
355 '(menu-item "Replace String..." query-replace
356 :enable (not buffer-read-only)
357 :help "Replace string interactively, ask about each occurrence"))
359 ;;; Assemble the top-level Edit menu items.
360 (define-key menu-bar-edit-menu [props]
361 '(menu-item "Text Properties" facemenu-menu))
363 (define-key menu-bar-edit-menu [fill]
364 '(menu-item "Fill" fill-region
365 :enable (and mark-active (not buffer-read-only))
367 "Fill text in region to fit between left and right margin"))
369 (define-key menu-bar-edit-menu [separator-bookmark]
372 (define-key menu-bar-edit-menu [bookmark]
373 '(menu-item "Bookmarks" menu-bar-bookmark-map))
375 (defvar menu-bar-goto-menu (make-sparse-keymap "Go To"))
377 (define-key menu-bar-goto-menu [set-tags-name]
378 '(menu-item "Set Tags File Name..." visit-tags-table
379 :help "Tell Tags commands which tag table file to use"))
381 (define-key menu-bar-goto-menu [separator-tag-file]
384 (define-key menu-bar-goto-menu [apropos-tags]
385 '(menu-item "Tags Apropos..." tags-apropos
386 :help "Find function/variables whose names match regexp"))
387 (define-key menu-bar-goto-menu [next-tag-otherw]
388 '(menu-item "Next Tag in Other Window"
389 menu-bar-next-tag-other-window
390 :enable (and (boundp 'tags-location-ring)
391 (not (ring-empty-p tags-location-ring)))
392 :help "Find next function/variable matching last tag name in another window"))
394 (defun menu-bar-next-tag-other-window ()
395 "Find the next definition of the tag already specified."
397 (find-tag-other-window nil t))
399 (defun menu-bar-next-tag ()
400 "Find the next definition of the tag already specified."
404 (define-key menu-bar-goto-menu [next-tag]
405 '(menu-item "Find Next Tag"
407 :enable (and (boundp 'tags-location-ring)
408 (not (ring-empty-p tags-location-ring)))
409 :help "Find next function/variable matching last tag name"))
410 (define-key menu-bar-goto-menu [find-tag-otherw]
411 '(menu-item "Find Tag in Other Window..." find-tag-other-window
412 :help "Find function/variable definition in another window"))
413 (define-key menu-bar-goto-menu [find-tag]
414 '(menu-item "Find Tag..." find-tag
415 :help "Find definition of function or variable"))
417 (define-key menu-bar-goto-menu [separator-tags]
420 (define-key menu-bar-goto-menu [end-of-buf]
421 '(menu-item "Goto End of Buffer" end-of-buffer))
422 (define-key menu-bar-goto-menu [beg-of-buf]
423 '(menu-item "Goto Beginning of Buffer" beginning-of-buffer))
424 (define-key menu-bar-goto-menu [go-to-pos]
425 '(menu-item "Goto Buffer Position..." goto-char
426 :help "Read a number N and go to buffer position N"))
427 (define-key menu-bar-goto-menu [go-to-line]
428 '(menu-item "Goto Line..." goto-line
429 :help "Read a line number and go to that line"))
431 (define-key menu-bar-edit-menu [goto]
432 (list 'menu-item "Go To" menu-bar-goto-menu))
434 (define-key menu-bar-edit-menu [replace]
435 (list 'menu-item "Replace" menu-bar-replace-menu))
437 (define-key menu-bar-edit-menu [search]
438 (list 'menu-item "Search" menu-bar-search-menu))
440 (define-key menu-bar-edit-menu [separator-search]
443 (define-key menu-bar-edit-menu [mark-whole-buffer]
444 '(menu-item "Select All" mark-whole-buffer
445 :help "Mark the whole buffer for a subsequent cut/copy."))
446 (define-key menu-bar-edit-menu [clear]
447 '(menu-item "Clear" delete-region
448 :enable (and mark-active
449 (not buffer-read-only)
450 (not (mouse-region-match)))
452 "Delete the text in region between mark and current position"))
453 (defvar yank-menu (cons "Select Yank" nil))
454 (fset 'yank-menu (cons 'keymap yank-menu))
455 (define-key menu-bar-edit-menu [paste-from-menu]
456 '(menu-item "Paste from kill menu" yank-menu
457 :enable (and (cdr yank-menu) (not buffer-read-only))
458 :help "Choose a string from the kill ring and paste it"))
459 (define-key menu-bar-edit-menu [paste]
460 '(menu-item "Paste" yank
462 ;; Emacs compiled --without-x doesn't have
463 ;; x-selection-exists-p.
464 (fboundp 'x-selection-exists-p)
465 (x-selection-exists-p) (not buffer-read-only))
466 :help "Paste (yank) text most recently cut/copied"))
467 (define-key menu-bar-edit-menu [copy]
468 '(menu-item "Copy" menu-bar-kill-ring-save
470 :help "Copy text in region between mark and current position"
471 :keys "\\[kill-ring-save]"))
472 (define-key menu-bar-edit-menu [cut]
473 '(menu-item "Cut" kill-region
474 :enable (and mark-active (not buffer-read-only))
476 "Cut (kill) text in region between mark and current position"))
477 (define-key menu-bar-edit-menu [undo]
478 '(menu-item "Undo" undo
479 :enable (and (not buffer-read-only)
480 (not (eq t buffer-undo-list))
481 (if (eq last-command 'undo)
482 (listp pending-undo-list)
483 (consp buffer-undo-list)))
484 :help "Undo last operation"))
487 (defun menu-bar-kill-ring-save (beg end)
489 (if (mouse-region-match)
490 (message "Selecting a region with the mouse does `copy' automatically")
491 (kill-ring-save beg end)))
493 ;; These are alternative definitions for the cut, paste and copy
494 ;; menu items. Use them if your system expects these to use the clipboard.
496 (put 'clipboard-kill-region 'menu-enable
497 '(and mark-active (not buffer-read-only)))
498 (put 'clipboard-kill-ring-save 'menu-enable 'mark-active)
499 (put 'clipboard-yank 'menu-enable
500 '(and (or (and (fboundp 'x-selection-exists-p)
501 (x-selection-exists-p))
502 (x-selection-exists-p 'CLIPBOARD))
503 (not buffer-read-only)))
505 (defun clipboard-yank ()
506 "Insert the clipboard contents, or the last stretch of killed text."
508 (let ((x-select-enable-clipboard t))
511 (defun clipboard-kill-ring-save (beg end)
512 "Copy region to kill ring, and save in the X clipboard."
514 (let ((x-select-enable-clipboard t))
515 (kill-ring-save beg end)))
517 (defun clipboard-kill-region (beg end)
518 "Kill the region, and save it in the X clipboard."
520 (let ((x-select-enable-clipboard t))
521 (kill-region beg end)))
523 (defun menu-bar-enable-clipboard ()
524 "Make CUT, PASTE and COPY (keys and menu bar items) use the clipboard.
525 Do the same for the keys of the same name."
527 ;; We can't use constant list structure here because it becomes pure,
528 ;; and because it gets modified with cache data.
529 (define-key menu-bar-edit-menu [paste]
530 (cons "Paste" (cons "Paste text from clipboard" 'clipboard-yank)))
531 (define-key menu-bar-edit-menu [copy]
532 (cons "Copy" (cons "Copy text in region to the clipboard"
533 'clipboard-kill-ring-save)))
534 (define-key menu-bar-edit-menu [cut]
535 (cons "Cut" (cons "Delete text in region and copy it to the clipboard"
536 'clipboard-kill-region)))
538 ;; These are Sun server keysyms for the Cut, Copy and Paste keys
539 ;; (also for XFree86 on Sun keyboard):
540 (define-key global-map [f20] 'clipboard-kill-region)
541 (define-key global-map [f16] 'clipboard-kill-ring-save)
542 (define-key global-map [f18] 'clipboard-yank)
544 (define-key global-map [cut] 'clipboard-kill-region)
545 (define-key global-map [copy] 'clipboard-kill-ring-save)
546 (define-key global-map [paste] 'clipboard-yank))
548 ;; The "Options" menu items
550 (defvar menu-bar-custom-menu (make-sparse-keymap "Customize"))
552 (define-key menu-bar-custom-menu [customize-apropos-groups]
553 '(menu-item "Groups Matching Regexp..." customize-apropos-groups
554 :help "Browse groups whose names match regexp"))
555 (define-key menu-bar-custom-menu [customize-apropos-faces]
556 '(menu-item "Faces Matching Regexp..." customize-apropos-faces
557 :help "Browse faces whose names match regexp"))
558 (define-key menu-bar-custom-menu [customize-apropos-options]
559 '(menu-item "Options Matching Regexp..." customize-apropos-options
560 :help "Browse options whose names match regexp"))
561 (define-key menu-bar-custom-menu [customize-apropos]
562 '(menu-item "Settings Matching Regexp..." customize-apropos
563 :help "Browse customizable settings whose names match regexp"))
564 (define-key menu-bar-custom-menu [separator-1]
566 (define-key menu-bar-custom-menu [customize-group]
567 '(menu-item "Specific Group..." customize-group
568 :help "Customize settings of specific group"))
569 (define-key menu-bar-custom-menu [customize-face]
570 '(menu-item "Specific Face..." customize-face
571 :help "Customize attributes of specific face"))
572 (define-key menu-bar-custom-menu [customize-option]
573 '(menu-item "Specific Option..." customize-option
574 :help "Customize value of specific option"))
575 (define-key menu-bar-custom-menu [separator-2]
577 (define-key menu-bar-custom-menu [customize-changed-options]
578 '(menu-item "New Options..." customize-changed-options
579 :help "Options added or changed in recent Emacs versions"))
580 (define-key menu-bar-custom-menu [customize-saved]
581 '(menu-item "Saved Options" customize-saved
582 :help "Customize previously saved options"))
583 (define-key menu-bar-custom-menu [separator-3]
585 (define-key menu-bar-custom-menu [customize-browse]
586 '(menu-item "Browse Customization Groups" customize-browse
587 :help "Browse all customization groups"))
588 (define-key menu-bar-custom-menu [customize]
589 '(menu-item "Top-level Customization Group" customize
590 :help "The master group called `Emacs'"))
592 ;(defvar menu-bar-preferences-menu (make-sparse-keymap "Preferences"))
594 (defmacro menu-bar-make-mm-toggle (fname doc help &optional props)
595 "Make a menu-item for a global minor mode toggle.
596 FNAME is the minor mode's name (variable and function).
597 DOC is the text to use for the menu entry.
598 HELP is the text to use for the tooltip.
599 PROPS are additional properties."
600 `'(menu-item ,doc ,fname
603 :button (:toggle . (and (default-boundp ',fname)
604 (default-value ',fname)))))
606 (defmacro menu-bar-make-toggle (name variable doc message help &rest body)
608 (defun ,name (&optional interactively)
609 ,(concat "Toggle whether to " (downcase (substring help 0 1))
610 (substring help 1) ".
611 In an interactive call, record this option as a candidate for saving
612 by \"Save Options\" in Custom buffers.")
614 (if ,(if body `(progn . ,body)
616 (custom-load-symbol ',variable)
617 (let ((set (or (get ',variable 'custom-set) 'set-default))
618 (get (or (get ',variable 'custom-get) 'default-value)))
619 (funcall set ',variable (not (funcall get ',variable))))))
620 (message ,message "enabled globally")
621 (message ,message "disabled globally"))
622 ;; The function `customize-mark-as-set' must only be called when
623 ;; a variable is set interactively, as the purpose is to mark it as
624 ;; a candidate for "Save Options", and we do not want to save options
625 ;; the user have already set explicitly in his init file.
626 (if interactively (customize-mark-as-set ',variable)))
627 '(menu-item ,doc ,name
629 :button (:toggle . (and (default-boundp ',variable)
630 (default-value ',variable))))))
632 ;;; Assemble all the top-level items of the "Options" menu
633 (define-key menu-bar-options-menu [customize]
634 (list 'menu-item "Customize Emacs" menu-bar-custom-menu))
636 (defun menu-bar-options-save ()
637 "Save current values of Options menu items using Custom."
639 (let ((need-save nil))
640 ;; These are set with menu-bar-make-mm-toggle, which does not
641 ;; put on a customized-value property.
642 (dolist (elt '(line-number-mode column-number-mode size-indication-mode
643 cua-mode show-paren-mode transient-mark-mode
644 blink-cursor-mode display-time-mode display-battery-mode))
645 (and (customize-mark-to-save elt)
647 ;; These are set with `customize-set-variable'.
648 (dolist (elt '(scroll-bar-mode
649 debug-on-quit debug-on-error
650 tooltip-mode menu-bar-mode tool-bar-mode
651 save-place uniquify-buffer-name-style fringe-mode
652 indicate-empty-lines indicate-buffer-boundaries
654 current-language-environment default-input-method
655 ;; Saving `text-mode-hook' is somewhat questionable,
656 ;; as we might get more than we bargain for, if
657 ;; other code may has added hooks as well.
658 ;; Nonetheless, not saving it would like be confuse
660 ;; -- Per Abrahamsen <abraham@dina.kvl.dk> 2002-02-11.
662 (and (get elt 'customized-value)
663 (customize-mark-to-save elt)
665 ;; Save if we changed anything.
669 (define-key menu-bar-options-menu [save]
670 '(menu-item "Save Options" menu-bar-options-save
671 :help "Save options set from the menu above"))
673 (define-key menu-bar-options-menu [custom-separator]
676 (define-key menu-bar-options-menu [mouse-set-font]
677 '(menu-item "Set Font/Fontset..." mouse-set-font
678 :visible (display-multi-font-p)
679 :help "Select a font from list of known fonts/fontsets"))
681 ;; The "Show/Hide" submenu of menu "Options"
683 (defvar menu-bar-showhide-menu (make-sparse-keymap "Show/Hide"))
685 (define-key menu-bar-showhide-menu [column-number-mode]
686 (menu-bar-make-mm-toggle column-number-mode
688 "Show the current column number in the mode line"))
690 (define-key menu-bar-showhide-menu [line-number-mode]
691 (menu-bar-make-mm-toggle line-number-mode
693 "Show the current line number in the mode line"))
695 (define-key menu-bar-showhide-menu [size-indication-mode]
696 (menu-bar-make-mm-toggle size-indication-mode
698 "Show the size of the buffer in the mode line"))
700 (define-key menu-bar-showhide-menu [linecolumn-separator]
703 (define-key menu-bar-showhide-menu [showhide-battery]
704 (menu-bar-make-mm-toggle display-battery-mode
706 "Display battery status information in mode line"))
708 (define-key menu-bar-showhide-menu [showhide-date-time]
709 (menu-bar-make-mm-toggle display-time-mode
710 "Time, Load and Mail"
711 "Display time, system load averages and \
712 mail status in mode line"))
714 (define-key menu-bar-showhide-menu [datetime-separator]
717 (define-key menu-bar-showhide-menu [showhide-speedbar]
718 '(menu-item "Speedbar" speedbar-frame-mode
719 :help "Display a Speedbar quick-navigation frame"
721 . (and (boundp 'speedbar-frame)
722 (frame-live-p (symbol-value 'speedbar-frame))
724 (symbol-value 'speedbar-frame))))))
726 (defvar menu-bar-showhide-fringe-menu (make-sparse-keymap "Fringe"))
728 (defvar menu-bar-showhide-fringe-ind-menu
729 (make-sparse-keymap "Buffer boundaries"))
731 (defun menu-bar-showhide-fringe-ind-customize ()
732 "Show customization buffer for `indicate-buffer-boundaries'."
734 (customize-variable 'indicate-buffer-boundaries))
736 (define-key menu-bar-showhide-fringe-ind-menu [customize]
737 '(menu-item "Other (Customize)"
738 menu-bar-showhide-fringe-ind-customize
739 :help "Additional choices available through Custom buffer"
740 :visible (display-graphic-p)
741 :button (:radio . (not (member indicate-buffer-boundaries
743 ((top . left) (bottom . right))
744 ((t . right) (top . left))))))))
746 (defun menu-bar-showhide-fringe-ind-mixed ()
747 "Display top and bottom indicators in opposite fringes, arrows in right."
749 (customize-set-variable 'indicate-buffer-boundaries
750 '((t . right) (top . left))))
752 (define-key menu-bar-showhide-fringe-ind-menu [mixed]
753 '(menu-item "Opposite, Arrows Right" menu-bar-showhide-fringe-ind-mixed
755 "Show top/bottom indicators in opposite fringes, arrows in right"
756 :visible (display-graphic-p)
757 :button (:radio . (equal indicate-buffer-boundaries
758 '((t . right) (top . left))))))
760 (defun menu-bar-showhide-fringe-ind-box ()
761 "Display top and bottom indicators in opposite fringes."
763 (customize-set-variable 'indicate-buffer-boundaries
764 '((top . left) (bottom . right))))
766 (define-key menu-bar-showhide-fringe-ind-menu [box]
767 '(menu-item "Opposite, No Arrows" menu-bar-showhide-fringe-ind-box
768 :help "Show top/bottom indicators in opposite fringes, no arrows"
769 :visible (display-graphic-p)
770 :button (:radio . (equal indicate-buffer-boundaries
771 '((top . left) (bottom . right))))))
773 (defun menu-bar-showhide-fringe-ind-right ()
774 "Display buffer boundaries and arrows in the right fringe."
776 (customize-set-variable 'indicate-buffer-boundaries 'right))
778 (define-key menu-bar-showhide-fringe-ind-menu [right]
779 '(menu-item "In Right Fringe" menu-bar-showhide-fringe-ind-right
780 :help "Show buffer boundaries and arrows in right fringe"
781 :visible (display-graphic-p)
782 :button (:radio . (eq indicate-buffer-boundaries 'right))))
784 (defun menu-bar-showhide-fringe-ind-left ()
785 "Display buffer boundaries and arrows in the left fringe."
787 (customize-set-variable 'indicate-buffer-boundaries 'left))
789 (define-key menu-bar-showhide-fringe-ind-menu [left]
790 '(menu-item "In Left Fringe" menu-bar-showhide-fringe-ind-left
791 :help "Show buffer boundaries and arrows in left fringe"
792 :visible (display-graphic-p)
793 :button (:radio . (eq indicate-buffer-boundaries 'left))))
795 (defun menu-bar-showhide-fringe-ind-none ()
796 "Do not display any buffer boundary indicators."
798 (customize-set-variable 'indicate-buffer-boundaries nil))
800 (define-key menu-bar-showhide-fringe-ind-menu [none]
801 '(menu-item "No Indicators" menu-bar-showhide-fringe-ind-none
802 :help "Hide all buffer boundary indicators and arrows"
803 :visible (display-graphic-p)
804 :button (:radio . (eq indicate-buffer-boundaries nil))))
806 (define-key menu-bar-showhide-fringe-menu [showhide-fringe-ind]
807 (list 'menu-item "Buffer Boundaries" menu-bar-showhide-fringe-ind-menu
808 :visible `(display-graphic-p)
809 :help "Indicate buffer boundaries in fringe"))
811 (define-key menu-bar-showhide-fringe-menu [indicate-empty-lines]
812 (menu-bar-make-toggle toggle-indicate-empty-lines indicate-empty-lines
813 "Empty Line Indicators"
814 "Indicating of empty lines %s"
815 "Indicate trailing empty lines in fringe, globally"))
817 (defun menu-bar-showhide-fringe-menu-customize ()
818 "Show customization buffer for `fringe-mode'."
820 (customize-variable 'fringe-mode))
822 (define-key menu-bar-showhide-fringe-menu [customize]
823 '(menu-item "Customize Fringe" menu-bar-showhide-fringe-menu-customize
824 :help "Detailed customization of fringe"
825 :visible (display-graphic-p)))
827 (defun menu-bar-showhide-fringe-menu-customize-reset ()
828 "Reset the fringe mode: display fringes on both sides of a window."
830 (customize-set-variable 'fringe-mode nil))
832 (define-key menu-bar-showhide-fringe-menu [default]
833 '(menu-item "Default" menu-bar-showhide-fringe-menu-customize-reset
834 :help "Default width fringe on both left and right side"
835 :visible (display-graphic-p)
836 :button (:radio . (eq fringe-mode nil))))
838 (defun menu-bar-showhide-fringe-menu-customize-right ()
839 "Display fringes only on the right of each window."
842 (customize-set-variable 'fringe-mode '(0 . nil)))
844 (define-key menu-bar-showhide-fringe-menu [right]
845 '(menu-item "On the Right" menu-bar-showhide-fringe-menu-customize-right
846 :help "Fringe only on the right side"
847 :visible (display-graphic-p)
848 :button (:radio . (equal fringe-mode '(0 . nil)))))
850 (defun menu-bar-showhide-fringe-menu-customize-left ()
851 "Display fringes only on the left of each window."
854 (customize-set-variable 'fringe-mode '(nil . 0)))
856 (define-key menu-bar-showhide-fringe-menu [left]
857 '(menu-item "On the Left" menu-bar-showhide-fringe-menu-customize-left
858 :help "Fringe only on the left side"
859 :visible (display-graphic-p)
860 :button (:radio . (equal fringe-mode '(nil . 0)))))
862 (defun menu-bar-showhide-fringe-menu-customize-disable ()
863 "Do not display window fringes."
866 (customize-set-variable 'fringe-mode 0))
868 (define-key menu-bar-showhide-fringe-menu [none]
869 '(menu-item "None" menu-bar-showhide-fringe-menu-customize-disable
870 :help "Turn off fringe"
871 :visible (display-graphic-p)
872 :button (:radio . (eq fringe-mode 0))))
874 (define-key menu-bar-showhide-menu [showhide-fringe]
875 (list 'menu-item "Fringe" menu-bar-showhide-fringe-menu
876 :visible `(display-graphic-p)))
878 (defvar menu-bar-showhide-scroll-bar-menu (make-sparse-keymap "Scroll-bar"))
880 (define-key menu-bar-showhide-scroll-bar-menu [right]
881 '(menu-item "On the Right"
882 menu-bar-right-scroll-bar
883 :help "Scroll-bar on the right side"
884 :visible (display-graphic-p)
885 :button (:radio . (eq (cdr (assq 'vertical-scroll-bars
886 (frame-parameters))) 'right))))
887 (defun menu-bar-right-scroll-bar ()
888 "Display scroll bars on the right of each window."
890 (customize-set-variable 'scroll-bar-mode 'right))
892 (define-key menu-bar-showhide-scroll-bar-menu [left]
893 '(menu-item "On the Left"
894 menu-bar-left-scroll-bar
895 :help "Scroll-bar on the left side"
896 :visible (display-graphic-p)
897 :button (:radio . (eq (cdr (assq 'vertical-scroll-bars
898 (frame-parameters))) 'left))))
900 (defun menu-bar-left-scroll-bar ()
901 "Display scroll bars on the left of each window."
903 (customize-set-variable 'scroll-bar-mode 'left))
905 (define-key menu-bar-showhide-scroll-bar-menu [none]
907 menu-bar-no-scroll-bar
908 :help "Turn off scroll-bar"
909 :visible (display-graphic-p)
910 :button (:radio . (eq (cdr (assq 'vertical-scroll-bars
911 (frame-parameters))) nil))))
913 (defun menu-bar-no-scroll-bar ()
914 "Turn off scroll bars."
916 (customize-set-variable 'scroll-bar-mode nil))
918 (define-key menu-bar-showhide-menu [showhide-scroll-bar]
919 (list 'menu-item "Scroll-bar" menu-bar-showhide-scroll-bar-menu
920 :visible `(display-graphic-p)))
922 (define-key menu-bar-showhide-menu [showhide-tooltip-mode]
923 (list 'menu-item "Tooltips" 'tooltip-mode
924 :help "Turn tooltips on/off"
925 :visible `(and (display-graphic-p) (fboundp 'x-show-tip))
926 :button `(:toggle . tooltip-mode)))
928 (define-key menu-bar-showhide-menu [menu-bar-mode]
929 '(menu-item "Menu-bar" toggle-menu-bar-mode-from-frame
930 :help "Turn menu-bar on/off"
931 :button (:toggle . (> (frame-parameter nil 'menu-bar-lines) 0))))
933 (define-key menu-bar-showhide-menu [showhide-tool-bar]
934 (list 'menu-item "Tool-bar" 'toggle-tool-bar-mode-from-frame
935 :help "Toggle tool-bar on/off"
936 :visible `(display-graphic-p)
937 :button `(:toggle . (> (frame-parameter nil 'tool-bar-lines) 0))))
939 (define-key menu-bar-options-menu [showhide]
940 (list 'menu-item "Show/Hide" menu-bar-showhide-menu))
942 (define-key menu-bar-options-menu [showhide-separator]
945 (define-key menu-bar-options-menu [mule]
946 ;; It is better not to use backquote here,
947 ;; because that makes a bootstrapping problem
948 ;; if you need to recompile all the Lisp files using interpreted code.
949 (list 'menu-item "Mule (Multilingual Environment)" mule-menu-keymap
950 ;; Most of the MULE menu actually does make sense in unibyte mode,
951 ;; e.g. language selection.
952 ;;; ':visible 'default-enable-multibyte-characters
954 ;(setq menu-bar-final-items (cons 'mule menu-bar-final-items))
955 ;(define-key menu-bar-options-menu [preferences]
956 ; (list 'menu-item "Preferences" menu-bar-preferences-menu
957 ; :help "Toggle important global options"))
959 (define-key menu-bar-options-menu [mule-separator]
962 (define-key menu-bar-options-menu [debug-on-quit]
963 (menu-bar-make-toggle toggle-debug-on-quit debug-on-quit
964 "Enter Debugger on Quit/C-g" "Debug on Quit %s"
965 "Enter Lisp debugger when C-g is pressed"))
966 (define-key menu-bar-options-menu [debug-on-error]
967 (menu-bar-make-toggle toggle-debug-on-error debug-on-error
968 "Enter Debugger on Error" "Debug on Error %s"
969 "Enter Lisp debugger when an error is signaled"))
970 (define-key menu-bar-options-menu [debugger-separator]
973 (define-key menu-bar-options-menu [blink-cursor-mode]
974 (menu-bar-make-mm-toggle blink-cursor-mode
976 "Whether the cursor blinks (Blink Cursor mode)"))
977 (define-key menu-bar-options-menu [cursor-separator]
980 (define-key menu-bar-options-menu [save-place]
981 (menu-bar-make-toggle toggle-save-place-globally save-place
982 "Save Place in Files between Sessions"
983 "Saving place in files %s"
984 "Visit files of previous session when restarting Emacs"
986 ;; Do it by name, to avoid a free-variable
987 ;; warning during byte compilation.
989 'save-place (not (symbol-value 'save-place)))))
991 (define-key menu-bar-options-menu [uniquify]
992 (menu-bar-make-toggle toggle-uniquify-buffer-names uniquify-buffer-name-style
993 "Use Directory Names in Buffer Names"
994 "Directory name in buffer names (uniquify) %s"
995 "Uniquify buffer names by adding parent directory names"
997 (setq uniquify-buffer-name-style
998 (if (not uniquify-buffer-name-style)
1001 (define-key menu-bar-options-menu [edit-options-separator]
1003 (define-key menu-bar-options-menu [cua-mode]
1004 (menu-bar-make-mm-toggle cua-mode
1005 "C-x/C-c/C-v Cut and Paste (CUA)"
1006 "Use C-z/C-x/C-c/C-v keys for undo/cut/copy/paste"
1007 (:visible (or (not (boundp 'cua-enable-cua-keys))
1008 cua-enable-cua-keys))))
1010 (define-key menu-bar-options-menu [cua-emulation-mode]
1011 (menu-bar-make-mm-toggle cua-mode
1012 "Shift movement mark region (CUA)"
1013 "Use shifted movement keys to set and extend the region."
1014 (:visible (and (boundp 'cua-enable-cua-keys)
1015 (not cua-enable-cua-keys)))))
1017 (define-key menu-bar-options-menu [case-fold-search]
1018 (menu-bar-make-toggle toggle-case-fold-search case-fold-search
1019 "Case-Insensitive Search"
1020 "Case-Insensitive Search %s"
1021 "Globally ignore letter-case in search"))
1023 (defun menu-bar-text-mode-auto-fill ()
1025 (toggle-text-mode-auto-fill)
1026 ;; This is somewhat questionable, as `text-mode-hook'
1027 ;; might have changed outside customize.
1028 ;; -- Per Abrahamsen <abraham@dina.kvl.dk> 2002-02-11.
1029 (customize-mark-as-set 'text-mode-hook))
1031 (define-key menu-bar-options-menu [auto-fill-mode]
1032 '(menu-item "Word Wrap in Text Modes"
1033 menu-bar-text-mode-auto-fill
1034 :help "Automatically fill text between left and right margins (Auto Fill)"
1035 :button (:toggle . (if (listp text-mode-hook)
1036 (member 'turn-on-auto-fill text-mode-hook)
1037 (eq 'turn-on-auto-fill text-mode-hook)))))
1038 (define-key menu-bar-options-menu [truncate-lines]
1039 '(menu-item "Truncate Long Lines in this Buffer"
1040 toggle-truncate-lines
1041 :help "Truncate long lines on the screen"
1042 :button (:toggle . (if (or (window-full-width-p)
1043 (not truncate-partial-width-windows))
1045 truncate-partial-width-windows))
1046 :enable (and (menu-bar-menu-frame-live-and-visible-p)
1047 (or (window-full-width-p)
1048 (not truncate-partial-width-windows)))))
1050 (define-key menu-bar-options-menu [highlight-separator]
1052 (define-key menu-bar-options-menu [highlight-paren-mode]
1053 (menu-bar-make-mm-toggle show-paren-mode
1054 "Paren Match Highlighting"
1055 "Highlight matching/mismatched parentheses at cursor (Show Paren mode)"))
1056 (define-key menu-bar-options-menu [transient-mark-mode]
1057 (menu-bar-make-mm-toggle transient-mark-mode
1058 "Active Region Highlighting"
1059 "Make text in active region stand out in color (Transient Mark mode)"
1060 (:enable (not cua-mode))))
1063 ;; The "Tools" menu items
1065 (defun send-mail-item-name ()
1066 (let* ((known-send-mail-commands '((sendmail-user-agent . "sendmail")
1067 (mh-e-user-agent . "MH")
1068 (message-user-agent . "Gnus Message")
1069 (gnus-user-agent . "Gnus")))
1070 (name (assq mail-user-agent known-send-mail-commands)))
1072 (setq name (cdr name))
1073 (setq name (symbol-name mail-user-agent))
1074 (if (string-match "\\(.+\\)-user-agent" name)
1075 (setq name (match-string 1 name))))
1078 (defun read-mail-item-name ()
1079 (let* ((known-rmail-commands '((rmail . "RMAIL")
1082 (known (assq read-mail-command known-rmail-commands)))
1083 (if known (cdr known) (symbol-name read-mail-command))))
1085 (defvar menu-bar-encryption-decryption-menu
1086 (make-sparse-keymap "Encryption/Decryption"))
1088 (define-key menu-bar-tools-menu [encryption-decryption]
1089 (list 'menu-item "Encryption/Decryption" menu-bar-encryption-decryption-menu))
1091 (define-key menu-bar-tools-menu [separator-encryption-decryption]
1094 (define-key menu-bar-encryption-decryption-menu [insert-keys]
1095 '(menu-item "Insert Keys" epa-insert-keys
1096 :help "Insert public keys after the current point"))
1098 (define-key menu-bar-encryption-decryption-menu [export-keys]
1099 '(menu-item "Export Keys" epa-export-keys
1100 :help "Export public keys to a file"))
1102 (define-key menu-bar-encryption-decryption-menu [import-keys-region]
1103 '(menu-item "Import Keys from Region" epa-import-keys-region
1104 :help "Import public keys from the current region"))
1106 (define-key menu-bar-encryption-decryption-menu [import-keys]
1107 '(menu-item "Import Keys from File" epa-import-keys
1108 :help "Import public keys from a file"))
1110 (define-key menu-bar-encryption-decryption-menu [list-keys]
1111 '(menu-item "List Keys" epa-list-keys
1112 :help "Browse your public keyring"))
1114 (define-key menu-bar-encryption-decryption-menu [separator-keys]
1117 (define-key menu-bar-encryption-decryption-menu [encrypt-region]
1118 '(menu-item "Encrypt Region" epa-encrypt-region
1119 :help "Encrypt the current region"))
1121 (define-key menu-bar-encryption-decryption-menu [encrypt-file]
1122 '(menu-item "Encrypt File" epa-encrypt-file
1123 :help "Encrypt a file"))
1125 (define-key menu-bar-encryption-decryption-menu [sign-region]
1126 '(menu-item "Sign Region" epa-sign-region
1127 :help "Create digital signature of the current region"))
1129 (define-key menu-bar-encryption-decryption-menu [sign-file]
1130 '(menu-item "Sign File" epa-sign-file
1131 :help "Create digital signature of a file"))
1133 (define-key menu-bar-encryption-decryption-menu [verify-region]
1134 '(menu-item "Verify Region" epa-verify-region
1135 :help "Verify digital signature of the current region"))
1137 (define-key menu-bar-encryption-decryption-menu [verify-file]
1138 '(menu-item "Verify File" epa-verify-file
1139 :help "Verify digital signature of a file"))
1141 (define-key menu-bar-encryption-decryption-menu [decrypt-region]
1142 '(menu-item "Decrypt Region" epa-decrypt-region
1143 :help "Decrypt the current region"))
1145 (define-key menu-bar-encryption-decryption-menu [decrypt-file]
1146 '(menu-item "Decrypt File" epa-decrypt-file
1147 :help "Decrypt a file"))
1149 (defvar menu-bar-games-menu (make-sparse-keymap "Games"))
1151 (define-key menu-bar-tools-menu [games]
1152 (list 'menu-item "Games" menu-bar-games-menu))
1154 (define-key menu-bar-tools-menu [separator-games]
1157 (define-key menu-bar-games-menu [zone]
1158 '(menu-item "Zone Out" zone
1159 :help "Play tricks with Emacs display when Emacs is idle"))
1160 (define-key menu-bar-games-menu [tetris]
1161 '(menu-item "Tetris" tetris
1162 :help "Falling blocks game"))
1163 (define-key menu-bar-games-menu [solitaire]
1164 '(menu-item "Solitaire" solitaire
1165 :help "Get rid of all the stones"))
1166 (define-key menu-bar-games-menu [snake]
1167 '(menu-item "Snake" snake
1168 :help "Move snake around avoiding collisions"))
1169 (define-key menu-bar-games-menu [pong]
1170 '(menu-item "Pong" pong
1171 :help "Bounce the ball to your opponent"))
1172 (define-key menu-bar-games-menu [mult]
1173 '(menu-item "Multiplication Puzzle" mpuz
1174 :help "Exercise brain with multiplication"))
1175 (define-key menu-bar-games-menu [life]
1176 '(menu-item "Life" life
1177 :help "Watch how John Conway's cellular automaton evolves"))
1178 (define-key menu-bar-games-menu [hanoi]
1179 '(menu-item "Towers of Hanoi" hanoi
1180 :help "Watch Towers-of-Hanoi puzzle solved by Emacs"))
1181 (define-key menu-bar-games-menu [gomoku]
1182 '(menu-item "Gomoku" gomoku
1183 :help "Mark 5 contiguous squares (like tic-tac-toe)"))
1184 (define-key menu-bar-games-menu [bubbles]
1185 '(menu-item "Bubbles" bubbles
1186 :help "Remove all bubbles using the fewest moves"))
1187 (define-key menu-bar-games-menu [black-box]
1188 '(menu-item "Blackbox" blackbox
1189 :help "Find balls in a black box by shooting rays"))
1190 (define-key menu-bar-games-menu [adventure]
1191 '(menu-item "Adventure" dunnet
1192 :help "Dunnet, a text Adventure game for Emacs"))
1193 (define-key menu-bar-games-menu [5x5]
1194 '(menu-item "5x5" 5x5
1195 :help "Fill in all the squares on a 5x5 board"))
1197 (define-key menu-bar-tools-menu [simple-calculator]
1198 '(menu-item "Simple Calculator" calculator
1199 :help "Invoke the Emacs built-in quick calculator"))
1200 (define-key menu-bar-tools-menu [calc]
1201 '(menu-item "Programmable Calculator" calc
1202 :help "Invoke the Emacs built-in full scientific calculator"))
1203 (define-key menu-bar-tools-menu [calendar]
1204 '(menu-item "Calendar" calendar
1205 :help "Invoke the Emacs built-in calendar"))
1207 (define-key menu-bar-tools-menu [separator-net]
1210 (define-key menu-bar-tools-menu [directory-search]
1211 '(menu-item "Directory Search" eudc-tools-menu))
1212 (define-key menu-bar-tools-menu [compose-mail]
1214 'menu-item `(format "Send Mail (with %s)" (send-mail-item-name))
1216 :visible `(and mail-user-agent (not (eq mail-user-agent 'ignore)))
1217 :help "Send a mail message"))
1218 (define-key menu-bar-tools-menu [rmail]
1220 'menu-item `(format "Read Mail (with %s)" (read-mail-item-name))
1222 :visible `(and read-mail-command (not (eq read-mail-command 'ignore)))
1223 :help "Read your mail and reply to it"))
1225 (defun menu-bar-read-mail ()
1226 "Read mail using `read-mail-command'."
1228 (call-interactively read-mail-command))
1230 (define-key menu-bar-tools-menu [gnus]
1231 '(menu-item "Read Net News (Gnus)" gnus
1232 :help "Read network news groups"))
1234 (define-key menu-bar-tools-menu [separator-vc]
1237 (define-key menu-bar-tools-menu [pcl-cvs]
1238 '(menu-item "PCL-CVS" cvs-global-menu))
1239 (define-key menu-bar-tools-menu [vc] nil) ;Create the place for the VC menu.
1241 (define-key menu-bar-tools-menu [separator-compare]
1244 (define-key menu-bar-tools-menu [ediff-misc]
1245 '(menu-item "Ediff Miscellanea" menu-bar-ediff-misc-menu))
1246 (define-key menu-bar-tools-menu [epatch]
1247 '(menu-item "Apply Patch" menu-bar-epatch-menu))
1248 (define-key menu-bar-tools-menu [ediff-merge]
1249 '(menu-item "Merge" menu-bar-ediff-merge-menu))
1250 (define-key menu-bar-tools-menu [compare]
1251 '(menu-item "Compare (Ediff)" menu-bar-ediff-menu))
1253 (define-key menu-bar-tools-menu [separator-spell]
1256 (define-key menu-bar-tools-menu [spell]
1257 '(menu-item "Spell Checking" ispell-menu-map))
1259 (define-key menu-bar-tools-menu [separator-prog]
1262 (define-key menu-bar-tools-menu [gdb]
1263 '(menu-item "Debugger (GDB)..." gdb
1264 :help "Debug a program from within Emacs with GDB"))
1265 (define-key menu-bar-tools-menu [shell-on-region]
1266 '(menu-item "Shell Command on Region..." shell-command-on-region
1268 :help "Pass marked region to a shell command"))
1269 (define-key menu-bar-tools-menu [shell]
1270 '(menu-item "Shell Command..." shell-command
1271 :help "Invoke a shell command and catch its output"))
1272 (define-key menu-bar-tools-menu [compile]
1273 '(menu-item "Compile..." compile
1274 :help "Invoke compiler or Make, view compilation errors"))
1275 (define-key menu-bar-tools-menu [grep]
1276 '(menu-item "Search Files (Grep)..." grep
1277 :help "Search files for strings or regexps (with Grep)"))
1280 ;; The "Help" menu items
1282 (defvar menu-bar-describe-menu (make-sparse-keymap "Describe"))
1284 (define-key menu-bar-describe-menu [mule-diag]
1285 '(menu-item "Show All of Mule Status" mule-diag
1286 :visible default-enable-multibyte-characters
1287 :help "Display multilingual environment settings"))
1288 (define-key menu-bar-describe-menu [describe-coding-system-briefly]
1289 '(menu-item "Describe Coding System (Briefly)"
1290 describe-current-coding-system-briefly
1291 :visible default-enable-multibyte-characters))
1292 (define-key menu-bar-describe-menu [describe-coding-system]
1293 '(menu-item "Describe Coding System..." describe-coding-system
1294 :visible default-enable-multibyte-characters))
1295 (define-key menu-bar-describe-menu [describe-input-method]
1296 '(menu-item "Describe Input Method..." describe-input-method
1297 :visible default-enable-multibyte-characters
1298 :help "Keyboard layout for specific input method"))
1299 (define-key menu-bar-describe-menu [describe-language-environment]
1300 (list 'menu-item "Describe Language Environment"
1301 describe-language-environment-map))
1303 (define-key menu-bar-describe-menu [separator-desc-mule]
1306 (define-key menu-bar-describe-menu [list-keybindings]
1307 '(menu-item "List Key Bindings" describe-bindings
1308 :help "Display all current keybindings (keyboard shortcuts)"))
1309 (define-key menu-bar-describe-menu [describe-current-display-table]
1310 '(menu-item "Describe Display Table" describe-current-display-table
1311 :help "Describe the current display table"))
1312 (define-key menu-bar-describe-menu [describe-face]
1313 '(menu-item "Describe Face..." describe-face
1314 :help "Display the properties of a face"))
1315 (define-key menu-bar-describe-menu [describe-variable]
1316 '(menu-item "Describe Variable..." describe-variable
1317 :help "Display documentation of variable/option"))
1318 (define-key menu-bar-describe-menu [describe-function]
1319 '(menu-item "Describe Function..." describe-function
1320 :help "Display documentation of function/command"))
1321 (define-key menu-bar-describe-menu [describe-key-1]
1322 '(menu-item "Describe Key or Mouse Operation..." describe-key
1323 ;; Users typically don't identify keys and menu items...
1324 :help "Display documentation of command bound to a \
1325 key, a click, or a menu-item"))
1326 (define-key menu-bar-describe-menu [describe-mode]
1327 '(menu-item "Describe Buffer Modes" describe-mode
1328 :help "Describe this buffer's major and minor mode"))
1330 (defvar menu-bar-search-documentation-menu
1331 (make-sparse-keymap "Search Documentation"))
1332 (defun menu-bar-read-lispref ()
1333 "Display the Emacs Lisp Reference manual in Info mode."
1337 (defun menu-bar-read-lispintro ()
1338 "Display the Introduction to Emacs Lisp Programming in Info mode."
1342 (defun search-emacs-glossary ()
1343 "Display the Glossary node of the Emacs manual in Info mode."
1345 (info "(emacs)Glossary"))
1347 (defun emacs-index-search (topic)
1348 "Look up TOPIC in the indices of the Emacs User Manual."
1349 (interactive "sSubject to look up: ")
1353 (defun elisp-index-search (topic)
1354 "Look up TOPIC in the indices of the Emacs Lisp Reference Manual."
1355 (interactive "sSubject to look up: ")
1359 (define-key menu-bar-search-documentation-menu [search-documentation-strings]
1360 '(menu-item "Search Documentation Strings..." apropos-documentation
1362 "Find functions and variables whose doc strings match a regexp"))
1363 (define-key menu-bar-search-documentation-menu [find-any-object-by-name]
1364 '(menu-item "Find Any Object by Name..." apropos
1365 :help "Find symbols of any kind whose names match a regexp"))
1366 (define-key menu-bar-search-documentation-menu [find-option-by-value]
1367 '(menu-item "Find Options by Value..." apropos-value
1368 :help "Find variables whose values match a regexp"))
1369 (define-key menu-bar-search-documentation-menu [find-options-by-name]
1370 '(menu-item "Find Options by Name..." apropos-variable
1371 :help "Find variables whose names match a regexp"))
1372 (define-key menu-bar-search-documentation-menu [find-commands-by-name]
1373 '(menu-item "Find Commands by Name..." apropos-command
1374 :help "Find commands whose names match a regexp"))
1375 (define-key menu-bar-search-documentation-menu [sep1]
1377 (define-key menu-bar-search-documentation-menu [lookup-command-in-manual]
1378 '(menu-item "Look Up Command in User Manual..." Info-goto-emacs-command-node
1379 :help "Display manual section that describes a command"))
1380 (define-key menu-bar-search-documentation-menu [lookup-key-in-manual]
1381 '(menu-item "Look Up Key in User Manual..." Info-goto-emacs-key-command-node
1382 :help "Display manual section that describes a key"))
1383 (define-key menu-bar-search-documentation-menu [lookup-subject-in-elisp-manual]
1384 '(menu-item "Look Up Subject in ELisp Manual..." elisp-index-search
1385 :help "Find description of a subject in Emacs Lisp manual"))
1386 (define-key menu-bar-search-documentation-menu [lookup-subject-in-emacs-manual]
1387 '(menu-item "Look Up Subject in User Manual..." emacs-index-search
1388 :help "Find description of a subject in Emacs User manual"))
1389 (define-key menu-bar-search-documentation-menu [emacs-terminology]
1390 '(menu-item "Emacs Terminology" search-emacs-glossary
1391 :help "Display the Glossary section of the Emacs manual"))
1393 (defvar menu-bar-manuals-menu (make-sparse-keymap "More Manuals"))
1395 (define-key menu-bar-manuals-menu [man]
1396 '(menu-item "Read Man Page..." manual-entry
1397 :help "Man-page docs for external commands and libraries"))
1398 (define-key menu-bar-manuals-menu [sep2]
1400 (define-key menu-bar-manuals-menu [order-emacs-manuals]
1401 '(menu-item "Ordering Manuals" view-order-manuals
1402 :help "How to order manuals from the Free Software Foundation"))
1403 (define-key menu-bar-manuals-menu [lookup-subject-in-all-manuals]
1404 '(menu-item "Lookup Subject in all manuals..." info-apropos
1405 :help "Find description of a subject in all installed manuals"))
1406 (define-key menu-bar-manuals-menu [other-manuals]
1407 '(menu-item "All Other Manuals (Info)" Info-directory
1408 :help "Read any of the installed manuals"))
1409 (define-key menu-bar-manuals-menu [emacs-lisp-reference]
1410 '(menu-item "Emacs Lisp Reference" menu-bar-read-lispref
1411 :help "Read the Emacs Lisp Reference manual"))
1412 (define-key menu-bar-manuals-menu [emac-lisp-intro]
1413 '(menu-item "Introduction to Emacs Lisp" menu-bar-read-lispintro
1414 :help "Read the Introduction to Emacs Lisp Programming"))
1416 (define-key menu-bar-help-menu [about-gnu-project]
1417 '(menu-item "About GNU" describe-gnu-project
1418 :help "About the GNU System, GNU Project, and GNU/Linux"))
1419 (define-key menu-bar-help-menu [about-emacs]
1420 '(menu-item "About Emacs" about-emacs
1421 :help "Display version number, copyright info, and basic help"))
1422 (define-key menu-bar-help-menu [sep4]
1424 (define-key menu-bar-help-menu [describe-no-warranty]
1425 '(menu-item "(Non)Warranty" describe-no-warranty
1426 :help "Explain that Emacs has NO WARRANTY"))
1427 (define-key menu-bar-help-menu [describe-copying]
1428 '(menu-item "Copying Conditions" describe-copying
1429 :help "Show the Emacs license (GPL)"))
1430 (define-key menu-bar-help-menu [getting-new-versions]
1431 '(menu-item "Getting New Versions" describe-distribution
1432 :help "How to get latest versions of Emacs"))
1433 (defun menu-bar-help-extra-packages ()
1434 "Display help about some additional packages available for Emacs."
1436 (let (enable-local-variables)
1437 (view-file (expand-file-name "MORE.STUFF"
1440 (define-key menu-bar-help-menu [sep2]
1442 (define-key menu-bar-help-menu [external-packages]
1443 '(menu-item "External Packages" menu-bar-help-extra-packages
1444 :help "Lisp packages distributed separately for use in Emacs"))
1445 (define-key menu-bar-help-menu [find-emacs-packages]
1446 '(menu-item "Find Emacs Packages" finder-by-keyword
1447 :help "Find packages and features by keyword"))
1448 (define-key menu-bar-help-menu [more-manuals]
1449 (list 'menu-item "More Manuals" menu-bar-manuals-menu))
1450 (define-key menu-bar-help-menu [emacs-manual]
1451 '(menu-item "Read the Emacs Manual" info-emacs-manual
1452 :help "Full documentation of Emacs features"))
1453 (define-key menu-bar-help-menu [describe]
1454 (list 'menu-item "Describe" menu-bar-describe-menu))
1455 (define-key menu-bar-help-menu [search-documentation]
1456 (list 'menu-item "Search Documentation" menu-bar-search-documentation-menu))
1457 (define-key menu-bar-help-menu [sep1]
1459 (define-key menu-bar-help-menu [emacs-psychotherapist]
1460 '(menu-item "Emacs Psychotherapist" doctor
1461 :help "Our doctor will help you feel better"))
1462 (define-key menu-bar-help-menu [send-emacs-bug-report]
1463 '(menu-item "Send Bug Report..." report-emacs-bug
1464 :help "Send e-mail to Emacs maintainers"))
1465 (define-key menu-bar-help-menu [emacs-known-problems]
1466 '(menu-item "Emacs Known Problems" view-emacs-problems
1467 :help "Read about known problems with Emacs"))
1468 (define-key menu-bar-help-menu [emacs-news]
1469 '(menu-item "Emacs News" view-emacs-news
1470 :help "New features of this version"))
1471 (define-key menu-bar-help-menu [emacs-faq]
1472 '(menu-item "Emacs FAQ" view-emacs-FAQ
1473 :help "Frequently asked (and answered) questions about Emacs"))
1475 (defun help-with-tutorial-spec-language ()
1476 "Use the Emacs tutorial, specifying which language you want."
1478 (help-with-tutorial t))
1480 (define-key menu-bar-help-menu [emacs-tutorial-language-specific]
1481 '(menu-item "Emacs Tutorial (choose language)..."
1482 help-with-tutorial-spec-language
1483 :help "Learn how to use Emacs (choose a language)"))
1484 (define-key menu-bar-help-menu [emacs-tutorial]
1485 '(menu-item "Emacs Tutorial" help-with-tutorial
1486 :help "Learn how to use Emacs"))
1488 (defun menu-bar-menu-frame-live-and-visible-p ()
1489 "Return non-nil if the menu frame is alive and visible.
1490 The menu frame is the frame for which we are updating the menu."
1491 (let ((menu-frame (or menu-updating-frame (selected-frame))))
1492 (and (frame-live-p menu-frame)
1493 (frame-visible-p menu-frame))))
1495 (defun menu-bar-non-minibuffer-window-p ()
1496 "Return non-nil if selected window of the menu frame is not a minibuf window.
1498 See the documentation of `menu-bar-menu-frame-live-and-visible-p'
1499 for the definition of the menu frame."
1500 (let ((menu-frame (or menu-updating-frame (selected-frame))))
1501 (not (window-minibuffer-p (frame-selected-window menu-frame)))))
1503 (defun kill-this-buffer () ; for the menu bar
1504 "Kill the current buffer.
1505 When called in the minibuffer, get out of the minibuffer
1506 using `abort-recursive-edit'."
1508 (if (menu-bar-non-minibuffer-window-p)
1509 (kill-buffer (current-buffer))
1510 (abort-recursive-edit)))
1512 (defun kill-this-buffer-enabled-p ()
1514 (buffers (buffer-list)))
1516 (or (string-match "^ " (buffer-name (car buffers)))
1517 (setq count (1+ count)))
1518 (setq buffers (cdr buffers)))
1519 (or (not (menu-bar-non-minibuffer-window-p))
1522 (put 'dired 'menu-enable '(menu-bar-non-minibuffer-window-p))
1524 ;; Permit deleting frame if it would leave a visible or iconified frame.
1525 (defun delete-frame-enabled-p ()
1526 "Return non-nil if `delete-frame' should be enabled in the menu bar."
1527 (let ((frames (frame-list))
1530 (if (frame-visible-p (car frames))
1531 (setq count (1+ count)))
1532 (setq frames (cdr frames)))
1535 (defcustom yank-menu-length 20
1536 "*Maximum length to display in the yank-menu."
1540 (defun menu-bar-update-yank-menu (string old)
1541 (let ((front (car (cdr yank-menu)))
1542 (menu-string (if (<= (length string) yank-menu-length)
1545 (substring string 0 (/ yank-menu-length 2))
1547 (substring string (- (/ yank-menu-length 2)))))))
1548 ;; Don't let the menu string be all dashes
1549 ;; because that has a special meaning in a menu.
1550 (if (string-match "\\`-+\\'" menu-string)
1551 (setq menu-string (concat menu-string " ")))
1552 ;; If we're supposed to be extending an existing string, and that
1553 ;; string really is at the front of the menu, then update it in place.
1554 (if (and old (or (eq old (car front))
1555 (string= old (car front))))
1557 (setcar front string)
1558 (setcar (cdr front) menu-string))
1561 (cons string (cons menu-string 'menu-bar-select-yank))
1563 (if (> (length (cdr yank-menu)) kill-ring-max)
1564 (setcdr (nthcdr kill-ring-max yank-menu) nil)))
1566 (put 'menu-bar-select-yank 'apropos-inhibit t)
1567 (defun menu-bar-select-yank ()
1568 "Insert the stretch of previously-killed text selected from menu.
1569 The menu shows all the killed text sequences stored in `kill-ring'."
1572 (insert last-command-event))
1577 (defcustom buffers-menu-max-size 10
1578 "*Maximum number of entries which may appear on the Buffers menu.
1579 If this is 10, then only the ten most-recently-selected buffers are shown.
1580 If this is nil, then all buffers are shown.
1581 A large number or nil slows down menu responsiveness."
1582 :type '(choice integer
1583 (const :tag "All" nil))
1586 (defcustom buffers-menu-buffer-name-length 30
1587 "*Maximum length of the buffer name on the Buffers menu.
1588 If this is a number, then buffer names are truncated to this length.
1589 If this is nil, then buffer names are shown in full.
1590 A large number or nil makes the menu too wide."
1591 :type '(choice integer
1592 (const :tag "Full length" nil))
1595 (defcustom buffers-menu-show-directories 'unless-uniquify
1596 "If non-nil, show directories in the Buffers menu for buffers that have them.
1597 The special value `unless-uniquify' means that directories will be shown
1598 unless `uniquify-buffer-name-style' is non-nil (in which case, buffer
1599 names should include enough of a buffer's directory to distinguish it
1600 from other buffers).
1602 Setting this variable directly does not take effect until next time the
1603 Buffers menu is regenerated."
1604 :set (lambda (symbol value)
1606 (menu-bar-update-buffers t))
1607 :initialize 'custom-initialize-default
1608 :type '(choice (const :tag "Never" nil)
1609 (const :tag "Unless uniquify is enabled" unless-uniquify)
1610 (const :tag "Always" t))
1613 (defcustom buffers-menu-show-status t
1614 "If non-nil, show modified/read-only status of buffers in the Buffers menu.
1615 Setting this variable directly does not take effect until next time the
1616 Buffers menu is regenerated."
1617 :set (lambda (symbol value)
1619 (menu-bar-update-buffers t))
1620 :initialize 'custom-initialize-default
1624 (defvar list-buffers-directory nil)
1626 (defun menu-bar-select-frame (frame)
1627 (make-frame-visible frame)
1629 (select-frame frame))
1631 (defun menu-bar-update-buffers-1 (elt)
1632 (let* ((buf (car elt))
1634 (and (if (eq buffers-menu-show-directories 'unless-uniquify)
1635 (or (not (boundp 'uniquify-buffer-name-style))
1636 (null uniquify-buffer-name-style))
1637 buffers-menu-show-directories)
1638 (or (buffer-file-name buf)
1639 (buffer-local-value 'list-buffers-directory buf)))))
1641 (setq file (file-name-directory file)))
1642 (when (and file (> (length file) 20))
1643 (setq file (concat "..." (substring file -17))))
1644 (cons (if buffers-menu-show-status
1645 (let ((mod (if (buffer-modified-p buf) "*" ""))
1646 (ro (if (buffer-local-value 'buffer-read-only buf) "%" "")))
1648 (format "%s %s%s -- %s" (cdr elt) mod ro file)
1649 (format "%s %s%s" (cdr elt) mod ro)))
1651 (format "%s -- %s" (cdr elt) file)
1655 ;; Used to cache the menu entries for commands in the Buffers menu
1656 (defvar menu-bar-buffers-menu-command-entries nil)
1658 (defun menu-bar-update-buffers (&optional force)
1659 ;; If user discards the Buffers item, play along.
1660 (and (lookup-key (current-global-map) [menu-bar buffer])
1661 (or force (frame-or-buffer-changed-p))
1662 (let ((buffers (buffer-list))
1663 (frames (frame-list))
1665 ;; If requested, list only the N most recently selected buffers.
1666 (if (and (integerp buffers-menu-max-size)
1667 (> buffers-menu-max-size 1))
1668 (if (> (length buffers) buffers-menu-max-size)
1669 (setcdr (nthcdr buffers-menu-max-size buffers) nil)))
1671 ;; Make the menu of buffers proper.
1674 ;; Put into each element of buffer-list
1675 ;; the name for actual display,
1676 ;; perhaps truncated in the middle.
1677 (dolist (buf buffers)
1678 (let ((name (buffer-name buf)))
1679 (unless (eq ?\s (aref name 0))
1680 (push (menu-bar-update-buffers-1
1682 (if (and (integerp buffers-menu-buffer-name-length)
1683 (> (length name) buffers-menu-buffer-name-length))
1686 name 0 (/ buffers-menu-buffer-name-length 2))
1689 name (- (/ buffers-menu-buffer-name-length 2))))
1693 ;; Now make the actual list of items.
1694 (let ((buffers-vec (make-vector (length alist) nil))
1696 (dolist (pair alist)
1699 (nconc (list (car pair)
1703 (switch-to-buffer ,(cdr pair))))))
1704 (list buffers-vec))))
1706 ;; Make a Frames menu if we have more than one frame.
1708 (let* ((frames-vec (make-vector (length frames) nil))
1711 (list "Select Frame" frames-vec)))
1713 (dolist (frame frames)
1717 (frame-parameter frame 'name)
1720 (interactive) (menu-bar-select-frame ,frame))))
1722 ;; Put it after the normal buffers
1725 `((frames-separator "--")
1726 (frames menu-item "Frames" ,frames-menu))))))
1728 ;; Add in some normal commands at the end of the menu. We use
1729 ;; the copy cached in `menu-bar-buffers-menu-command-entries'
1730 ;; if it's been set already. Note that we can't use constant
1731 ;; lists for the menu-entries, because the low-level menu-code
1733 (unless menu-bar-buffers-menu-command-entries
1734 (setq menu-bar-buffers-menu-command-entries
1735 (list '(command-separator "--")
1740 :help "Switch to the \"next\" buffer in a cyclic order")
1741 (list 'previous-buffer
1745 :help "Switch to the \"previous\" buffer in a cyclic order")
1746 (list 'select-named-buffer
1748 "Select Named Buffer..."
1750 :help "Prompt for a buffer name, and select that buffer in the current window")
1751 (list 'list-all-buffers
1755 :help "Pop up a window listing all Emacs buffers"
1758 (nconc buffers-menu menu-bar-buffers-menu-command-entries))
1760 ;; We used to "(define-key (current-global-map) [menu-bar buffer]"
1761 ;; but that did not do the right thing when the [menu-bar buffer]
1762 ;; entry above had been moved (e.g. to a parent keymap).
1763 (setcdr global-buffers-menu-map (cons "Select Buffer" buffers-menu)))))
1765 (add-hook 'menu-bar-update-hook 'menu-bar-update-buffers)
1767 (menu-bar-update-buffers)
1769 ;; this version is too slow
1770 ;;(defun format-buffers-menu-line (buffer)
1771 ;; "Returns a string to represent the given buffer in the Buffer menu.
1772 ;;nil means the buffer shouldn't be listed. You can redefine this."
1773 ;; (if (string-match "\\` " (buffer-name buffer))
1776 ;; (set-buffer buffer)
1777 ;; (let ((size (buffer-size)))
1778 ;; (format "%s%s %-19s %6s %-15s %s"
1779 ;; (if (buffer-modified-p) "*" " ")
1780 ;; (if buffer-read-only "%" " ")
1784 ;; (or (buffer-file-name) ""))))))
1786 ;;; Set up a menu bar menu for the minibuffer.
1788 (dolist (map (list minibuffer-local-map
1789 ;; This shouldn't be necessary, but there's a funny
1790 ;; bug in keymap.c that I don't understand yet. -stef
1791 minibuffer-local-completion-map))
1792 (define-key map [menu-bar minibuf]
1793 (cons "Minibuf" (make-sparse-keymap "Minibuf"))))
1795 (let ((map minibuffer-local-completion-map))
1796 (define-key map [menu-bar minibuf ?\?]
1797 (list 'menu-item "List Completions" 'minibuffer-completion-help
1798 :help "Display all possible completions"))
1799 (define-key map [menu-bar minibuf space]
1800 (list 'menu-item "Complete Word" 'minibuffer-complete-word
1801 :help "Complete at most one word"))
1802 (define-key map [menu-bar minibuf tab]
1803 (list 'menu-item "Complete" 'minibuffer-complete
1804 :help "Complete as far as possible")))
1806 (let ((map minibuffer-local-map))
1807 (define-key map [menu-bar minibuf quit]
1808 (list 'menu-item "Quit" 'abort-recursive-edit
1809 :help "Abort input and exit minibuffer"))
1810 (define-key map [menu-bar minibuf return]
1811 (list 'menu-item "Enter" 'exit-minibuffer
1813 :help "Terminate input and exit minibuffer"))
1814 (define-key map [menu-bar minibuf isearch-forward]
1815 (list 'menu-item "Isearch History Forward" 'isearch-forward
1816 :help "Incrementally search minibuffer history forward"))
1817 (define-key map [menu-bar minibuf isearch-backward]
1818 (list 'menu-item "Isearch History Backward" 'isearch-backward
1819 :help "Incrementally search minibuffer history backward"))
1820 (define-key map [menu-bar minibuf next]
1821 (list 'menu-item "Next History Item" 'next-history-element
1822 :help "Put next minibuffer history element in the minibuffer"))
1823 (define-key map [menu-bar minibuf previous]
1824 (list 'menu-item "Previous History Item" 'previous-history-element
1825 :help "Put previous minibuffer history element in the minibuffer")))
1828 ;; This comment is taken from tool-bar.el near
1829 ;; (put 'tool-bar-mode ...)
1830 ;; We want to pretend the menu bar by standard is on, as this will make
1831 ;; customize consider disabling the menu bar a customization, and save
1832 ;; that. We could do this for real by setting :init-value below, but
1833 ;; that would overwrite disabling the tool bar from X resources.
1834 (put 'menu-bar-mode 'standard-value '(t))
1836 (define-minor-mode menu-bar-mode
1837 "Toggle display of a menu bar on each frame.
1838 This command applies to all frames that exist and frames to be
1839 created in the future.
1840 With a numeric argument, if the argument is positive,
1841 turn on menu bars; otherwise, turn off menu bars."
1846 ;; Make menu-bar-mode and default-frame-alist consistent.
1847 (modify-all-frames-parameters (list (cons 'menu-bar-lines
1848 (if menu-bar-mode 1 0))))
1850 ;; Make the message appear when Emacs is idle. We can not call message
1851 ;; directly. The minor-mode message "Menu-bar mode disabled" comes
1852 ;; after this function returns, overwriting any message we do here.
1853 (when (and (interactive-p) (not menu-bar-mode))
1854 (run-with-idle-timer 0 nil 'message
1855 "Menu-bar mode disabled. Use M-x menu-bar-mode to make the menu bar appear."))
1858 (defun toggle-menu-bar-mode-from-frame (&optional arg)
1859 "Toggle menu bar on or off, based on the status of the current frame.
1860 See `menu-bar-mode' for more information."
1861 (interactive (list (or current-prefix-arg 'toggle)))
1862 (if (eq arg 'toggle)
1863 (menu-bar-mode (if (> (frame-parameter nil 'menu-bar-lines) 0) 0 1))
1864 (menu-bar-mode arg)))
1866 (declare-function x-menu-bar-open "term/x-win" (&optional frame))
1868 (defun menu-bar-open (&optional frame)
1869 "Start key navigation of the menu bar in FRAME.
1871 This function decides which method to use to access the menu
1872 depending on FRAME's terminal device. On X displays, it calls
1873 `x-menu-bar-open'; otherwise it calls `tmm-menubar'.
1875 If FRAME is nil or not given, use the selected frame."
1877 (if (eq window-system 'x)
1878 (x-menu-bar-open frame)
1879 (with-selected-frame (or frame (selected-frame))
1882 (global-set-key [f10] 'menu-bar-open)
1886 ;; arch-tag: 6e6a3c22-4ec4-4d3d-8190-583f8ef94ced
1887 ;;; menu-bar.el ends here