* etc/CONTRIBUTE: Expand a bit on copyright assignments.
[emacs.git] / lisp / menu-bar.el
blob1f57601a71122b44cbd6ab25f7682f9d5690595d
1 ;;; menu-bar.el --- define a default menu bar
3 ;; Copyright (C) 1993-1995, 2000-2012 Free Software Foundation, Inc.
5 ;; Author: RMS
6 ;; Maintainer: FSF
7 ;; Keywords: internal, mouse
8 ;; Package: emacs
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.
27 ;;; Commentary:
29 ;;; Code:
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 (if (not (featurep 'ns))
44 ;; Force Help item to come last, after the major mode's own items.
45 ;; The symbol used to be called `help', but that gets confused with the
46 ;; help key.
47 (setq menu-bar-final-items '(help-menu))
48 (if (eq system-type 'darwin)
49 (setq menu-bar-final-items '(buffer services help-menu))
50 (setq menu-bar-final-items '(buffer services hide-app quit))
51 ;; Add standard top-level items to GNUstep menu.
52 (define-key global-map [menu-bar quit]
53 `(menu-item ,(purecopy "Quit") save-buffers-kill-emacs
54 :help ,(purecopy "Save unsaved buffers, then exit")))
55 (define-key global-map [menu-bar hide-app]
56 `(menu-item ,(purecopy "Hide") ns-do-hide-emacs
57 :help ,(purecopy "Hide Emacs"))))
58 (define-key global-map [menu-bar services] ; set-up in ns-win
59 (cons (purecopy "Services") (make-sparse-keymap "Services"))))
61 ;; This definition is just to show what this looks like.
62 ;; It gets modified in place when menu-bar-update-buffers is called.
63 (defvar global-buffers-menu-map (make-sparse-keymap "Buffers"))
65 ;; Only declared obsolete (and only made a proper alias) in 23.3.
66 (define-obsolete-variable-alias
67 'menu-bar-files-menu 'menu-bar-file-menu "22.1")
68 (defvar menu-bar-file-menu
69 (let ((menu (make-sparse-keymap "File")))
71 ;; The "File" menu items
72 (define-key menu [exit-emacs]
73 `(menu-item ,(purecopy "Quit") save-buffers-kill-terminal
74 :help ,(purecopy "Save unsaved buffers, then exit")))
76 (define-key menu [separator-exit]
77 menu-bar-separator)
79 ;; Don't use delete-frame as event name because that is a special
80 ;; event.
81 (define-key menu [delete-this-frame]
82 `(menu-item ,(purecopy "Delete Frame") delete-frame
83 :visible (fboundp 'delete-frame)
84 :enable (delete-frame-enabled-p)
85 :help ,(purecopy "Delete currently selected frame")))
86 (define-key menu [make-frame-on-display]
87 `(menu-item ,(purecopy "New Frame on Display...") make-frame-on-display
88 :visible (fboundp 'make-frame-on-display)
89 :help ,(purecopy "Open a new frame on another display")))
90 (define-key menu [make-frame]
91 `(menu-item ,(purecopy "New Frame") make-frame-command
92 :visible (fboundp 'make-frame-command)
93 :help ,(purecopy "Open a new frame")))
95 (define-key menu [separator-frame]
96 menu-bar-separator)
98 (define-key menu [one-window]
99 `(menu-item ,(purecopy "Remove Other Windows") delete-other-windows
100 :enable (not (one-window-p t nil))
101 :help ,(purecopy "Make selected window fill whole frame")))
103 (define-key menu [new-window-on-right]
104 `(menu-item ,(purecopy "New Window on Right") split-window-right
105 :enable (and (menu-bar-menu-frame-live-and-visible-p)
106 (menu-bar-non-minibuffer-window-p))
107 :help ,(purecopy "Make new window on right of selected one")))
109 (define-key menu [new-window-below]
110 `(menu-item ,(purecopy "New Window Below") split-window-below
111 :enable (and (menu-bar-menu-frame-live-and-visible-p)
112 (menu-bar-non-minibuffer-window-p))
113 :help ,(purecopy "Make new window below selected one")))
115 (define-key menu [separator-window]
116 menu-bar-separator)
118 (define-key menu [ps-print-region]
119 `(menu-item ,(purecopy "PostScript Print Region (B+W)") ps-print-region
120 :enable mark-active
121 :help ,(purecopy "Pretty-print marked region in black and white to PostScript printer")))
122 (define-key menu [ps-print-buffer]
123 `(menu-item ,(purecopy "PostScript Print Buffer (B+W)") ps-print-buffer
124 :enable (menu-bar-menu-frame-live-and-visible-p)
125 :help ,(purecopy "Pretty-print current buffer in black and white to PostScript printer")))
126 (define-key menu [ps-print-region-faces]
127 `(menu-item ,(purecopy "PostScript Print Region")
128 ps-print-region-with-faces
129 :enable mark-active
130 :help ,(purecopy
131 "Pretty-print marked region to PostScript printer")))
132 (define-key menu [ps-print-buffer-faces]
133 `(menu-item ,(purecopy "PostScript Print Buffer")
134 ps-print-buffer-with-faces
135 :enable (menu-bar-menu-frame-live-and-visible-p)
136 :help ,(purecopy "Pretty-print current buffer to PostScript printer")))
137 (define-key menu [print-region]
138 `(menu-item ,(purecopy "Print Region") print-region
139 :enable mark-active
140 :help ,(purecopy "Print region between mark and current position")))
141 (define-key menu [print-buffer]
142 `(menu-item ,(purecopy "Print Buffer") print-buffer
143 :enable (menu-bar-menu-frame-live-and-visible-p)
144 :help ,(purecopy "Print current buffer with page headings")))
146 (define-key menu [separator-print]
147 menu-bar-separator)
149 (define-key menu [recover-session]
150 `(menu-item ,(purecopy "Recover Crashed Session") recover-session
151 :enable
152 (and auto-save-list-file-prefix
153 (file-directory-p
154 (file-name-directory auto-save-list-file-prefix))
155 (directory-files
156 (file-name-directory auto-save-list-file-prefix)
158 (concat "\\`"
159 (regexp-quote
160 (file-name-nondirectory
161 auto-save-list-file-prefix)))
163 :help ,(purecopy "Recover edits from a crashed session")))
164 (define-key menu [revert-buffer]
165 `(menu-item ,(purecopy "Revert Buffer") revert-buffer
166 :enable (or revert-buffer-function
167 revert-buffer-insert-file-contents-function
168 (and buffer-file-number
169 (or (buffer-modified-p)
170 (not (verify-visited-file-modtime
171 (current-buffer))))))
172 :help ,(purecopy "Re-read current buffer from its file")))
173 (define-key menu [write-file]
174 `(menu-item ,(purecopy "Save As...") write-file
175 :enable (and (menu-bar-menu-frame-live-and-visible-p)
176 (menu-bar-non-minibuffer-window-p))
177 :help ,(purecopy "Write current buffer to another file")))
178 (define-key menu [save-buffer]
179 `(menu-item ,(purecopy "Save") save-buffer
180 :enable (and (buffer-modified-p)
181 (buffer-file-name)
182 (menu-bar-non-minibuffer-window-p))
183 :help ,(purecopy "Save current buffer to its file")))
185 (define-key menu [separator-save]
186 menu-bar-separator)
189 (define-key menu [kill-buffer]
190 `(menu-item ,(purecopy "Close") kill-this-buffer
191 :enable (kill-this-buffer-enabled-p)
192 :help ,(purecopy "Discard (kill) current buffer")))
193 (define-key menu [insert-file]
194 `(menu-item ,(purecopy "Insert File...") insert-file
195 :enable (menu-bar-non-minibuffer-window-p)
196 :help ,(purecopy "Insert another file into current buffer")))
197 (define-key menu [dired]
198 `(menu-item ,(purecopy "Open Directory...") dired
199 :enable (menu-bar-non-minibuffer-window-p)
200 :help ,(purecopy
201 "Read a directory, to operate on its files")))
202 (define-key menu [open-file]
203 `(menu-item ,(purecopy "Open File...") menu-find-file-existing
204 :enable (menu-bar-non-minibuffer-window-p)
205 :help ,(purecopy
206 "Read an existing file into an Emacs buffer")))
207 (define-key menu [new-file]
208 `(menu-item ,(purecopy "Visit New File...") find-file
209 :enable (menu-bar-non-minibuffer-window-p)
210 :help ,(purecopy
211 "Specify a new file's name, to edit the file")))
213 menu))
215 (defun menu-find-file-existing ()
216 "Edit the existing file FILENAME."
217 (interactive)
218 (let* ((mustmatch (not (and (fboundp 'x-uses-old-gtk-dialog)
219 (x-uses-old-gtk-dialog))))
220 (filename (car (find-file-read-args "Find file: " mustmatch))))
221 (if mustmatch
222 (find-file-existing filename)
223 (find-file filename))))
225 ;; The "Edit->Search" submenu
226 (defvar menu-bar-last-search-type nil
227 "Type of last non-incremental search command called from the menu.")
229 (defun nonincremental-repeat-search-forward ()
230 "Search forward for the previous search string or regexp."
231 (interactive)
232 (cond
233 ((and (eq menu-bar-last-search-type 'string)
234 search-ring)
235 (search-forward (car search-ring)))
236 ((and (eq menu-bar-last-search-type 'regexp)
237 regexp-search-ring)
238 (re-search-forward (car regexp-search-ring)))
240 (error "No previous search"))))
242 (defun nonincremental-repeat-search-backward ()
243 "Search backward for the previous search string or regexp."
244 (interactive)
245 (cond
246 ((and (eq menu-bar-last-search-type 'string)
247 search-ring)
248 (search-backward (car search-ring)))
249 ((and (eq menu-bar-last-search-type 'regexp)
250 regexp-search-ring)
251 (re-search-backward (car regexp-search-ring)))
253 (error "No previous search"))))
255 (defun nonincremental-search-forward (string)
256 "Read a string and search for it nonincrementally."
257 (interactive "sSearch for string: ")
258 (setq menu-bar-last-search-type 'string)
259 (if (equal string "")
260 (search-forward (car search-ring))
261 (isearch-update-ring string nil)
262 (search-forward string)))
264 (defun nonincremental-search-backward (string)
265 "Read a string and search backward for it nonincrementally."
266 (interactive "sSearch for string: ")
267 (setq menu-bar-last-search-type 'string)
268 (if (equal string "")
269 (search-backward (car search-ring))
270 (isearch-update-ring string nil)
271 (search-backward string)))
273 (defun nonincremental-re-search-forward (string)
274 "Read a regular expression and search for it nonincrementally."
275 (interactive "sSearch for regexp: ")
276 (setq menu-bar-last-search-type 'regexp)
277 (if (equal string "")
278 (re-search-forward (car regexp-search-ring))
279 (isearch-update-ring string t)
280 (re-search-forward string)))
282 (defun nonincremental-re-search-backward (string)
283 "Read a regular expression and search backward for it nonincrementally."
284 (interactive "sSearch for regexp: ")
285 (setq menu-bar-last-search-type 'regexp)
286 (if (equal string "")
287 (re-search-backward (car regexp-search-ring))
288 (isearch-update-ring string t)
289 (re-search-backward string)))
291 ;; The Edit->Search->Incremental Search menu
292 (defvar menu-bar-i-search-menu
293 (let ((menu (make-sparse-keymap "Incremental Search")))
294 (define-key menu [isearch-backward-regexp]
295 `(menu-item ,(purecopy "Backward Regexp...") isearch-backward-regexp
296 :help ,(purecopy
297 "Search backwards for a regular expression as you type it")))
298 (define-key menu [isearch-forward-regexp]
299 `(menu-item ,(purecopy "Forward Regexp...") isearch-forward-regexp
300 :help ,(purecopy
301 "Search forward for a regular expression as you type it")))
302 (define-key menu [isearch-backward]
303 `(menu-item ,(purecopy "Backward String...") isearch-backward
304 :help ,(purecopy "Search backwards for a string as you type it")))
305 (define-key menu [isearch-forward]
306 `(menu-item ,(purecopy "Forward String...") isearch-forward
307 :help ,(purecopy "Search forward for a string as you type it")))
308 menu))
310 (defvar menu-bar-search-menu
311 (let ((menu (make-sparse-keymap "Search")))
313 (define-key menu [i-search]
314 `(menu-item ,(purecopy "Incremental Search") ,menu-bar-i-search-menu))
315 (define-key menu [separator-tag-isearch]
316 menu-bar-separator)
318 (define-key menu [tags-continue]
319 `(menu-item ,(purecopy "Continue Tags Search") tags-loop-continue
320 :help ,(purecopy "Continue last tags search operation")))
321 (define-key menu [tags-srch]
322 `(menu-item ,(purecopy "Search Tagged Files...") tags-search
323 :help ,(purecopy "Search for a regexp in all tagged files")))
324 (define-key menu [separator-tag-search] menu-bar-separator)
326 (define-key menu [repeat-search-back]
327 `(menu-item ,(purecopy "Repeat Backwards")
328 nonincremental-repeat-search-backward
329 :enable (or (and (eq menu-bar-last-search-type 'string)
330 search-ring)
331 (and (eq menu-bar-last-search-type 'regexp)
332 regexp-search-ring))
333 :help ,(purecopy "Repeat last search backwards")))
334 (define-key menu [repeat-search-fwd]
335 `(menu-item ,(purecopy "Repeat Forward")
336 nonincremental-repeat-search-forward
337 :enable (or (and (eq menu-bar-last-search-type 'string)
338 search-ring)
339 (and (eq menu-bar-last-search-type 'regexp)
340 regexp-search-ring))
341 :help ,(purecopy "Repeat last search forward")))
342 (define-key menu [separator-repeat-search]
343 menu-bar-separator)
345 (define-key menu [re-search-backward]
346 `(menu-item ,(purecopy "Regexp Backwards...")
347 nonincremental-re-search-backward
348 :help ,(purecopy
349 "Search backwards for a regular expression")))
350 (define-key menu [re-search-forward]
351 `(menu-item ,(purecopy "Regexp Forward...")
352 nonincremental-re-search-forward
353 :help ,(purecopy "Search forward for a regular expression")))
355 (define-key menu [search-backward]
356 `(menu-item ,(purecopy "String Backwards...")
357 nonincremental-search-backward
358 :help ,(purecopy "Search backwards for a string")))
359 (define-key menu [search-forward]
360 `(menu-item ,(purecopy "String Forward...") nonincremental-search-forward
361 :help ,(purecopy "Search forward for a string")))
362 menu))
364 ;; The Edit->Replace submenu
366 (defvar menu-bar-replace-menu
367 (let ((menu (make-sparse-keymap "Replace")))
368 (define-key menu [tags-repl-continue]
369 `(menu-item ,(purecopy "Continue Replace") tags-loop-continue
370 :help ,(purecopy "Continue last tags replace operation")))
371 (define-key menu [tags-repl]
372 `(menu-item ,(purecopy "Replace in Tagged Files...") tags-query-replace
373 :help ,(purecopy
374 "Interactively replace a regexp in all tagged files")))
375 (define-key menu [separator-replace-tags]
376 menu-bar-separator)
378 (define-key menu [query-replace-regexp]
379 `(menu-item ,(purecopy "Replace Regexp...") query-replace-regexp
380 :enable (not buffer-read-only)
381 :help ,(purecopy "Replace regular expression interactively, ask about each occurrence")))
382 (define-key menu [query-replace]
383 `(menu-item ,(purecopy "Replace String...") query-replace
384 :enable (not buffer-read-only)
385 :help ,(purecopy
386 "Replace string interactively, ask about each occurrence")))
387 menu))
389 ;;; Assemble the top-level Edit menu items.
390 (defvar menu-bar-goto-menu
391 (let ((menu (make-sparse-keymap "Go To")))
393 (define-key menu [set-tags-name]
394 `(menu-item ,(purecopy "Set Tags File Name...") visit-tags-table
395 :help ,(purecopy "Tell Tags commands which tag table file to use")))
397 (define-key menu [separator-tag-file]
398 menu-bar-separator)
400 (define-key menu [apropos-tags]
401 `(menu-item ,(purecopy "Tags Apropos...") tags-apropos
402 :help ,(purecopy "Find function/variables whose names match regexp")))
403 (define-key menu [next-tag-otherw]
404 `(menu-item ,(purecopy "Next Tag in Other Window")
405 menu-bar-next-tag-other-window
406 :enable (and (boundp 'tags-location-ring)
407 (not (ring-empty-p tags-location-ring)))
408 :help ,(purecopy "Find next function/variable matching last tag name in another window")))
410 (define-key menu [next-tag]
411 `(menu-item ,(purecopy "Find Next Tag")
412 menu-bar-next-tag
413 :enable (and (boundp 'tags-location-ring)
414 (not (ring-empty-p tags-location-ring)))
415 :help ,(purecopy "Find next function/variable matching last tag name")))
416 (define-key menu [find-tag-otherw]
417 `(menu-item ,(purecopy "Find Tag in Other Window...") find-tag-other-window
418 :help ,(purecopy "Find function/variable definition in another window")))
419 (define-key menu [find-tag]
420 `(menu-item ,(purecopy "Find Tag...") find-tag
421 :help ,(purecopy "Find definition of function or variable")))
423 (define-key menu [separator-tags]
424 menu-bar-separator)
426 (define-key menu [end-of-buf]
427 `(menu-item ,(purecopy "Goto End of Buffer") end-of-buffer))
428 (define-key menu [beg-of-buf]
429 `(menu-item ,(purecopy "Goto Beginning of Buffer") beginning-of-buffer))
430 (define-key menu [go-to-pos]
431 `(menu-item ,(purecopy "Goto Buffer Position...") goto-char
432 :help ,(purecopy "Read a number N and go to buffer position N")))
433 (define-key menu [go-to-line]
434 `(menu-item ,(purecopy "Goto Line...") goto-line
435 :help ,(purecopy "Read a line number and go to that line")))
436 menu))
439 (defvar yank-menu (cons (purecopy "Select Yank") nil))
440 (fset 'yank-menu (cons 'keymap yank-menu))
442 (defvar menu-bar-edit-menu
443 (let ((menu (make-sparse-keymap "Edit")))
445 (define-key menu [props]
446 `(menu-item ,(purecopy "Text Properties") facemenu-menu))
448 ;; ns-win.el said: Add spell for platform consistency.
449 (if (featurep 'ns)
450 (define-key menu [spell]
451 `(menu-item ,(purecopy "Spell") ispell-menu-map)))
453 (define-key menu [fill]
454 `(menu-item ,(purecopy "Fill") fill-region
455 :enable (and mark-active (not buffer-read-only))
456 :help
457 ,(purecopy "Fill text in region to fit between left and right margin")))
459 (define-key menu [separator-bookmark]
460 menu-bar-separator)
462 (define-key menu [bookmark]
463 `(menu-item ,(purecopy "Bookmarks") menu-bar-bookmark-map))
465 (define-key menu [goto]
466 `(menu-item ,(purecopy "Go To") ,menu-bar-goto-menu))
468 (define-key menu [replace]
469 `(menu-item ,(purecopy "Replace") ,menu-bar-replace-menu))
471 (define-key menu [search]
472 `(menu-item ,(purecopy "Search") ,menu-bar-search-menu))
474 (define-key menu [separator-search]
475 menu-bar-separator)
477 (define-key menu [mark-whole-buffer]
478 `(menu-item ,(purecopy "Select All") mark-whole-buffer
479 :help ,(purecopy "Mark the whole buffer for a subsequent cut/copy")))
480 (define-key menu [clear]
481 `(menu-item ,(purecopy "Clear") delete-region
482 :enable (and mark-active
483 (not buffer-read-only))
484 :help
485 ,(purecopy "Delete the text in region between mark and current position")))
488 (define-key menu (if (featurep 'ns) [select-paste]
489 [paste-from-menu])
490 ;; ns-win.el said: Change text to be more consistent with
491 ;; surrounding menu items `paste', etc."
492 `(menu-item ,(purecopy (if (featurep 'ns) "Select and Paste"
493 "Paste from Kill Menu")) yank-menu
494 :enable (and (cdr yank-menu) (not buffer-read-only))
495 :help ,(purecopy "Choose a string from the kill ring and paste it")))
496 (define-key menu [paste]
497 `(menu-item ,(purecopy "Paste") yank
498 :enable (and (or
499 ;; Emacs compiled --without-x (or --with-ns)
500 ;; doesn't have x-selection-exists-p.
501 (and (fboundp 'x-selection-exists-p)
502 (x-selection-exists-p 'CLIPBOARD))
503 (if (featurep 'ns) ; like paste-from-menu
504 (cdr yank-menu)
505 kill-ring))
506 (not buffer-read-only))
507 :help ,(purecopy "Paste (yank) text most recently cut/copied")))
508 (define-key menu [copy]
509 ;; ns-win.el said: Substitute a Copy function that works better
510 ;; under X (for GNUstep).
511 `(menu-item ,(purecopy "Copy") ,(if (featurep 'ns)
512 'ns-copy-including-secondary
513 'kill-ring-save)
514 :enable mark-active
515 :help ,(purecopy "Copy text in region between mark and current position")
516 :keys ,(purecopy (if (featurep 'ns)
517 "\\[ns-copy-including-secondary]"
518 "\\[kill-ring-save]"))))
519 (define-key menu [cut]
520 `(menu-item ,(purecopy "Cut") kill-region
521 :enable (and mark-active (not buffer-read-only))
522 :help
523 ,(purecopy "Cut (kill) text in region between mark and current position")))
524 ;; ns-win.el said: Separate undo from cut/paste section.
525 (if (featurep 'ns)
526 (define-key menu [separator-undo] menu-bar-separator))
528 (define-key menu [undo]
529 `(menu-item ,(purecopy "Undo") undo
530 :enable (and (not buffer-read-only)
531 (not (eq t buffer-undo-list))
532 (if (eq last-command 'undo)
533 (listp pending-undo-list)
534 (consp buffer-undo-list)))
535 :help ,(purecopy "Undo last operation")))
537 menu))
539 (defun menu-bar-next-tag-other-window ()
540 "Find the next definition of the tag already specified."
541 (interactive)
542 (find-tag-other-window nil t))
544 (defun menu-bar-next-tag ()
545 "Find the next definition of the tag already specified."
546 (interactive)
547 (find-tag nil t))
549 (define-obsolete-function-alias
550 'menu-bar-kill-ring-save 'kill-ring-save "24.1")
552 ;; These are alternative definitions for the cut, paste and copy
553 ;; menu items. Use them if your system expects these to use the clipboard.
555 (put 'clipboard-kill-region 'menu-enable
556 '(and mark-active (not buffer-read-only)))
557 (put 'clipboard-kill-ring-save 'menu-enable 'mark-active)
558 (put 'clipboard-yank 'menu-enable
559 '(and (or (not (fboundp 'x-selection-exists-p))
560 (x-selection-exists-p)
561 (x-selection-exists-p 'CLIPBOARD))
562 (not buffer-read-only)))
564 (defun clipboard-yank ()
565 "Insert the clipboard contents, or the last stretch of killed text."
566 (interactive "*")
567 (let ((x-select-enable-clipboard t))
568 (yank)))
570 (defun clipboard-kill-ring-save (beg end)
571 "Copy region to kill ring, and save in the X clipboard."
572 (interactive "r")
573 (let ((x-select-enable-clipboard t))
574 (kill-ring-save beg end)))
576 (defun clipboard-kill-region (beg end)
577 "Kill the region, and save it in the X clipboard."
578 (interactive "r")
579 (let ((x-select-enable-clipboard t))
580 (kill-region beg end)))
582 (defun menu-bar-enable-clipboard ()
583 "Make CUT, PASTE and COPY (keys and menu bar items) use the clipboard.
584 Do the same for the keys of the same name."
585 (interactive)
586 ;; These are Sun server keysyms for the Cut, Copy and Paste keys
587 ;; (also for XFree86 on Sun keyboard):
588 (define-key global-map [f20] 'clipboard-kill-region)
589 (define-key global-map [f16] 'clipboard-kill-ring-save)
590 (define-key global-map [f18] 'clipboard-yank)
591 ;; X11R6 versions:
592 (define-key global-map [cut] 'clipboard-kill-region)
593 (define-key global-map [copy] 'clipboard-kill-ring-save)
594 (define-key global-map [paste] 'clipboard-yank))
596 ;; The "Options" menu items
598 (defvar menu-bar-custom-menu
599 (let ((menu (make-sparse-keymap "Customize")))
601 (define-key menu [customize-apropos-faces]
602 `(menu-item ,(purecopy "Faces Matching...") customize-apropos-faces
603 :help ,(purecopy "Browse faces matching a regexp or word list")))
604 (define-key menu [customize-apropos-options]
605 `(menu-item ,(purecopy "Options Matching...") customize-apropos-options
606 :help ,(purecopy "Browse options matching a regexp or word list")))
607 (define-key menu [customize-apropos]
608 `(menu-item ,(purecopy "All Settings Matching...") customize-apropos
609 :help ,(purecopy "Browse customizable settings matching a regexp or word list")))
610 (define-key menu [separator-1]
611 menu-bar-separator)
612 (define-key menu [customize-group]
613 `(menu-item ,(purecopy "Specific Group...") customize-group
614 :help ,(purecopy "Customize settings of specific group")))
615 (define-key menu [customize-face]
616 `(menu-item ,(purecopy "Specific Face...") customize-face
617 :help ,(purecopy "Customize attributes of specific face")))
618 (define-key menu [customize-option]
619 `(menu-item ,(purecopy "Specific Option...") customize-option
620 :help ,(purecopy "Customize value of specific option")))
621 (define-key menu [separator-2]
622 menu-bar-separator)
623 (define-key menu [customize-changed-options]
624 `(menu-item ,(purecopy "New Options...") customize-changed-options
625 :help ,(purecopy "Options added or changed in recent Emacs versions")))
626 (define-key menu [customize-saved]
627 `(menu-item ,(purecopy "Saved Options") customize-saved
628 :help ,(purecopy "Customize previously saved options")))
629 (define-key menu [separator-3]
630 menu-bar-separator)
631 (define-key menu [customize-browse]
632 `(menu-item ,(purecopy "Browse Customization Groups") customize-browse
633 :help ,(purecopy "Browse all customization groups")))
634 (define-key menu [customize]
635 `(menu-item ,(purecopy "Top-level Customization Group") customize
636 :help ,(purecopy "The master group called `Emacs'")))
637 (define-key menu [customize-themes]
638 `(menu-item ,(purecopy "Custom Themes") customize-themes
639 :help ,(purecopy "Choose a pre-defined customization theme")))
640 menu))
641 ;(defvar menu-bar-preferences-menu (make-sparse-keymap "Preferences"))
643 (defmacro menu-bar-make-mm-toggle (fname doc help &optional props)
644 "Make a menu-item for a global minor mode toggle.
645 FNAME is the minor mode's name (variable and function).
646 DOC is the text to use for the menu entry.
647 HELP is the text to use for the tooltip.
648 PROPS are additional properties."
649 `(list 'menu-item (purecopy ,doc) ',fname
650 ,@(mapcar (lambda (p) (list 'quote p)) props)
651 :help (purecopy ,help)
652 :button '(:toggle . (and (default-boundp ',fname)
653 (default-value ',fname)))))
655 (defmacro menu-bar-make-toggle (name variable doc message help &rest body)
656 `(progn
657 (defun ,name (&optional interactively)
658 ,(concat "Toggle whether to " (downcase (substring help 0 1))
659 (substring help 1) ".
660 In an interactive call, record this option as a candidate for saving
661 by \"Save Options\" in Custom buffers.")
662 (interactive "p")
663 (if ,(if body `(progn . ,body)
664 `(progn
665 (custom-load-symbol ',variable)
666 (let ((set (or (get ',variable 'custom-set) 'set-default))
667 (get (or (get ',variable 'custom-get) 'default-value)))
668 (funcall set ',variable (not (funcall get ',variable))))))
669 (message ,message "enabled globally")
670 (message ,message "disabled globally"))
671 ;; The function `customize-mark-as-set' must only be called when
672 ;; a variable is set interactively, as the purpose is to mark it as
673 ;; a candidate for "Save Options", and we do not want to save options
674 ;; the user have already set explicitly in his init file.
675 (if interactively (customize-mark-as-set ',variable)))
676 (list 'menu-item (purecopy ,doc) ',name
677 :help (purecopy ,help)
678 :button '(:toggle . (and (default-boundp ',variable)
679 (default-value ',variable))))))
681 ;; Function for setting/saving default font.
683 (defun menu-set-font ()
684 "Interactively select a font and make it the default."
685 (interactive)
686 (set-frame-font (if (fboundp 'x-select-font)
687 (x-select-font)
688 (mouse-select-font))
689 nil t))
691 (defun menu-bar-options-save ()
692 "Save current values of Options menu items using Custom."
693 (interactive)
694 (let ((need-save nil))
695 ;; These are set with menu-bar-make-mm-toggle, which does not
696 ;; put on a customized-value property.
697 (dolist (elt '(line-number-mode column-number-mode size-indication-mode
698 cua-mode show-paren-mode transient-mark-mode
699 blink-cursor-mode display-time-mode display-battery-mode
700 ;; These are set by other functions that don't set
701 ;; the customized state. Having them here has the
702 ;; side-effect that turning them off via X
703 ;; resources acts like having customized them, but
704 ;; that seems harmless.
705 menu-bar-mode tool-bar-mode))
706 ;; FIXME ? It's a little annoying that running this command
707 ;; always loads cua-base, paren, time, and battery, even if they
708 ;; have not been customized in any way. (Due to custom-load-symbol.)
709 (and (customize-mark-to-save elt)
710 (setq need-save t)))
711 ;; These are set with `customize-set-variable'.
712 (dolist (elt '(scroll-bar-mode
713 debug-on-quit debug-on-error
714 ;; Somehow this works, when tool-bar and menu-bar don't.
715 tooltip-mode
716 save-place uniquify-buffer-name-style fringe-mode
717 indicate-empty-lines indicate-buffer-boundaries
718 case-fold-search font-use-system-font
719 current-language-environment default-input-method
720 ;; Saving `text-mode-hook' is somewhat questionable,
721 ;; as we might get more than we bargain for, if
722 ;; other code may has added hooks as well.
723 ;; Nonetheless, not saving it would like be confuse
724 ;; more often.
725 ;; -- Per Abrahamsen <abraham@dina.kvl.dk> 2002-02-11.
726 text-mode-hook tool-bar-position))
727 (and (get elt 'customized-value)
728 (customize-mark-to-save elt)
729 (setq need-save t)))
730 (when (get 'default 'customized-face)
731 (put 'default 'saved-face (get 'default 'customized-face))
732 (put 'default 'customized-face nil)
733 (setq need-save t))
734 ;; Save if we changed anything.
735 (when need-save
736 (custom-save-all))))
739 ;;; Assemble all the top-level items of the "Options" menu
741 ;; The "Show/Hide" submenu of menu "Options"
743 (defun menu-bar-showhide-fringe-ind-customize ()
744 "Show customization buffer for `indicate-buffer-boundaries'."
745 (interactive)
746 (customize-variable 'indicate-buffer-boundaries))
748 (defun menu-bar-showhide-fringe-ind-mixed ()
749 "Display top and bottom indicators in opposite fringes, arrows in right."
750 (interactive)
751 (customize-set-variable 'indicate-buffer-boundaries
752 '((t . right) (top . left))))
754 (defun menu-bar-showhide-fringe-ind-box ()
755 "Display top and bottom indicators in opposite fringes."
756 (interactive)
757 (customize-set-variable 'indicate-buffer-boundaries
758 '((top . left) (bottom . right))))
760 (defun menu-bar-showhide-fringe-ind-right ()
761 "Display buffer boundaries and arrows in the right fringe."
762 (interactive)
763 (customize-set-variable 'indicate-buffer-boundaries 'right))
765 (defun menu-bar-showhide-fringe-ind-left ()
766 "Display buffer boundaries and arrows in the left fringe."
767 (interactive)
768 (customize-set-variable 'indicate-buffer-boundaries 'left))
770 (defun menu-bar-showhide-fringe-ind-none ()
771 "Do not display any buffer boundary indicators."
772 (interactive)
773 (customize-set-variable 'indicate-buffer-boundaries nil))
775 (defvar menu-bar-showhide-fringe-ind-menu
776 (let ((menu (make-sparse-keymap "Buffer boundaries")))
778 (define-key menu [customize]
779 `(menu-item ,(purecopy "Other (Customize)")
780 menu-bar-showhide-fringe-ind-customize
781 :help ,(purecopy "Additional choices available through Custom buffer")
782 :visible (display-graphic-p)
783 :button (:radio . (not (member indicate-buffer-boundaries
784 '(nil left right
785 ((top . left) (bottom . right))
786 ((t . right) (top . left))))))))
788 (define-key menu [mixed]
789 `(menu-item ,(purecopy "Opposite, Arrows Right") menu-bar-showhide-fringe-ind-mixed
790 :help
791 ,(purecopy "Show top/bottom indicators in opposite fringes, arrows in right")
792 :visible (display-graphic-p)
793 :button (:radio . (equal indicate-buffer-boundaries
794 '((t . right) (top . left))))))
796 (define-key menu [box]
797 `(menu-item ,(purecopy "Opposite, No Arrows") menu-bar-showhide-fringe-ind-box
798 :help ,(purecopy "Show top/bottom indicators in opposite fringes, no arrows")
799 :visible (display-graphic-p)
800 :button (:radio . (equal indicate-buffer-boundaries
801 '((top . left) (bottom . right))))))
803 (define-key menu [right]
804 `(menu-item ,(purecopy "In Right Fringe") menu-bar-showhide-fringe-ind-right
805 :help ,(purecopy "Show buffer boundaries and arrows in right fringe")
806 :visible (display-graphic-p)
807 :button (:radio . (eq indicate-buffer-boundaries 'right))))
809 (define-key menu [left]
810 `(menu-item ,(purecopy "In Left Fringe") menu-bar-showhide-fringe-ind-left
811 :help ,(purecopy "Show buffer boundaries and arrows in left fringe")
812 :visible (display-graphic-p)
813 :button (:radio . (eq indicate-buffer-boundaries 'left))))
815 (define-key menu [none]
816 `(menu-item ,(purecopy "No Indicators") menu-bar-showhide-fringe-ind-none
817 :help ,(purecopy "Hide all buffer boundary indicators and arrows")
818 :visible (display-graphic-p)
819 :button (:radio . (eq indicate-buffer-boundaries nil))))
820 menu))
822 (defun menu-bar-showhide-fringe-menu-customize ()
823 "Show customization buffer for `fringe-mode'."
824 (interactive)
825 (customize-variable 'fringe-mode))
827 (defun menu-bar-showhide-fringe-menu-customize-reset ()
828 "Reset the fringe mode: display fringes on both sides of a window."
829 (interactive)
830 (customize-set-variable 'fringe-mode nil))
832 (defun menu-bar-showhide-fringe-menu-customize-right ()
833 "Display fringes only on the right of each window."
834 (interactive)
835 (require 'fringe)
836 (customize-set-variable 'fringe-mode '(0 . nil)))
838 (defun menu-bar-showhide-fringe-menu-customize-left ()
839 "Display fringes only on the left of each window."
840 (interactive)
841 (require 'fringe)
842 (customize-set-variable 'fringe-mode '(nil . 0)))
844 (defun menu-bar-showhide-fringe-menu-customize-disable ()
845 "Do not display window fringes."
846 (interactive)
847 (require 'fringe)
848 (customize-set-variable 'fringe-mode 0))
850 (defvar menu-bar-showhide-fringe-menu
851 (let ((menu (make-sparse-keymap "Fringe")))
853 (define-key menu [showhide-fringe-ind]
854 `(menu-item ,(purecopy "Buffer Boundaries") ,menu-bar-showhide-fringe-ind-menu
855 :visible (display-graphic-p)
856 :help ,(purecopy "Indicate buffer boundaries in fringe")))
858 (define-key menu [indicate-empty-lines]
859 (menu-bar-make-toggle toggle-indicate-empty-lines indicate-empty-lines
860 "Empty Line Indicators"
861 "Indicating of empty lines %s"
862 "Indicate trailing empty lines in fringe, globally"))
864 (define-key menu [customize]
865 `(menu-item ,(purecopy "Customize Fringe") menu-bar-showhide-fringe-menu-customize
866 :help ,(purecopy "Detailed customization of fringe")
867 :visible (display-graphic-p)))
869 (define-key menu [default]
870 `(menu-item ,(purecopy "Default") menu-bar-showhide-fringe-menu-customize-reset
871 :help ,(purecopy "Default width fringe on both left and right side")
872 :visible (display-graphic-p)
873 :button (:radio . (eq fringe-mode nil))))
875 (define-key menu [right]
876 `(menu-item ,(purecopy "On the Right") menu-bar-showhide-fringe-menu-customize-right
877 :help ,(purecopy "Fringe only on the right side")
878 :visible (display-graphic-p)
879 :button (:radio . (equal fringe-mode '(0 . nil)))))
881 (define-key menu [left]
882 `(menu-item ,(purecopy "On the Left") menu-bar-showhide-fringe-menu-customize-left
883 :help ,(purecopy "Fringe only on the left side")
884 :visible (display-graphic-p)
885 :button (:radio . (equal fringe-mode '(nil . 0)))))
887 (define-key menu [none]
888 `(menu-item ,(purecopy "None") menu-bar-showhide-fringe-menu-customize-disable
889 :help ,(purecopy "Turn off fringe")
890 :visible (display-graphic-p)
891 :button (:radio . (eq fringe-mode 0))))
892 menu))
894 (defun menu-bar-right-scroll-bar ()
895 "Display scroll bars on the right of each window."
896 (interactive)
897 (customize-set-variable 'scroll-bar-mode 'right))
899 (defun menu-bar-left-scroll-bar ()
900 "Display scroll bars on the left of each window."
901 (interactive)
902 (customize-set-variable 'scroll-bar-mode 'left))
904 (defun menu-bar-no-scroll-bar ()
905 "Turn off scroll bars."
906 (interactive)
907 (customize-set-variable 'scroll-bar-mode nil))
909 (defvar menu-bar-showhide-scroll-bar-menu
910 (let ((menu (make-sparse-keymap "Scroll-bar")))
912 (define-key menu [right]
913 `(menu-item ,(purecopy "On the Right")
914 menu-bar-right-scroll-bar
915 :help ,(purecopy "Scroll-bar on the right side")
916 :visible (display-graphic-p)
917 :button (:radio . (eq (cdr (assq 'vertical-scroll-bars
918 (frame-parameters))) 'right))))
920 (define-key menu [left]
921 `(menu-item ,(purecopy "On the Left")
922 menu-bar-left-scroll-bar
923 :help ,(purecopy "Scroll-bar on the left side")
924 :visible (display-graphic-p)
925 :button (:radio . (eq (cdr (assq 'vertical-scroll-bars
926 (frame-parameters))) 'left))))
928 (define-key menu [none]
929 `(menu-item ,(purecopy "None")
930 menu-bar-no-scroll-bar
931 :help ,(purecopy "Turn off scroll-bar")
932 :visible (display-graphic-p)
933 :button (:radio . (eq (cdr (assq 'vertical-scroll-bars
934 (frame-parameters))) nil))))
935 menu))
937 (defun menu-bar-frame-for-menubar ()
938 "Return the frame suitable for updating the menu bar."
939 (or (and (framep menu-updating-frame)
940 menu-updating-frame)
941 (selected-frame)))
943 (defun menu-bar-positive-p (val)
944 "Return non-nil iff VAL is a positive number."
945 (and (numberp val)
946 (> val 0)))
948 (defun menu-bar-set-tool-bar-position (position)
949 (customize-set-variable 'tool-bar-mode t)
950 (customize-set-variable 'tool-bar-position position))
951 (defun menu-bar-showhide-tool-bar-menu-customize-disable ()
952 "Do not display tool bars."
953 (interactive)
954 (customize-set-variable 'tool-bar-mode nil))
955 (defun menu-bar-showhide-tool-bar-menu-customize-enable-left ()
956 "Display tool bars on the left side."
957 (interactive)
958 (menu-bar-set-tool-bar-position 'left))
959 (defun menu-bar-showhide-tool-bar-menu-customize-enable-right ()
960 "Display tool bars on the right side."
961 (interactive)
962 (menu-bar-set-tool-bar-position 'right))
963 (defun menu-bar-showhide-tool-bar-menu-customize-enable-top ()
964 "Display tool bars on the top side."
965 (interactive)
966 (menu-bar-set-tool-bar-position 'top))
967 (defun menu-bar-showhide-tool-bar-menu-customize-enable-bottom ()
968 "Display tool bars on the bottom side."
969 (interactive)
970 (menu-bar-set-tool-bar-position 'bottom))
972 (when (featurep 'move-toolbar)
973 (defvar menu-bar-showhide-tool-bar-menu
974 (let ((menu (make-sparse-keymap "Tool-bar")))
976 (define-key menu [showhide-tool-bar-left]
977 `(menu-item ,(purecopy "On the Left")
978 menu-bar-showhide-tool-bar-menu-customize-enable-left
979 :help ,(purecopy "Tool-bar at the left side")
980 :visible (display-graphic-p)
981 :button
982 (:radio . (and tool-bar-mode
983 (eq (frame-parameter
984 (menu-bar-frame-for-menubar)
985 'tool-bar-position)
986 'left)))))
988 (define-key menu [showhide-tool-bar-right]
989 `(menu-item ,(purecopy "On the Right")
990 menu-bar-showhide-tool-bar-menu-customize-enable-right
991 :help ,(purecopy "Tool-bar at the right side")
992 :visible (display-graphic-p)
993 :button
994 (:radio . (and tool-bar-mode
995 (eq (frame-parameter
996 (menu-bar-frame-for-menubar)
997 'tool-bar-position)
998 'right)))))
1000 (define-key menu [showhide-tool-bar-bottom]
1001 `(menu-item ,(purecopy "On the Bottom")
1002 menu-bar-showhide-tool-bar-menu-customize-enable-bottom
1003 :help ,(purecopy "Tool-bar at the bottom")
1004 :visible (display-graphic-p)
1005 :button
1006 (:radio . (and tool-bar-mode
1007 (eq (frame-parameter
1008 (menu-bar-frame-for-menubar)
1009 'tool-bar-position)
1010 'bottom)))))
1012 (define-key menu [showhide-tool-bar-top]
1013 `(menu-item ,(purecopy "On the Top")
1014 menu-bar-showhide-tool-bar-menu-customize-enable-top
1015 :help ,(purecopy "Tool-bar at the top")
1016 :visible (display-graphic-p)
1017 :button
1018 (:radio . (and tool-bar-mode
1019 (eq (frame-parameter
1020 (menu-bar-frame-for-menubar)
1021 'tool-bar-position)
1022 'top)))))
1024 (define-key menu [showhide-tool-bar-none]
1025 `(menu-item ,(purecopy "None")
1026 menu-bar-showhide-tool-bar-menu-customize-disable
1027 :help ,(purecopy "Turn tool-bar off")
1028 :visible (display-graphic-p)
1029 :button (:radio . (eq tool-bar-mode nil))))
1030 menu)))
1032 (defvar menu-bar-showhide-menu
1033 (let ((menu (make-sparse-keymap "Show/Hide")))
1035 (define-key menu [column-number-mode]
1036 (menu-bar-make-mm-toggle column-number-mode
1037 "Column Numbers"
1038 "Show the current column number in the mode line"))
1040 (define-key menu [line-number-mode]
1041 (menu-bar-make-mm-toggle line-number-mode
1042 "Line Numbers"
1043 "Show the current line number in the mode line"))
1045 (define-key menu [size-indication-mode]
1046 (menu-bar-make-mm-toggle size-indication-mode
1047 "Size Indication"
1048 "Show the size of the buffer in the mode line"))
1050 (define-key menu [linecolumn-separator]
1051 menu-bar-separator)
1053 (define-key menu [showhide-battery]
1054 (menu-bar-make-mm-toggle display-battery-mode
1055 "Battery Status"
1056 "Display battery status information in mode line"))
1058 (define-key menu [showhide-date-time]
1059 (menu-bar-make-mm-toggle display-time-mode
1060 "Time, Load and Mail"
1061 "Display time, system load averages and \
1062 mail status in mode line"))
1064 (define-key menu [datetime-separator]
1065 menu-bar-separator)
1067 (define-key menu [showhide-speedbar]
1068 `(menu-item ,(purecopy "Speedbar") speedbar-frame-mode
1069 :help ,(purecopy "Display a Speedbar quick-navigation frame")
1070 :button (:toggle
1071 . (and (boundp 'speedbar-frame)
1072 (frame-live-p (symbol-value 'speedbar-frame))
1073 (frame-visible-p
1074 (symbol-value 'speedbar-frame))))))
1076 (define-key menu [showhide-fringe]
1077 `(menu-item ,(purecopy "Fringe") ,menu-bar-showhide-fringe-menu
1078 :visible (display-graphic-p)))
1080 (define-key menu [showhide-scroll-bar]
1081 `(menu-item ,(purecopy "Scroll-bar") ,menu-bar-showhide-scroll-bar-menu
1082 :visible (display-graphic-p)))
1084 (define-key menu [showhide-tooltip-mode]
1085 `(menu-item ,(purecopy "Tooltips") tooltip-mode
1086 :help ,(purecopy "Turn tooltips on/off")
1087 :visible (and (display-graphic-p) (fboundp 'x-show-tip))
1088 :button (:toggle . tooltip-mode)))
1090 (define-key menu [menu-bar-mode]
1091 `(menu-item ,(purecopy "Menu-bar") toggle-menu-bar-mode-from-frame
1092 :help ,(purecopy "Turn menu-bar on/off")
1093 :button
1094 (:toggle . (menu-bar-positive-p
1095 (frame-parameter (menu-bar-frame-for-menubar)
1096 'menu-bar-lines)))))
1098 (if (and (boundp 'menu-bar-showhide-tool-bar-menu)
1099 (keymapp menu-bar-showhide-tool-bar-menu))
1100 (define-key menu [showhide-tool-bar]
1101 `(menu-item ,(purecopy "Tool-bar") ,menu-bar-showhide-tool-bar-menu
1102 :visible (display-graphic-p)))
1103 ;; else not tool bar that can move.
1104 (define-key menu [showhide-tool-bar]
1105 `(menu-item ,(purecopy "Tool-bar") toggle-tool-bar-mode-from-frame
1106 :help ,(purecopy "Turn tool-bar on/off")
1107 :visible (display-graphic-p)
1108 :button
1109 (:toggle . (menu-bar-positive-p
1110 (frame-parameter (menu-bar-frame-for-menubar)
1111 'tool-bar-lines))))))
1112 menu))
1114 (defun menu-bar-text-mode-auto-fill ()
1115 (interactive)
1116 (toggle-text-mode-auto-fill)
1117 ;; This is somewhat questionable, as `text-mode-hook'
1118 ;; might have changed outside customize.
1119 ;; -- Per Abrahamsen <abraham@dina.kvl.dk> 2002-02-11.
1120 (customize-mark-as-set 'text-mode-hook))
1123 (defvar menu-bar-line-wrapping-menu
1124 (let ((menu (make-sparse-keymap "Line Wrapping")))
1126 (define-key menu [word-wrap]
1127 `(menu-item
1128 ,(purecopy "Word Wrap (Visual Line mode)")
1129 (lambda ()
1130 (interactive)
1131 (unless visual-line-mode
1132 (visual-line-mode 1))
1133 (message ,(purecopy "Visual-Line mode enabled")))
1134 :help ,(purecopy "Wrap long lines at word boundaries")
1135 :button (:radio . (and (null truncate-lines)
1136 (not (truncated-partial-width-window-p))
1137 word-wrap))
1138 :visible (menu-bar-menu-frame-live-and-visible-p)))
1140 (define-key menu [truncate]
1141 `(menu-item ,(purecopy "Truncate Long Lines")
1142 (lambda ()
1143 (interactive)
1144 (if visual-line-mode (visual-line-mode 0))
1145 (setq word-wrap nil)
1146 (toggle-truncate-lines 1))
1147 :help ,(purecopy "Truncate long lines at window edge")
1148 :button (:radio . (or truncate-lines
1149 (truncated-partial-width-window-p)))
1150 :visible (menu-bar-menu-frame-live-and-visible-p)
1151 :enable (not (truncated-partial-width-window-p))))
1153 (define-key menu [window-wrap]
1154 `(menu-item ,(purecopy "Wrap at Window Edge")
1155 (lambda () (interactive)
1156 (if visual-line-mode (visual-line-mode 0))
1157 (setq word-wrap nil)
1158 (if truncate-lines (toggle-truncate-lines -1)))
1159 :help ,(purecopy "Wrap long lines at window edge")
1160 :button (:radio . (and (null truncate-lines)
1161 (not (truncated-partial-width-window-p))
1162 (not word-wrap)))
1163 :visible (menu-bar-menu-frame-live-and-visible-p)
1164 :enable (not (truncated-partial-width-window-p))))
1165 menu))
1167 (defvar menu-bar-options-menu
1168 (let ((menu (make-sparse-keymap "Options")))
1169 (define-key menu [customize]
1170 `(menu-item ,(purecopy "Customize Emacs") ,menu-bar-custom-menu))
1172 (define-key menu [package]
1173 '(menu-item "Manage Emacs Packages" package-list-packages
1174 :help "Install or uninstall additional Emacs packages"))
1176 (define-key menu [save]
1177 `(menu-item ,(purecopy "Save Options") menu-bar-options-save
1178 :help ,(purecopy "Save options set from the menu above")))
1180 (define-key menu [custom-separator]
1181 menu-bar-separator)
1183 (define-key menu [menu-set-font]
1184 `(menu-item ,(purecopy "Set Default Font...") menu-set-font
1185 :visible (display-multi-font-p)
1186 :help ,(purecopy "Select a default font")))
1188 (if (featurep 'system-font-setting)
1189 (define-key menu [menu-system-font]
1190 (menu-bar-make-toggle
1191 toggle-use-system-font font-use-system-font
1192 "Use System Font"
1193 "Use system font: %s"
1194 "Use the monospaced font defined by the system")))
1196 (define-key menu [showhide]
1197 `(menu-item ,(purecopy "Show/Hide") ,menu-bar-showhide-menu))
1199 (define-key menu [showhide-separator]
1200 menu-bar-separator)
1202 (define-key menu [mule]
1203 ;; It is better not to use backquote here,
1204 ;; because that makes a bootstrapping problem
1205 ;; if you need to recompile all the Lisp files using interpreted code.
1206 `(menu-item ,(purecopy "Multilingual Environment") ,mule-menu-keymap
1207 ;; Most of the MULE menu actually does make sense in
1208 ;; unibyte mode, e.g. language selection.
1209 ;; :visible '(default-value 'enable-multibyte-characters)
1211 ;;(setq menu-bar-final-items (cons 'mule menu-bar-final-items))
1212 ;;(define-key menu [preferences]
1213 ;; `(menu-item ,(purecopy "Preferences") ,menu-bar-preferences-menu
1214 ;; :help ,(purecopy "Toggle important global options")))
1216 (define-key menu [mule-separator]
1217 menu-bar-separator)
1219 (define-key menu [debug-on-quit]
1220 (menu-bar-make-toggle toggle-debug-on-quit debug-on-quit
1221 "Enter Debugger on Quit/C-g" "Debug on Quit %s"
1222 "Enter Lisp debugger when C-g is pressed"))
1223 (define-key menu [debug-on-error]
1224 (menu-bar-make-toggle toggle-debug-on-error debug-on-error
1225 "Enter Debugger on Error" "Debug on Error %s"
1226 "Enter Lisp debugger when an error is signaled"))
1227 (define-key menu [debugger-separator]
1228 menu-bar-separator)
1230 (define-key menu [blink-cursor-mode]
1231 (menu-bar-make-mm-toggle
1232 blink-cursor-mode
1233 "Blink Cursor"
1234 "Whether the cursor blinks (Blink Cursor mode)"))
1235 (define-key menu [cursor-separator]
1236 menu-bar-separator)
1238 (define-key menu [save-place]
1239 (menu-bar-make-toggle
1240 toggle-save-place-globally save-place
1241 "Save Place in Files between Sessions"
1242 "Saving place in files %s"
1243 "Visit files of previous session when restarting Emacs"
1244 (require 'saveplace)
1245 ;; Do it by name, to avoid a free-variable
1246 ;; warning during byte compilation.
1247 (set-default
1248 'save-place (not (symbol-value 'save-place)))))
1250 (define-key menu [uniquify]
1251 (menu-bar-make-toggle
1252 toggle-uniquify-buffer-names uniquify-buffer-name-style
1253 "Use Directory Names in Buffer Names"
1254 "Directory name in buffer names (uniquify) %s"
1255 "Uniquify buffer names by adding parent directory names"
1256 (require 'uniquify)
1257 (setq uniquify-buffer-name-style
1258 (if (not uniquify-buffer-name-style)
1259 'forward))))
1261 (define-key menu [edit-options-separator]
1262 menu-bar-separator)
1263 (define-key menu [cua-mode]
1264 (menu-bar-make-mm-toggle
1265 cua-mode
1266 "Use CUA Keys (Cut/Paste with C-x/C-c/C-v)"
1267 "Use C-z/C-x/C-c/C-v keys for undo/cut/copy/paste"
1268 (:visible (or (not (boundp 'cua-enable-cua-keys))
1269 cua-enable-cua-keys))))
1271 (define-key menu [cua-emulation-mode]
1272 (menu-bar-make-mm-toggle
1273 cua-mode
1274 "Shift movement mark region (CUA)"
1275 "Use shifted movement keys to set and extend the region"
1276 (:visible (and (boundp 'cua-enable-cua-keys)
1277 (not cua-enable-cua-keys)))))
1279 (define-key menu [case-fold-search]
1280 (menu-bar-make-toggle
1281 toggle-case-fold-search case-fold-search
1282 "Ignore Case for Search"
1283 "Case-Insensitive Search %s"
1284 "Ignore letter-case in search commands"))
1286 (define-key menu [auto-fill-mode]
1287 `(menu-item
1288 ,(purecopy "Auto Fill in Text Modes")
1289 menu-bar-text-mode-auto-fill
1290 :help ,(purecopy "Automatically fill text while typing (Auto Fill mode)")
1291 :button (:toggle . (if (listp text-mode-hook)
1292 (member 'turn-on-auto-fill text-mode-hook)
1293 (eq 'turn-on-auto-fill text-mode-hook)))))
1295 (define-key menu [line-wrapping]
1296 `(menu-item ,(purecopy "Line Wrapping in This Buffer")
1297 ,menu-bar-line-wrapping-menu))
1300 (define-key menu [highlight-separator]
1301 menu-bar-separator)
1302 (define-key menu [highlight-paren-mode]
1303 (menu-bar-make-mm-toggle
1304 show-paren-mode
1305 "Highlight Matching Parentheses"
1306 "Highlight matching/mismatched parentheses at cursor (Show Paren mode)"))
1307 (define-key menu [transient-mark-mode]
1308 (menu-bar-make-mm-toggle
1309 transient-mark-mode
1310 "Highlight Active Region"
1311 "Make text in active region stand out in color (Transient Mark mode)"
1312 (:enable (not cua-mode))))
1313 menu))
1316 ;; The "Tools" menu items
1318 (defun send-mail-item-name ()
1319 (let* ((known-send-mail-commands '((sendmail-user-agent . "sendmail")
1320 (mh-e-user-agent . "MH")
1321 (message-user-agent . "Gnus Message")
1322 (gnus-user-agent . "Gnus")))
1323 (name (assq mail-user-agent known-send-mail-commands)))
1324 (if name
1325 (setq name (cdr name))
1326 (setq name (symbol-name mail-user-agent))
1327 (if (string-match "\\(.+\\)-user-agent" name)
1328 (setq name (match-string 1 name))))
1329 name))
1331 (defun read-mail-item-name ()
1332 (let* ((known-rmail-commands '((rmail . "RMAIL")
1333 (mh-rmail . "MH")
1334 (gnus . "Gnus")))
1335 (known (assq read-mail-command known-rmail-commands)))
1336 (if known (cdr known) (symbol-name read-mail-command))))
1338 (defvar menu-bar-games-menu
1339 (let ((menu (make-sparse-keymap "Games")))
1341 (define-key menu [zone]
1342 `(menu-item ,(purecopy "Zone Out") zone
1343 :help ,(purecopy "Play tricks with Emacs display when Emacs is idle")))
1344 (define-key menu [tetris]
1345 `(menu-item ,(purecopy "Tetris") tetris
1346 :help ,(purecopy "Falling blocks game")))
1347 (define-key menu [solitaire]
1348 `(menu-item ,(purecopy "Solitaire") solitaire
1349 :help ,(purecopy "Get rid of all the stones")))
1350 (define-key menu [snake]
1351 `(menu-item ,(purecopy "Snake") snake
1352 :help ,(purecopy "Move snake around avoiding collisions")))
1353 (define-key menu [pong]
1354 `(menu-item ,(purecopy "Pong") pong
1355 :help ,(purecopy "Bounce the ball to your opponent")))
1356 (define-key menu [mult]
1357 `(menu-item ,(purecopy "Multiplication Puzzle") mpuz
1358 :help ,(purecopy "Exercise brain with multiplication")))
1359 (define-key menu [life]
1360 `(menu-item ,(purecopy "Life") life
1361 :help ,(purecopy "Watch how John Conway's cellular automaton evolves")))
1362 (define-key menu [land]
1363 `(menu-item ,(purecopy "Landmark") landmark
1364 :help ,(purecopy "Watch a neural-network robot learn landmarks")))
1365 (define-key menu [hanoi]
1366 `(menu-item ,(purecopy "Towers of Hanoi") hanoi
1367 :help ,(purecopy "Watch Towers-of-Hanoi puzzle solved by Emacs")))
1368 (define-key menu [gomoku]
1369 `(menu-item ,(purecopy "Gomoku") gomoku
1370 :help ,(purecopy "Mark 5 contiguous squares (like tic-tac-toe)")))
1371 (define-key menu [bubbles]
1372 `(menu-item ,(purecopy "Bubbles") bubbles
1373 :help ,(purecopy "Remove all bubbles using the fewest moves")))
1374 (define-key menu [black-box]
1375 `(menu-item ,(purecopy "Blackbox") blackbox
1376 :help ,(purecopy "Find balls in a black box by shooting rays")))
1377 (define-key menu [adventure]
1378 `(menu-item ,(purecopy "Adventure") dunnet
1379 :help ,(purecopy "Dunnet, a text Adventure game for Emacs")))
1380 (define-key menu [5x5]
1381 `(menu-item ,(purecopy "5x5") 5x5
1382 :help ,(purecopy "Fill in all the squares on a 5x5 board")))
1383 menu))
1385 (defvar menu-bar-encryption-decryption-menu
1386 (let ((menu (make-sparse-keymap "Encryption/Decryption")))
1387 (define-key menu [insert-keys]
1388 `(menu-item ,(purecopy "Insert Keys") epa-insert-keys
1389 :help ,(purecopy "Insert public keys after the current point")))
1391 (define-key menu [export-keys]
1392 `(menu-item ,(purecopy "Export Keys") epa-export-keys
1393 :help ,(purecopy "Export public keys to a file")))
1395 (define-key menu [import-keys-region]
1396 `(menu-item ,(purecopy "Import Keys from Region") epa-import-keys-region
1397 :help ,(purecopy "Import public keys from the current region")))
1399 (define-key menu [import-keys]
1400 `(menu-item ,(purecopy "Import Keys from File...") epa-import-keys
1401 :help ,(purecopy "Import public keys from a file")))
1403 (define-key menu [list-keys]
1404 `(menu-item ,(purecopy "List Keys") epa-list-keys
1405 :help ,(purecopy "Browse your public keyring")))
1407 (define-key menu [separator-keys]
1408 menu-bar-separator)
1410 (define-key menu [sign-region]
1411 `(menu-item ,(purecopy "Sign Region") epa-sign-region
1412 :help ,(purecopy "Create digital signature of the current region")))
1414 (define-key menu [verify-region]
1415 `(menu-item ,(purecopy "Verify Region") epa-verify-region
1416 :help ,(purecopy "Verify digital signature of the current region")))
1418 (define-key menu [encrypt-region]
1419 `(menu-item ,(purecopy "Encrypt Region") epa-encrypt-region
1420 :help ,(purecopy "Encrypt the current region")))
1422 (define-key menu [decrypt-region]
1423 `(menu-item ,(purecopy "Decrypt Region") epa-decrypt-region
1424 :help ,(purecopy "Decrypt the current region")))
1426 (define-key menu [separator-file]
1427 menu-bar-separator)
1429 (define-key menu [sign-file]
1430 `(menu-item ,(purecopy "Sign File...") epa-sign-file
1431 :help ,(purecopy "Create digital signature of a file")))
1433 (define-key menu [verify-file]
1434 `(menu-item ,(purecopy "Verify File...") epa-verify-file
1435 :help ,(purecopy "Verify digital signature of a file")))
1437 (define-key menu [encrypt-file]
1438 `(menu-item ,(purecopy "Encrypt File...") epa-encrypt-file
1439 :help ,(purecopy "Encrypt a file")))
1441 (define-key menu [decrypt-file]
1442 `(menu-item ,(purecopy "Decrypt File...") epa-decrypt-file
1443 :help ,(purecopy "Decrypt a file")))
1445 menu))
1447 (defun menu-bar-read-mail ()
1448 "Read mail using `read-mail-command'."
1449 (interactive)
1450 (call-interactively read-mail-command))
1452 (defvar menu-bar-tools-menu
1453 (let ((menu (make-sparse-keymap "Tools")))
1455 (define-key menu [games]
1456 `(menu-item ,(purecopy "Games") ,menu-bar-games-menu))
1458 (define-key menu [separator-games]
1459 menu-bar-separator)
1461 (define-key menu [encryption-decryption]
1462 `(menu-item ,(purecopy "Encryption/Decryption") ,menu-bar-encryption-decryption-menu))
1464 (define-key menu [separator-encryption-decryption]
1465 menu-bar-separator)
1467 (define-key menu [simple-calculator]
1468 `(menu-item ,(purecopy "Simple Calculator") calculator
1469 :help ,(purecopy "Invoke the Emacs built-in quick calculator")))
1470 (define-key menu [calc]
1471 `(menu-item ,(purecopy "Programmable Calculator") calc
1472 :help ,(purecopy "Invoke the Emacs built-in full scientific calculator")))
1473 (define-key menu [calendar]
1474 `(menu-item ,(purecopy "Calendar") calendar
1475 :help ,(purecopy "Invoke the Emacs built-in calendar")))
1477 (define-key menu [separator-net]
1478 menu-bar-separator)
1480 (define-key menu [directory-search]
1481 `(menu-item ,(purecopy "Directory Search") eudc-tools-menu))
1482 (define-key menu [compose-mail]
1483 `(menu-item (format "Send Mail (with %s)" (send-mail-item-name)) compose-mail
1484 :visible (and mail-user-agent (not (eq mail-user-agent 'ignore)))
1485 :help ,(purecopy "Send a mail message")))
1486 (define-key menu [rmail]
1487 `(menu-item (format "Read Mail (with %s)" (read-mail-item-name))
1488 menu-bar-read-mail
1489 :visible (and read-mail-command
1490 (not (eq read-mail-command 'ignore)))
1491 :help ,(purecopy "Read your mail and reply to it")))
1493 (define-key menu [gnus]
1494 `(menu-item ,(purecopy "Read Net News (Gnus)") gnus
1495 :help ,(purecopy "Read network news groups")))
1497 (define-key menu [separator-vc]
1498 menu-bar-separator)
1500 (define-key menu [pcl-cvs]
1501 `(menu-item ,(purecopy "PCL-CVS") cvs-global-menu))
1502 (define-key menu [vc] nil) ;Create the place for the VC menu.
1504 (define-key menu [separator-compare]
1505 menu-bar-separator)
1507 (define-key menu [epatch]
1508 `(menu-item ,(purecopy "Apply Patch") menu-bar-epatch-menu))
1509 (define-key menu [ediff-merge]
1510 `(menu-item ,(purecopy "Merge") menu-bar-ediff-merge-menu))
1511 (define-key menu [compare]
1512 `(menu-item ,(purecopy "Compare (Ediff)") menu-bar-ediff-menu))
1514 (define-key menu [separator-spell]
1515 menu-bar-separator)
1517 (define-key menu [spell]
1518 `(menu-item ,(purecopy "Spell Checking") ispell-menu-map))
1520 (define-key menu [separator-prog]
1521 menu-bar-separator)
1523 (define-key menu [semantic]
1524 `(menu-item ,(purecopy "Source Code Parsers (Semantic)")
1525 semantic-mode
1526 :help ,(purecopy "Toggle automatic parsing in source code buffers (Semantic mode)")
1527 :button (:toggle . (bound-and-true-p semantic-mode))))
1529 (define-key menu [ede]
1530 `(menu-item ,(purecopy "Project support (EDE)")
1531 global-ede-mode
1532 :help ,(purecopy "Toggle the Emacs Development Environment (Global EDE mode)")
1533 :button (:toggle . (bound-and-true-p global-ede-mode))))
1535 (define-key menu [gdb]
1536 `(menu-item ,(purecopy "Debugger (GDB)...") gdb
1537 :help ,(purecopy "Debug a program from within Emacs with GDB")))
1538 (define-key menu [shell-on-region]
1539 `(menu-item ,(purecopy "Shell Command on Region...") shell-command-on-region
1540 :enable mark-active
1541 :help ,(purecopy "Pass marked region to a shell command")))
1542 (define-key menu [shell]
1543 `(menu-item ,(purecopy "Shell Command...") shell-command
1544 :help ,(purecopy "Invoke a shell command and catch its output")))
1545 (define-key menu [compile]
1546 `(menu-item ,(purecopy "Compile...") compile
1547 :help ,(purecopy "Invoke compiler or Make, view compilation errors")))
1548 (define-key menu [grep]
1549 `(menu-item ,(purecopy "Search Files (Grep)...") grep
1550 :help ,(purecopy "Search files for strings or regexps (with Grep)")))
1551 menu))
1553 ;; The "Help" menu items
1555 (defvar menu-bar-describe-menu
1556 (let ((menu (make-sparse-keymap "Describe")))
1558 (define-key menu [mule-diag]
1559 `(menu-item ,(purecopy "Show All of Mule Status") mule-diag
1560 :visible (default-value 'enable-multibyte-characters)
1561 :help ,(purecopy "Display multilingual environment settings")))
1562 (define-key menu [describe-coding-system-briefly]
1563 `(menu-item ,(purecopy "Describe Coding System (Briefly)")
1564 describe-current-coding-system-briefly
1565 :visible (default-value 'enable-multibyte-characters)))
1566 (define-key menu [describe-coding-system]
1567 `(menu-item ,(purecopy "Describe Coding System...") describe-coding-system
1568 :visible (default-value 'enable-multibyte-characters)))
1569 (define-key menu [describe-input-method]
1570 `(menu-item ,(purecopy "Describe Input Method...") describe-input-method
1571 :visible (default-value 'enable-multibyte-characters)
1572 :help ,(purecopy "Keyboard layout for specific input method")))
1573 (define-key menu [describe-language-environment]
1574 `(menu-item ,(purecopy "Describe Language Environment")
1575 ,describe-language-environment-map))
1577 (define-key menu [separator-desc-mule]
1578 menu-bar-separator)
1580 (define-key menu [list-keybindings]
1581 `(menu-item ,(purecopy "List Key Bindings") describe-bindings
1582 :help ,(purecopy "Display all current key bindings (keyboard shortcuts)")))
1583 (define-key menu [describe-current-display-table]
1584 `(menu-item ,(purecopy "Describe Display Table") describe-current-display-table
1585 :help ,(purecopy "Describe the current display table")))
1586 (define-key menu [describe-package]
1587 `(menu-item ,(purecopy "Describe Package...") describe-package
1588 :help ,(purecopy "Display documentation of a Lisp package")))
1589 (define-key menu [describe-face]
1590 `(menu-item ,(purecopy "Describe Face...") describe-face
1591 :help ,(purecopy "Display the properties of a face")))
1592 (define-key menu [describe-variable]
1593 `(menu-item ,(purecopy "Describe Variable...") describe-variable
1594 :help ,(purecopy "Display documentation of variable/option")))
1595 (define-key menu [describe-function]
1596 `(menu-item ,(purecopy "Describe Function...") describe-function
1597 :help ,(purecopy "Display documentation of function/command")))
1598 (define-key menu [describe-key-1]
1599 `(menu-item ,(purecopy "Describe Key or Mouse Operation...") describe-key
1600 ;; Users typically don't identify keys and menu items...
1601 :help ,(purecopy "Display documentation of command bound to a \
1602 key, a click, or a menu-item")))
1603 (define-key menu [describe-mode]
1604 `(menu-item ,(purecopy "Describe Buffer Modes") describe-mode
1605 :help ,(purecopy "Describe this buffer's major and minor mode")))
1606 menu))
1608 (defun menu-bar-read-lispref ()
1609 "Display the Emacs Lisp Reference manual in Info mode."
1610 (interactive)
1611 (info "elisp"))
1613 (defun menu-bar-read-lispintro ()
1614 "Display the Introduction to Emacs Lisp Programming in Info mode."
1615 (interactive)
1616 (info "eintr"))
1618 (defun search-emacs-glossary ()
1619 "Display the Glossary node of the Emacs manual in Info mode."
1620 (interactive)
1621 (info "(emacs)Glossary"))
1623 (defun emacs-index-search (topic)
1624 "Look up TOPIC in the indices of the Emacs User Manual."
1625 (interactive "sSubject to look up: ")
1626 (info "emacs")
1627 (Info-index topic))
1629 (defun elisp-index-search (topic)
1630 "Look up TOPIC in the indices of the Emacs Lisp Reference Manual."
1631 (interactive "sSubject to look up: ")
1632 (info "elisp")
1633 (Info-index topic))
1635 (defvar menu-bar-search-documentation-menu
1636 (let ((menu (make-sparse-keymap "Search Documentation")))
1638 (define-key menu [search-documentation-strings]
1639 `(menu-item ,(purecopy "Search Documentation Strings...") apropos-documentation
1640 :help
1641 ,(purecopy "Find functions and variables whose doc strings match a regexp")))
1642 (define-key menu [find-any-object-by-name]
1643 `(menu-item ,(purecopy "Find Any Object by Name...") apropos
1644 :help ,(purecopy "Find symbols of any kind whose names match a regexp")))
1645 (define-key menu [find-option-by-value]
1646 `(menu-item ,(purecopy "Find Options by Value...") apropos-value
1647 :help ,(purecopy "Find variables whose values match a regexp")))
1648 (define-key menu [find-options-by-name]
1649 `(menu-item ,(purecopy "Find Options by Name...") apropos-variable
1650 :help ,(purecopy "Find variables whose names match a regexp")))
1651 (define-key menu [find-commands-by-name]
1652 `(menu-item ,(purecopy "Find Commands by Name...") apropos-command
1653 :help ,(purecopy "Find commands whose names match a regexp")))
1654 (define-key menu [sep1]
1655 menu-bar-separator)
1656 (define-key menu [lookup-command-in-manual]
1657 `(menu-item ,(purecopy "Look Up Command in User Manual...") Info-goto-emacs-command-node
1658 :help ,(purecopy "Display manual section that describes a command")))
1659 (define-key menu [lookup-key-in-manual]
1660 `(menu-item ,(purecopy "Look Up Key in User Manual...") Info-goto-emacs-key-command-node
1661 :help ,(purecopy "Display manual section that describes a key")))
1662 (define-key menu [lookup-subject-in-elisp-manual]
1663 `(menu-item ,(purecopy "Look Up Subject in ELisp Manual...") elisp-index-search
1664 :help ,(purecopy "Find description of a subject in Emacs Lisp manual")))
1665 (define-key menu [lookup-subject-in-emacs-manual]
1666 `(menu-item ,(purecopy "Look Up Subject in User Manual...") emacs-index-search
1667 :help ,(purecopy "Find description of a subject in Emacs User manual")))
1668 (define-key menu [emacs-terminology]
1669 `(menu-item ,(purecopy "Emacs Terminology") search-emacs-glossary
1670 :help ,(purecopy "Display the Glossary section of the Emacs manual")))
1671 menu))
1673 (defvar menu-bar-manuals-menu
1674 (let ((menu (make-sparse-keymap "More Manuals")))
1676 (define-key menu [man]
1677 `(menu-item ,(purecopy "Read Man Page...") manual-entry
1678 :help ,(purecopy "Man-page docs for external commands and libraries")))
1679 (define-key menu [sep2]
1680 menu-bar-separator)
1681 (define-key menu [order-emacs-manuals]
1682 `(menu-item ,(purecopy "Ordering Manuals") view-order-manuals
1683 :help ,(purecopy "How to order manuals from the Free Software Foundation")))
1684 (define-key menu [lookup-subject-in-all-manuals]
1685 `(menu-item ,(purecopy "Lookup Subject in all Manuals...") info-apropos
1686 :help ,(purecopy "Find description of a subject in all installed manuals")))
1687 (define-key menu [other-manuals]
1688 `(menu-item ,(purecopy "All Other Manuals (Info)") Info-directory
1689 :help ,(purecopy "Read any of the installed manuals")))
1690 (define-key menu [emacs-lisp-reference]
1691 `(menu-item ,(purecopy "Emacs Lisp Reference") menu-bar-read-lispref
1692 :help ,(purecopy "Read the Emacs Lisp Reference manual")))
1693 (define-key menu [emacs-lisp-intro]
1694 `(menu-item ,(purecopy "Introduction to Emacs Lisp") menu-bar-read-lispintro
1695 :help ,(purecopy "Read the Introduction to Emacs Lisp Programming")))
1696 menu))
1698 (defun menu-bar-help-extra-packages ()
1699 "Display help about some additional packages available for Emacs."
1700 (interactive)
1701 (let (enable-local-variables)
1702 (view-file (expand-file-name "MORE.STUFF"
1703 data-directory))
1704 (goto-address-mode 1)))
1706 (defun help-with-tutorial-spec-language ()
1707 "Use the Emacs tutorial, specifying which language you want."
1708 (interactive)
1709 (help-with-tutorial t))
1711 (defvar menu-bar-help-menu
1712 (let ((menu (make-sparse-keymap "Help")))
1713 (define-key menu [about-gnu-project]
1714 `(menu-item ,(purecopy "About GNU") describe-gnu-project
1715 :help ,(purecopy "About the GNU System, GNU Project, and GNU/Linux")))
1716 (define-key menu [about-emacs]
1717 `(menu-item ,(purecopy "About Emacs") about-emacs
1718 :help ,(purecopy "Display version number, copyright info, and basic help")))
1719 (define-key menu [sep4]
1720 menu-bar-separator)
1721 (define-key menu [describe-no-warranty]
1722 `(menu-item ,(purecopy "(Non)Warranty") describe-no-warranty
1723 :help ,(purecopy "Explain that Emacs has NO WARRANTY")))
1724 (define-key menu [describe-copying]
1725 `(menu-item ,(purecopy "Copying Conditions") describe-copying
1726 :help ,(purecopy "Show the Emacs license (GPL)")))
1727 (define-key menu [getting-new-versions]
1728 `(menu-item ,(purecopy "Getting New Versions") describe-distribution
1729 :help ,(purecopy "How to get the latest version of Emacs")))
1730 (define-key menu [sep2]
1731 menu-bar-separator)
1732 (define-key menu [external-packages]
1733 `(menu-item ,(purecopy "Finding Extra Packages") menu-bar-help-extra-packages
1734 :help ,(purecopy "Lisp packages distributed separately for use in Emacs")))
1735 (define-key menu [find-emacs-packages]
1736 `(menu-item ,(purecopy "Search Built-in Packages") finder-by-keyword
1737 :help ,(purecopy "Find built-in packages and features by keyword")))
1738 (define-key menu [more-manuals]
1739 `(menu-item ,(purecopy "More Manuals") ,menu-bar-manuals-menu))
1740 (define-key menu [emacs-manual]
1741 `(menu-item ,(purecopy "Read the Emacs Manual") info-emacs-manual
1742 :help ,(purecopy "Full documentation of Emacs features")))
1743 (define-key menu [describe]
1744 `(menu-item ,(purecopy "Describe") ,menu-bar-describe-menu))
1745 (define-key menu [search-documentation]
1746 `(menu-item ,(purecopy "Search Documentation") ,menu-bar-search-documentation-menu))
1747 (define-key menu [sep1]
1748 menu-bar-separator)
1749 (define-key menu [emacs-psychotherapist]
1750 `(menu-item ,(purecopy "Emacs Psychotherapist") doctor
1751 :help ,(purecopy "Our doctor will help you feel better")))
1752 (define-key menu [send-emacs-bug-report]
1753 `(menu-item ,(purecopy "Send Bug Report...") report-emacs-bug
1754 :help ,(purecopy "Send e-mail to Emacs maintainers")))
1755 (define-key menu [emacs-known-problems]
1756 `(menu-item ,(purecopy "Emacs Known Problems") view-emacs-problems
1757 :help ,(purecopy "Read about known problems with Emacs")))
1758 (define-key menu [emacs-news]
1759 `(menu-item ,(purecopy "Emacs News") view-emacs-news
1760 :help ,(purecopy "New features of this version")))
1761 (define-key menu [emacs-faq]
1762 `(menu-item ,(purecopy "Emacs FAQ") view-emacs-FAQ
1763 :help ,(purecopy "Frequently asked (and answered) questions about Emacs")))
1765 (define-key menu [emacs-tutorial-language-specific]
1766 `(menu-item ,(purecopy "Emacs Tutorial (choose language)...")
1767 help-with-tutorial-spec-language
1768 :help ,(purecopy "Learn how to use Emacs (choose a language)")))
1769 (define-key menu [emacs-tutorial]
1770 `(menu-item ,(purecopy "Emacs Tutorial") help-with-tutorial
1771 :help ,(purecopy "Learn how to use Emacs")))
1773 ;; In OS X it's in the app menu already.
1774 ;; FIXME? There already is an "About Emacs" (sans ...) entry in the Help menu.
1775 (and (featurep 'ns)
1776 (not (eq system-type 'darwin))
1777 (define-key menu [info-panel]
1778 `(menu-item ,(purecopy "About Emacs...") ns-do-emacs-info-panel)))
1779 menu))
1781 (define-key global-map [menu-bar tools]
1782 (cons (purecopy "Tools") menu-bar-tools-menu))
1783 (define-key global-map [menu-bar buffer]
1784 (cons (purecopy "Buffers") global-buffers-menu-map))
1785 (define-key global-map [menu-bar options]
1786 (cons (purecopy "Options") menu-bar-options-menu))
1787 (define-key global-map [menu-bar edit]
1788 (cons (purecopy "Edit") menu-bar-edit-menu))
1789 (define-key global-map [menu-bar file]
1790 (cons (purecopy "File") menu-bar-file-menu))
1792 ;; Put "Help" menu at the end, or Info at the front.
1793 ;; If running under GNUstep, "Help" is moved and renamed "Info" (see below).
1794 (if (and (featurep 'ns)
1795 (not (eq system-type 'darwin)))
1796 (define-key global-map [menu-bar help-menu]
1797 (cons (purecopy "Info") menu-bar-help-menu))
1798 (define-key-after global-map [menu-bar help-menu]
1799 (cons (purecopy "Help") menu-bar-help-menu)))
1801 (defun menu-bar-menu-frame-live-and-visible-p ()
1802 "Return non-nil if the menu frame is alive and visible.
1803 The menu frame is the frame for which we are updating the menu."
1804 (let ((menu-frame (or menu-updating-frame (selected-frame))))
1805 (and (frame-live-p menu-frame)
1806 (frame-visible-p menu-frame))))
1808 (defun menu-bar-non-minibuffer-window-p ()
1809 "Return non-nil if selected window of the menu frame is not a minibuf window.
1811 See the documentation of `menu-bar-menu-frame-live-and-visible-p'
1812 for the definition of the menu frame."
1813 (let ((menu-frame (or menu-updating-frame (selected-frame))))
1814 (not (window-minibuffer-p (frame-selected-window menu-frame)))))
1816 (defun kill-this-buffer () ; for the menu bar
1817 "Kill the current buffer.
1818 When called in the minibuffer, get out of the minibuffer
1819 using `abort-recursive-edit'."
1820 (interactive)
1821 (if (menu-bar-non-minibuffer-window-p)
1822 (kill-buffer (current-buffer))
1823 (abort-recursive-edit)))
1825 (defun kill-this-buffer-enabled-p ()
1826 "Return non-nil if the `kill-this-buffer' menu item should be enabled."
1827 (or (not (menu-bar-non-minibuffer-window-p))
1828 (let (found-1)
1829 ;; Instead of looping over entire buffer list, stop once we've
1830 ;; found two "killable" buffers (Bug#8184).
1831 (catch 'found-2
1832 (dolist (buffer (buffer-list))
1833 (unless (string-match-p "^ " (buffer-name buffer))
1834 (if (not found-1)
1835 (setq found-1 t)
1836 (throw 'found-2 t))))))))
1838 (put 'dired 'menu-enable '(menu-bar-non-minibuffer-window-p))
1840 ;; Permit deleting frame if it would leave a visible or iconified frame.
1841 (defun delete-frame-enabled-p ()
1842 "Return non-nil if `delete-frame' should be enabled in the menu bar."
1843 (let ((frames (frame-list))
1844 (count 0))
1845 (while frames
1846 (if (frame-visible-p (car frames))
1847 (setq count (1+ count)))
1848 (setq frames (cdr frames)))
1849 (> count 1)))
1851 (defcustom yank-menu-length 20
1852 "Maximum length to display in the yank-menu."
1853 :type 'integer
1854 :group 'menu)
1856 (defun menu-bar-update-yank-menu (string old)
1857 (let ((front (car (cdr yank-menu)))
1858 (menu-string (if (<= (length string) yank-menu-length)
1859 string
1860 (concat
1861 (substring string 0 (/ yank-menu-length 2))
1862 "..."
1863 (substring string (- (/ yank-menu-length 2)))))))
1864 ;; Don't let the menu string be all dashes
1865 ;; because that has a special meaning in a menu.
1866 (if (string-match "\\`-+\\'" menu-string)
1867 (setq menu-string (concat menu-string " ")))
1868 ;; If we're supposed to be extending an existing string, and that
1869 ;; string really is at the front of the menu, then update it in place.
1870 (if (and old (or (eq old (car front))
1871 (string= old (car front))))
1872 (progn
1873 (setcar front string)
1874 (setcar (cdr front) menu-string))
1875 (setcdr yank-menu
1876 (cons
1877 (cons string (cons menu-string 'menu-bar-select-yank))
1878 (cdr yank-menu)))))
1879 (if (> (length (cdr yank-menu)) kill-ring-max)
1880 (setcdr (nthcdr kill-ring-max yank-menu) nil)))
1882 (put 'menu-bar-select-yank 'apropos-inhibit t)
1883 (defun menu-bar-select-yank ()
1884 "Insert the stretch of previously-killed text selected from menu.
1885 The menu shows all the killed text sequences stored in `kill-ring'."
1886 (interactive "*")
1887 (push-mark (point))
1888 (insert last-command-event))
1891 ;;; Buffers Menu
1893 (defcustom buffers-menu-max-size 10
1894 "Maximum number of entries which may appear on the Buffers menu.
1895 If this is 10, then only the ten most-recently-selected buffers are shown.
1896 If this is nil, then all buffers are shown.
1897 A large number or nil slows down menu responsiveness."
1898 :type '(choice integer
1899 (const :tag "All" nil))
1900 :group 'menu)
1902 (defcustom buffers-menu-buffer-name-length 30
1903 "Maximum length of the buffer name on the Buffers menu.
1904 If this is a number, then buffer names are truncated to this length.
1905 If this is nil, then buffer names are shown in full.
1906 A large number or nil makes the menu too wide."
1907 :type '(choice integer
1908 (const :tag "Full length" nil))
1909 :group 'menu)
1911 (defcustom buffers-menu-show-directories 'unless-uniquify
1912 "If non-nil, show directories in the Buffers menu for buffers that have them.
1913 The special value `unless-uniquify' means that directories will be shown
1914 unless `uniquify-buffer-name-style' is non-nil (in which case, buffer
1915 names should include enough of a buffer's directory to distinguish it
1916 from other buffers).
1918 Setting this variable directly does not take effect until next time the
1919 Buffers menu is regenerated."
1920 :set (lambda (symbol value)
1921 (set symbol value)
1922 (menu-bar-update-buffers t))
1923 :initialize 'custom-initialize-default
1924 :type '(choice (const :tag "Never" nil)
1925 (const :tag "Unless uniquify is enabled" unless-uniquify)
1926 (const :tag "Always" t))
1927 :group 'menu)
1929 (defcustom buffers-menu-show-status t
1930 "If non-nil, show modified/read-only status of buffers in the Buffers menu.
1931 Setting this variable directly does not take effect until next time the
1932 Buffers menu is regenerated."
1933 :set (lambda (symbol value)
1934 (set symbol value)
1935 (menu-bar-update-buffers t))
1936 :initialize 'custom-initialize-default
1937 :type 'boolean
1938 :group 'menu)
1940 (defvar list-buffers-directory nil
1941 "String to display in buffer listings for buffers not visiting a file.")
1942 (make-variable-buffer-local 'list-buffers-directory)
1944 (defun menu-bar-select-buffer ()
1945 (interactive)
1946 (switch-to-buffer last-command-event))
1948 (defun menu-bar-select-frame (frame)
1949 (make-frame-visible frame)
1950 (raise-frame frame)
1951 (select-frame frame))
1953 (defun menu-bar-update-buffers-1 (elt)
1954 (let* ((buf (car elt))
1955 (file
1956 (and (if (eq buffers-menu-show-directories 'unless-uniquify)
1957 (or (not (boundp 'uniquify-buffer-name-style))
1958 (null uniquify-buffer-name-style))
1959 buffers-menu-show-directories)
1960 (or (buffer-file-name buf)
1961 (buffer-local-value 'list-buffers-directory buf)))))
1962 (when file
1963 (setq file (file-name-directory file)))
1964 (when (and file (> (length file) 20))
1965 (setq file (concat "..." (substring file -17))))
1966 (cons (if buffers-menu-show-status
1967 (let ((mod (if (buffer-modified-p buf) "*" ""))
1968 (ro (if (buffer-local-value 'buffer-read-only buf) "%" "")))
1969 (if file
1970 (format "%s %s%s -- %s" (cdr elt) mod ro file)
1971 (format "%s %s%s" (cdr elt) mod ro)))
1972 (if file
1973 (format "%s -- %s" (cdr elt) file)
1974 (cdr elt)))
1975 buf)))
1977 ;; Used to cache the menu entries for commands in the Buffers menu
1978 (defvar menu-bar-buffers-menu-command-entries nil)
1980 (defvar menu-bar-select-buffer-function 'switch-to-buffer
1981 "Function to select the buffer chosen from the `Buffers' menu-bar menu.
1982 It must accept a buffer as its only required argument.")
1984 (defun menu-bar-update-buffers (&optional force)
1985 ;; If user discards the Buffers item, play along.
1986 (and (lookup-key (current-global-map) [menu-bar buffer])
1987 (or force (frame-or-buffer-changed-p))
1988 (let ((buffers (buffer-list))
1989 (frames (frame-list))
1990 buffers-menu)
1991 ;; If requested, list only the N most recently selected buffers.
1992 (if (and (integerp buffers-menu-max-size)
1993 (> buffers-menu-max-size 1))
1994 (if (> (length buffers) buffers-menu-max-size)
1995 (setcdr (nthcdr buffers-menu-max-size buffers) nil)))
1997 ;; Make the menu of buffers proper.
1998 (setq buffers-menu
1999 (let (alist)
2000 ;; Put into each element of buffer-list
2001 ;; the name for actual display,
2002 ;; perhaps truncated in the middle.
2003 (dolist (buf buffers)
2004 (let ((name (buffer-name buf)))
2005 (unless (eq ?\s (aref name 0))
2006 (push (menu-bar-update-buffers-1
2007 (cons buf
2008 (if (and (integerp buffers-menu-buffer-name-length)
2009 (> (length name) buffers-menu-buffer-name-length))
2010 (concat
2011 (substring
2012 name 0 (/ buffers-menu-buffer-name-length 2))
2013 "..."
2014 (substring
2015 name (- (/ buffers-menu-buffer-name-length 2))))
2016 name)
2018 alist))))
2019 ;; Now make the actual list of items.
2020 (let ((buffers-vec (make-vector (length alist) nil))
2021 (i (length alist)))
2022 (dolist (pair alist)
2023 (setq i (1- i))
2024 (aset buffers-vec i
2025 (nconc (list (car pair)
2026 (cons nil nil))
2027 `(lambda ()
2028 (interactive)
2029 (funcall menu-bar-select-buffer-function ,(cdr pair))))))
2030 (list buffers-vec))))
2032 ;; Make a Frames menu if we have more than one frame.
2033 (when (cdr frames)
2034 (let* ((frames-vec (make-vector (length frames) nil))
2035 (frames-menu
2036 (cons 'keymap
2037 (list "Select Frame" frames-vec)))
2038 (i 0))
2039 (dolist (frame frames)
2040 (aset frames-vec i
2041 (nconc
2042 (list
2043 (frame-parameter frame 'name)
2044 (cons nil nil))
2045 `(lambda ()
2046 (interactive) (menu-bar-select-frame ,frame))))
2047 (setq i (1+ i)))
2048 ;; Put it after the normal buffers
2049 (setq buffers-menu
2050 (nconc buffers-menu
2051 `((frames-separator "--")
2052 (frames menu-item "Frames" ,frames-menu))))))
2054 ;; Add in some normal commands at the end of the menu. We use
2055 ;; the copy cached in `menu-bar-buffers-menu-command-entries'
2056 ;; if it's been set already. Note that we can't use constant
2057 ;; lists for the menu-entries, because the low-level menu-code
2058 ;; modifies them.
2059 (unless menu-bar-buffers-menu-command-entries
2060 (setq menu-bar-buffers-menu-command-entries
2061 (list '(command-separator "--")
2062 (list 'next-buffer
2063 'menu-item
2064 "Next Buffer"
2065 'next-buffer
2066 :help "Switch to the \"next\" buffer in a cyclic order")
2067 (list 'previous-buffer
2068 'menu-item
2069 "Previous Buffer"
2070 'previous-buffer
2071 :help "Switch to the \"previous\" buffer in a cyclic order")
2072 (list 'select-named-buffer
2073 'menu-item
2074 "Select Named Buffer..."
2075 'switch-to-buffer
2076 :help "Prompt for a buffer name, and select that buffer in the current window")
2077 (list 'list-all-buffers
2078 'menu-item
2079 "List All Buffers"
2080 'list-buffers
2081 :help "Pop up a window listing all Emacs buffers"
2082 ))))
2083 (setq buffers-menu
2084 (nconc buffers-menu menu-bar-buffers-menu-command-entries))
2086 ;; We used to "(define-key (current-global-map) [menu-bar buffer]"
2087 ;; but that did not do the right thing when the [menu-bar buffer]
2088 ;; entry above had been moved (e.g. to a parent keymap).
2089 (setcdr global-buffers-menu-map (cons "Select Buffer" buffers-menu)))))
2091 (add-hook 'menu-bar-update-hook 'menu-bar-update-buffers)
2093 (menu-bar-update-buffers)
2095 ;; this version is too slow
2096 ;;(defun format-buffers-menu-line (buffer)
2097 ;; "Returns a string to represent the given buffer in the Buffer menu.
2098 ;;nil means the buffer shouldn't be listed. You can redefine this."
2099 ;; (if (string-match "\\` " (buffer-name buffer))
2100 ;; nil
2101 ;; (with-current-buffer buffer
2102 ;; (let ((size (buffer-size)))
2103 ;; (format "%s%s %-19s %6s %-15s %s"
2104 ;; (if (buffer-modified-p) "*" " ")
2105 ;; (if buffer-read-only "%" " ")
2106 ;; (buffer-name)
2107 ;; size
2108 ;; mode-name
2109 ;; (or (buffer-file-name) ""))))))
2111 ;;; Set up a menu bar menu for the minibuffer.
2113 (dolist (map (list minibuffer-local-map
2114 ;; This shouldn't be necessary, but there's a funny
2115 ;; bug in keymap.c that I don't understand yet. -stef
2116 minibuffer-local-completion-map))
2117 (define-key map [menu-bar minibuf]
2118 (cons (purecopy "Minibuf") (make-sparse-keymap "Minibuf"))))
2120 (let ((map minibuffer-local-completion-map))
2121 (define-key map [menu-bar minibuf ?\?]
2122 `(menu-item ,(purecopy "List Completions") minibuffer-completion-help
2123 :help ,(purecopy "Display all possible completions")))
2124 (define-key map [menu-bar minibuf space]
2125 `(menu-item ,(purecopy "Complete Word") minibuffer-complete-word
2126 :help ,(purecopy "Complete at most one word")))
2127 (define-key map [menu-bar minibuf tab]
2128 `(menu-item ,(purecopy "Complete") minibuffer-complete
2129 :help ,(purecopy "Complete as far as possible"))))
2131 (let ((map minibuffer-local-map))
2132 (define-key map [menu-bar minibuf quit]
2133 `(menu-item ,(purecopy "Quit") abort-recursive-edit
2134 :help ,(purecopy "Abort input and exit minibuffer")))
2135 (define-key map [menu-bar minibuf return]
2136 `(menu-item ,(purecopy "Enter") exit-minibuffer
2137 :key-sequence ,(purecopy "\r")
2138 :help ,(purecopy "Terminate input and exit minibuffer")))
2139 (define-key map [menu-bar minibuf isearch-forward]
2140 `(menu-item ,(purecopy "Isearch History Forward") isearch-forward
2141 :help ,(purecopy "Incrementally search minibuffer history forward")))
2142 (define-key map [menu-bar minibuf isearch-backward]
2143 `(menu-item ,(purecopy "Isearch History Backward") isearch-backward
2144 :help ,(purecopy "Incrementally search minibuffer history backward")))
2145 (define-key map [menu-bar minibuf next]
2146 `(menu-item ,(purecopy "Next History Item") next-history-element
2147 :help ,(purecopy "Put next minibuffer history element in the minibuffer")))
2148 (define-key map [menu-bar minibuf previous]
2149 `(menu-item ,(purecopy "Previous History Item") previous-history-element
2150 :help ,(purecopy "Put previous minibuffer history element in the minibuffer"))))
2152 (define-minor-mode menu-bar-mode
2153 "Toggle display of a menu bar on each frame (Menu Bar mode).
2154 With a prefix argument ARG, enable Menu Bar mode if ARG is
2155 positive, and disable it otherwise. If called from Lisp, enable
2156 Menu Bar mode if ARG is omitted or nil.
2158 This command applies to all frames that exist and frames to be
2159 created in the future."
2160 :init-value t
2161 :global t
2162 ;; It's defined in C/cus-start, this stops the d-m-m macro defining it again.
2163 :variable menu-bar-mode
2165 ;; Turn the menu-bars on all frames on or off.
2166 (let ((val (if menu-bar-mode 1 0)))
2167 (dolist (frame (frame-list))
2168 (set-frame-parameter frame 'menu-bar-lines val))
2169 ;; If the user has given `default-frame-alist' a `menu-bar-lines'
2170 ;; parameter, replace it.
2171 (if (assq 'menu-bar-lines default-frame-alist)
2172 (setq default-frame-alist
2173 (cons (cons 'menu-bar-lines val)
2174 (assq-delete-all 'menu-bar-lines
2175 default-frame-alist)))))
2176 ;; Make the message appear when Emacs is idle. We can not call message
2177 ;; directly. The minor-mode message "Menu-bar mode disabled" comes
2178 ;; after this function returns, overwriting any message we do here.
2179 (when (and (called-interactively-p 'interactive) (not menu-bar-mode))
2180 (run-with-idle-timer 0 nil 'message
2181 "Menu-bar mode disabled. Use M-x menu-bar-mode to make the menu bar appear.")))
2183 ;;;###autoload
2184 ;; (This does not work right unless it comes after the above definition.)
2185 ;; This comment is taken from tool-bar.el near
2186 ;; (put 'tool-bar-mode ...)
2187 ;; We want to pretend the menu bar by standard is on, as this will make
2188 ;; customize consider disabling the menu bar a customization, and save
2189 ;; that. We could do this for real by setting :init-value above, but
2190 ;; that would overwrite disabling the menu bar from X resources.
2191 (put 'menu-bar-mode 'standard-value '(t))
2193 (defun toggle-menu-bar-mode-from-frame (&optional arg)
2194 "Toggle menu bar on or off, based on the status of the current frame.
2195 See `menu-bar-mode' for more information."
2196 (interactive (list (or current-prefix-arg 'toggle)))
2197 (if (eq arg 'toggle)
2198 (menu-bar-mode
2199 (if (menu-bar-positive-p
2200 (frame-parameter (menu-bar-frame-for-menubar) 'menu-bar-lines))
2201 0 1))
2202 (menu-bar-mode arg)))
2204 (declare-function x-menu-bar-open "term/x-win" (&optional frame))
2205 (declare-function w32-menu-bar-open "term/w32-win" (&optional frame))
2207 (defun menu-bar-open (&optional frame)
2208 "Start key navigation of the menu bar in FRAME.
2210 This function decides which method to use to access the menu
2211 depending on FRAME's terminal device. On X displays, it calls
2212 `x-menu-bar-open'; on Windows, `w32-menu-bar-open' otherwise it
2213 calls `tmm-menubar'.
2215 If FRAME is nil or not given, use the selected frame."
2216 (interactive)
2217 (let ((type (framep (or frame (selected-frame)))))
2218 (cond
2219 ((eq type 'x) (x-menu-bar-open frame))
2220 ((eq type 'w32) (w32-menu-bar-open frame))
2221 (t (with-selected-frame (or frame (selected-frame))
2222 (tmm-menubar))))))
2224 (global-set-key [f10] 'menu-bar-open)
2226 (provide 'menu-bar)
2228 ;;; menu-bar.el ends here