Add "Package:" file headers to denote built-in packages.
[emacs.git] / lisp / menu-bar.el
blob64c39f644a7de31c3788e7a664729b2635db3253
1 ;;; menu-bar.el --- define a default menu bar
3 ;; Copyright (C) 1993, 1994, 1995, 2000, 2001, 2002, 2003, 2004, 2005,
4 ;; 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
6 ;; Author: RMS
7 ;; Maintainer: FSF
8 ;; Keywords: internal, mouse
9 ;; Package: emacs
11 ;; This file is part of GNU Emacs.
13 ;; GNU Emacs is free software: you can redistribute it and/or modify
14 ;; it under the terms of the GNU General Public License as published by
15 ;; the Free Software Foundation, either version 3 of the License, or
16 ;; (at your option) any later version.
18 ;; GNU Emacs is distributed in the hope that it will be useful,
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;; GNU General Public License for more details.
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
26 ;; Avishai Yacobi suggested some menu rearrangements.
28 ;;; Commentary:
30 ;;; Code:
32 ;; Don't clobber an existing menu-bar keymap, to preserve any menu-bar key
33 ;; definitions made in loaddefs.el.
34 (or (lookup-key global-map [menu-bar])
35 (define-key global-map [menu-bar] (make-sparse-keymap "menu-bar")))
36 (defvar menu-bar-help-menu (make-sparse-keymap "Help"))
38 ;; Force Help item to come last, after the major mode's own items.
39 ;; The symbol used to be called `help', but that gets confused with the
40 ;; help key.
41 (setq menu-bar-final-items '(help-menu))
43 (define-key global-map [menu-bar help-menu] (cons (purecopy "Help") menu-bar-help-menu))
44 (defvar menu-bar-tools-menu (make-sparse-keymap "Tools"))
45 (define-key global-map [menu-bar tools] (cons (purecopy "Tools") menu-bar-tools-menu))
46 ;; This definition is just to show what this looks like.
47 ;; It gets modified in place when menu-bar-update-buffers is called.
48 (defvar global-buffers-menu-map (make-sparse-keymap "Buffers"))
49 (define-key global-map [menu-bar buffer]
50 (cons (purecopy "Buffers") global-buffers-menu-map))
51 (defvar menu-bar-options-menu (make-sparse-keymap "Options"))
52 (define-key global-map [menu-bar options]
53 (cons (purecopy "Options") menu-bar-options-menu))
54 (defvar menu-bar-edit-menu (make-sparse-keymap "Edit"))
55 (define-key global-map [menu-bar edit] (cons (purecopy "Edit") menu-bar-edit-menu))
56 (defvar menu-bar-file-menu (make-sparse-keymap "File"))
57 (define-key global-map [menu-bar file] (cons (purecopy "File") menu-bar-file-menu))
59 ;; This alias is for compatibility with 19.28 and before.
60 (defvar menu-bar-files-menu menu-bar-file-menu)
62 ;; This is referenced by some code below; it is defined in uniquify.el
63 (defvar uniquify-buffer-name-style)
65 ;; From emulation/cua-base.el; used below
66 (defvar cua-enable-cua-keys)
69 ;; The "File" menu items
70 (define-key menu-bar-file-menu [exit-emacs]
71 `(menu-item ,(purecopy "Quit") save-buffers-kill-terminal
72 :help ,(purecopy "Save unsaved buffers, then exit")))
74 (define-key menu-bar-file-menu [separator-exit]
75 menu-bar-separator)
77 ;; Don't use delete-frame as event name because that is a special
78 ;; event.
79 (define-key menu-bar-file-menu [delete-this-frame]
80 `(menu-item ,(purecopy "Delete Frame") delete-frame
81 :visible (fboundp 'delete-frame)
82 :enable (delete-frame-enabled-p)
83 :help ,(purecopy "Delete currently selected frame")))
84 (define-key menu-bar-file-menu [make-frame-on-display]
85 `(menu-item ,(purecopy "New Frame on Display...") make-frame-on-display
86 :visible (fboundp 'make-frame-on-display)
87 :help ,(purecopy "Open a new frame on another display")))
88 (define-key menu-bar-file-menu [make-frame]
89 `(menu-item ,(purecopy "New Frame") make-frame-command
90 :visible (fboundp 'make-frame-command)
91 :help ,(purecopy "Open a new frame")))
93 (define-key menu-bar-file-menu [one-window]
94 `(menu-item ,(purecopy "Remove Splits") delete-other-windows
95 :enable (not (one-window-p t nil))
96 :help ,(purecopy "Selected window grows to fill the whole frame")))
98 (define-key menu-bar-file-menu [split-window]
99 `(menu-item ,(purecopy "Split Window") split-window-vertically
100 :enable (and (menu-bar-menu-frame-live-and-visible-p)
101 (menu-bar-non-minibuffer-window-p))
102 :help ,(purecopy "Split selected window in two windows")))
104 (define-key menu-bar-file-menu [separator-window]
105 menu-bar-separator)
107 (define-key menu-bar-file-menu [ps-print-region]
108 `(menu-item ,(purecopy "Postscript Print Region (B+W)") ps-print-region
109 :enable mark-active
110 :help ,(purecopy "Pretty-print marked region in black and white to PostScript printer")))
111 (define-key menu-bar-file-menu [ps-print-buffer]
112 `(menu-item ,(purecopy "Postscript Print Buffer (B+W)") ps-print-buffer
113 :enable (menu-bar-menu-frame-live-and-visible-p)
114 :help ,(purecopy "Pretty-print current buffer in black and white to PostScript printer")))
115 (define-key menu-bar-file-menu [ps-print-region-faces]
116 `(menu-item ,(purecopy "Postscript Print Region") ps-print-region-with-faces
117 :enable mark-active
118 :help ,(purecopy "Pretty-print marked region to PostScript printer")))
119 (define-key menu-bar-file-menu [ps-print-buffer-faces]
120 `(menu-item ,(purecopy "Postscript Print Buffer") ps-print-buffer-with-faces
121 :enable (menu-bar-menu-frame-live-and-visible-p)
122 :help ,(purecopy "Pretty-print current buffer to PostScript printer")))
123 (define-key menu-bar-file-menu [print-region]
124 `(menu-item ,(purecopy "Print Region") print-region
125 :enable mark-active
126 :help ,(purecopy "Print region between mark and current position")))
127 (define-key menu-bar-file-menu [print-buffer]
128 `(menu-item ,(purecopy "Print Buffer") print-buffer
129 :enable (menu-bar-menu-frame-live-and-visible-p)
130 :help ,(purecopy "Print current buffer with page headings")))
132 (define-key menu-bar-file-menu [separator-print]
133 menu-bar-separator)
135 (define-key menu-bar-file-menu [recover-session]
136 `(menu-item ,(purecopy "Recover Crashed Session") recover-session
137 :enable (and auto-save-list-file-prefix
138 (file-directory-p
139 (file-name-directory auto-save-list-file-prefix))
140 (directory-files
141 (file-name-directory auto-save-list-file-prefix)
143 (concat "\\`"
144 (regexp-quote
145 (file-name-nondirectory
146 auto-save-list-file-prefix)))
148 :help ,(purecopy "Recover edits from a crashed session")))
149 (define-key menu-bar-file-menu [revert-buffer]
150 `(menu-item ,(purecopy "Revert Buffer") revert-buffer
151 :enable (or revert-buffer-function
152 revert-buffer-insert-file-contents-function
153 (and buffer-file-number
154 (or (buffer-modified-p)
155 (not (verify-visited-file-modtime
156 (current-buffer))))))
157 :help ,(purecopy "Re-read current buffer from its file")))
158 (define-key menu-bar-file-menu [write-file]
159 `(menu-item ,(purecopy "Save As...") write-file
160 :enable (and (menu-bar-menu-frame-live-and-visible-p)
161 (menu-bar-non-minibuffer-window-p))
162 :help ,(purecopy "Write current buffer to another file")))
163 (define-key menu-bar-file-menu [save-buffer]
164 `(menu-item ,(purecopy "Save") save-buffer
165 :enable (and (buffer-modified-p)
166 (buffer-file-name)
167 (menu-bar-non-minibuffer-window-p))
168 :help ,(purecopy "Save current buffer to its file")))
170 (define-key menu-bar-file-menu [separator-save]
171 menu-bar-separator)
173 (defun menu-find-file-existing ()
174 "Edit the existing file FILENAME."
175 (interactive)
176 (let* ((mustmatch (not (and (fboundp 'x-uses-old-gtk-dialog)
177 (x-uses-old-gtk-dialog))))
178 (filename (car (find-file-read-args "Find file: " mustmatch))))
179 (if mustmatch
180 (find-file-existing filename)
181 (find-file filename))))
184 (define-key menu-bar-file-menu [kill-buffer]
185 `(menu-item ,(purecopy "Close") kill-this-buffer
186 :enable (kill-this-buffer-enabled-p)
187 :help ,(purecopy "Discard (kill) current buffer")))
188 (define-key menu-bar-file-menu [insert-file]
189 `(menu-item ,(purecopy "Insert File...") insert-file
190 :enable (menu-bar-non-minibuffer-window-p)
191 :help ,(purecopy "Insert another file into current buffer")))
192 (define-key menu-bar-file-menu [dired]
193 `(menu-item ,(purecopy "Open Directory...") dired
194 :enable (menu-bar-non-minibuffer-window-p)
195 :help ,(purecopy "Read a directory, to operate on its files")))
196 (define-key menu-bar-file-menu [open-file]
197 `(menu-item ,(purecopy "Open File...") menu-find-file-existing
198 :enable (menu-bar-non-minibuffer-window-p)
199 :help ,(purecopy "Read an existing file into an Emacs buffer")))
200 (define-key menu-bar-file-menu [new-file]
201 `(menu-item ,(purecopy "Visit New File...") find-file
202 :enable (menu-bar-non-minibuffer-window-p)
203 :help ,(purecopy "Specify a new file's name, to edit the file")))
206 ;; The "Edit" menu items
208 ;; The "Edit->Search" submenu
209 (defvar menu-bar-last-search-type nil
210 "Type of last non-incremental search command called from the menu.")
212 (defun nonincremental-repeat-search-forward ()
213 "Search forward for the previous search string or regexp."
214 (interactive)
215 (cond
216 ((and (eq menu-bar-last-search-type 'string)
217 search-ring)
218 (search-forward (car search-ring)))
219 ((and (eq menu-bar-last-search-type 'regexp)
220 regexp-search-ring)
221 (re-search-forward (car regexp-search-ring)))
223 (error "No previous search"))))
225 (defun nonincremental-repeat-search-backward ()
226 "Search backward for the previous search string or regexp."
227 (interactive)
228 (cond
229 ((and (eq menu-bar-last-search-type 'string)
230 search-ring)
231 (search-backward (car search-ring)))
232 ((and (eq menu-bar-last-search-type 'regexp)
233 regexp-search-ring)
234 (re-search-backward (car regexp-search-ring)))
236 (error "No previous search"))))
238 (defun nonincremental-search-forward (string)
239 "Read a string and search for it nonincrementally."
240 (interactive "sSearch for string: ")
241 (setq menu-bar-last-search-type 'string)
242 (if (equal string "")
243 (search-forward (car search-ring))
244 (isearch-update-ring string nil)
245 (search-forward string)))
247 (defun nonincremental-search-backward (string)
248 "Read a string and search backward for it nonincrementally."
249 (interactive "sSearch for string: ")
250 (setq menu-bar-last-search-type 'string)
251 (if (equal string "")
252 (search-backward (car search-ring))
253 (isearch-update-ring string nil)
254 (search-backward string)))
256 (defun nonincremental-re-search-forward (string)
257 "Read a regular expression and search for it nonincrementally."
258 (interactive "sSearch for regexp: ")
259 (setq menu-bar-last-search-type 'regexp)
260 (if (equal string "")
261 (re-search-forward (car regexp-search-ring))
262 (isearch-update-ring string t)
263 (re-search-forward string)))
265 (defun nonincremental-re-search-backward (string)
266 "Read a regular expression and search backward for it nonincrementally."
267 (interactive "sSearch for regexp: ")
268 (setq menu-bar-last-search-type 'regexp)
269 (if (equal string "")
270 (re-search-backward (car regexp-search-ring))
271 (isearch-update-ring string t)
272 (re-search-backward string)))
274 (defvar menu-bar-search-menu (make-sparse-keymap "Search"))
276 ;; The Edit->Search->Incremental Search menu
277 (defvar menu-bar-i-search-menu
278 (make-sparse-keymap "Incremental Search"))
280 (define-key menu-bar-i-search-menu [isearch-backward-regexp]
281 `(menu-item ,(purecopy "Backward Regexp...") isearch-backward-regexp
282 :help ,(purecopy "Search backwards for a regular expression as you type it")))
283 (define-key menu-bar-i-search-menu [isearch-forward-regexp]
284 `(menu-item ,(purecopy "Forward Regexp...") isearch-forward-regexp
285 :help ,(purecopy "Search forward for a regular expression as you type it")))
286 (define-key menu-bar-i-search-menu [isearch-backward]
287 `(menu-item ,(purecopy "Backward String...") isearch-backward
288 :help ,(purecopy "Search backwards for a string as you type it")))
289 (define-key menu-bar-i-search-menu [isearch-forward]
290 `(menu-item ,(purecopy "Forward String...") isearch-forward
291 :help ,(purecopy "Search forward for a string as you type it")))
293 (define-key menu-bar-search-menu [i-search]
294 `(menu-item ,(purecopy "Incremental Search") ,menu-bar-i-search-menu))
295 (define-key menu-bar-search-menu [separator-tag-isearch]
296 menu-bar-separator)
298 (define-key menu-bar-search-menu [tags-continue]
299 `(menu-item ,(purecopy "Continue Tags Search") tags-loop-continue
300 :help ,(purecopy "Continue last tags search operation")))
301 (define-key menu-bar-search-menu [tags-srch]
302 `(menu-item ,(purecopy "Search Tagged Files...") tags-search
303 :help ,(purecopy "Search for a regexp in all tagged files")))
304 (define-key menu-bar-search-menu [separator-tag-search]
305 menu-bar-separator)
307 (define-key menu-bar-search-menu [repeat-search-back]
308 `(menu-item ,(purecopy "Repeat Backwards") nonincremental-repeat-search-backward
309 :enable (or (and (eq menu-bar-last-search-type 'string)
310 search-ring)
311 (and (eq menu-bar-last-search-type 'regexp)
312 regexp-search-ring))
313 :help ,(purecopy "Repeat last search backwards")))
314 (define-key menu-bar-search-menu [repeat-search-fwd]
315 `(menu-item ,(purecopy "Repeat Forward") nonincremental-repeat-search-forward
316 :enable (or (and (eq menu-bar-last-search-type 'string)
317 search-ring)
318 (and (eq menu-bar-last-search-type 'regexp)
319 regexp-search-ring))
320 :help ,(purecopy "Repeat last search forward")))
321 (define-key menu-bar-search-menu [separator-repeat-search]
322 menu-bar-separator)
324 (define-key menu-bar-search-menu [re-search-backward]
325 `(menu-item ,(purecopy "Regexp Backwards...") nonincremental-re-search-backward
326 :help ,(purecopy "Search backwards for a regular expression")))
327 (define-key menu-bar-search-menu [re-search-forward]
328 `(menu-item ,(purecopy "Regexp Forward...") nonincremental-re-search-forward
329 :help ,(purecopy "Search forward for a regular expression")))
331 (define-key menu-bar-search-menu [search-backward]
332 `(menu-item ,(purecopy "String Backwards...") nonincremental-search-backward
333 :help ,(purecopy "Search backwards for a string")))
334 (define-key menu-bar-search-menu [search-forward]
335 `(menu-item ,(purecopy "String Forward...") nonincremental-search-forward
336 :help ,(purecopy "Search forward for a string")))
338 ;; The Edit->Replace submenu
340 (defvar menu-bar-replace-menu (make-sparse-keymap "Replace"))
342 (define-key menu-bar-replace-menu [tags-repl-continue]
343 `(menu-item ,(purecopy "Continue Replace") tags-loop-continue
344 :help ,(purecopy "Continue last tags replace operation")))
345 (define-key menu-bar-replace-menu [tags-repl]
346 `(menu-item ,(purecopy "Replace in Tagged Files...") tags-query-replace
347 :help ,(purecopy "Interactively replace a regexp in all tagged files")))
348 (define-key menu-bar-replace-menu [separator-replace-tags]
349 menu-bar-separator)
351 (define-key menu-bar-replace-menu [query-replace-regexp]
352 `(menu-item ,(purecopy "Replace Regexp...") query-replace-regexp
353 :enable (not buffer-read-only)
354 :help ,(purecopy "Replace regular expression interactively, ask about each occurrence")))
355 (define-key menu-bar-replace-menu [query-replace]
356 `(menu-item ,(purecopy "Replace String...") query-replace
357 :enable (not buffer-read-only)
358 :help ,(purecopy "Replace string interactively, ask about each occurrence")))
360 ;;; Assemble the top-level Edit menu items.
361 (define-key menu-bar-edit-menu [props]
362 `(menu-item ,(purecopy "Text Properties") facemenu-menu))
364 (define-key menu-bar-edit-menu [fill]
365 `(menu-item ,(purecopy "Fill") fill-region
366 :enable (and mark-active (not buffer-read-only))
367 :help
368 ,(purecopy "Fill text in region to fit between left and right margin")))
370 (define-key menu-bar-edit-menu [separator-bookmark]
371 menu-bar-separator)
373 (define-key menu-bar-edit-menu [bookmark]
374 `(menu-item ,(purecopy "Bookmarks") menu-bar-bookmark-map))
376 (defvar menu-bar-goto-menu (make-sparse-keymap "Go To"))
378 (define-key menu-bar-goto-menu [set-tags-name]
379 `(menu-item ,(purecopy "Set Tags File Name...") visit-tags-table
380 :help ,(purecopy "Tell Tags commands which tag table file to use")))
382 (define-key menu-bar-goto-menu [separator-tag-file]
383 menu-bar-separator)
385 (define-key menu-bar-goto-menu [apropos-tags]
386 `(menu-item ,(purecopy "Tags Apropos...") tags-apropos
387 :help ,(purecopy "Find function/variables whose names match regexp")))
388 (define-key menu-bar-goto-menu [next-tag-otherw]
389 `(menu-item ,(purecopy "Next Tag in Other Window")
390 menu-bar-next-tag-other-window
391 :enable (and (boundp 'tags-location-ring)
392 (not (ring-empty-p tags-location-ring)))
393 :help ,(purecopy "Find next function/variable matching last tag name in another window")))
395 (defun menu-bar-next-tag-other-window ()
396 "Find the next definition of the tag already specified."
397 (interactive)
398 (find-tag-other-window nil t))
400 (defun menu-bar-next-tag ()
401 "Find the next definition of the tag already specified."
402 (interactive)
403 (find-tag nil t))
405 (define-key menu-bar-goto-menu [next-tag]
406 `(menu-item ,(purecopy "Find Next Tag")
407 menu-bar-next-tag
408 :enable (and (boundp 'tags-location-ring)
409 (not (ring-empty-p tags-location-ring)))
410 :help ,(purecopy "Find next function/variable matching last tag name")))
411 (define-key menu-bar-goto-menu [find-tag-otherw]
412 `(menu-item ,(purecopy "Find Tag in Other Window...") find-tag-other-window
413 :help ,(purecopy "Find function/variable definition in another window")))
414 (define-key menu-bar-goto-menu [find-tag]
415 `(menu-item ,(purecopy "Find Tag...") find-tag
416 :help ,(purecopy "Find definition of function or variable")))
418 (define-key menu-bar-goto-menu [separator-tags]
419 menu-bar-separator)
421 (define-key menu-bar-goto-menu [end-of-buf]
422 `(menu-item ,(purecopy "Goto End of Buffer") end-of-buffer))
423 (define-key menu-bar-goto-menu [beg-of-buf]
424 `(menu-item ,(purecopy "Goto Beginning of Buffer") beginning-of-buffer))
425 (define-key menu-bar-goto-menu [go-to-pos]
426 `(menu-item ,(purecopy "Goto Buffer Position...") goto-char
427 :help ,(purecopy "Read a number N and go to buffer position N")))
428 (define-key menu-bar-goto-menu [go-to-line]
429 `(menu-item ,(purecopy "Goto Line...") goto-line
430 :help ,(purecopy "Read a line number and go to that line")))
432 (define-key menu-bar-edit-menu [goto]
433 `(menu-item ,(purecopy "Go To") ,menu-bar-goto-menu))
435 (define-key menu-bar-edit-menu [replace]
436 `(menu-item ,(purecopy "Replace") ,menu-bar-replace-menu))
438 (define-key menu-bar-edit-menu [search]
439 `(menu-item ,(purecopy "Search") ,menu-bar-search-menu))
441 (define-key menu-bar-edit-menu [separator-search]
442 menu-bar-separator)
444 (define-key menu-bar-edit-menu [mark-whole-buffer]
445 `(menu-item ,(purecopy "Select All") mark-whole-buffer
446 :help ,(purecopy "Mark the whole buffer for a subsequent cut/copy")))
447 (define-key menu-bar-edit-menu [clear]
448 `(menu-item ,(purecopy "Clear") delete-region
449 :enable (and mark-active
450 (not buffer-read-only)
451 (not (mouse-region-match)))
452 :help
453 ,(purecopy "Delete the text in region between mark and current position")))
454 (defvar yank-menu (cons (purecopy "Select Yank") nil))
455 (fset 'yank-menu (cons 'keymap yank-menu))
456 (define-key menu-bar-edit-menu [paste-from-menu]
457 `(menu-item ,(purecopy "Paste from Kill Menu") yank-menu
458 :enable (and (cdr yank-menu) (not buffer-read-only))
459 :help ,(purecopy "Choose a string from the kill ring and paste it")))
460 (define-key menu-bar-edit-menu [paste]
461 `(menu-item ,(purecopy "Paste") yank
462 :enable (and (or
463 ;; Emacs compiled --without-x doesn't have
464 ;; x-selection-exists-p.
465 (and (fboundp 'x-selection-exists-p)
466 (x-selection-exists-p))
467 kill-ring)
468 (not buffer-read-only))
469 :help ,(purecopy "Paste (yank) text most recently cut/copied")))
470 (define-key menu-bar-edit-menu [copy]
471 `(menu-item ,(purecopy "Copy") menu-bar-kill-ring-save
472 :enable mark-active
473 :help ,(purecopy "Copy text in region between mark and current position")
474 :keys ,(purecopy "\\[kill-ring-save]")))
475 (define-key menu-bar-edit-menu [cut]
476 `(menu-item ,(purecopy "Cut") kill-region
477 :enable (and mark-active (not buffer-read-only))
478 :help
479 ,(purecopy "Cut (kill) text in region between mark and current position")))
480 (define-key menu-bar-edit-menu [undo]
481 `(menu-item ,(purecopy "Undo") undo
482 :enable (and (not buffer-read-only)
483 (not (eq t buffer-undo-list))
484 (if (eq last-command 'undo)
485 (listp pending-undo-list)
486 (consp buffer-undo-list)))
487 :help ,(purecopy "Undo last operation")))
490 (defun menu-bar-kill-ring-save (beg end)
491 (interactive "r")
492 (if (mouse-region-match)
493 (message "Selecting a region with the mouse does `copy' automatically")
494 (kill-ring-save beg end)))
496 ;; These are alternative definitions for the cut, paste and copy
497 ;; menu items. Use them if your system expects these to use the clipboard.
499 (put 'clipboard-kill-region 'menu-enable
500 '(and mark-active (not buffer-read-only)))
501 (put 'clipboard-kill-ring-save 'menu-enable 'mark-active)
502 (put 'clipboard-yank 'menu-enable
503 '(and (or (not (fboundp 'x-selection-exists-p))
504 (x-selection-exists-p)
505 (x-selection-exists-p 'CLIPBOARD))
506 (not buffer-read-only)))
508 (defun clipboard-yank ()
509 "Insert the clipboard contents, or the last stretch of killed text."
510 (interactive "*")
511 (let ((x-select-enable-clipboard t))
512 (yank)))
514 (defun clipboard-kill-ring-save (beg end)
515 "Copy region to kill ring, and save in the X clipboard."
516 (interactive "r")
517 (let ((x-select-enable-clipboard t))
518 (kill-ring-save beg end)))
520 (defun clipboard-kill-region (beg end)
521 "Kill the region, and save it in the X clipboard."
522 (interactive "r")
523 (let ((x-select-enable-clipboard t))
524 (kill-region beg end)))
526 (defun menu-bar-enable-clipboard ()
527 "Make CUT, PASTE and COPY (keys and menu bar items) use the clipboard.
528 Do the same for the keys of the same name."
529 (interactive)
530 ;; These are Sun server keysyms for the Cut, Copy and Paste keys
531 ;; (also for XFree86 on Sun keyboard):
532 (define-key global-map [f20] 'clipboard-kill-region)
533 (define-key global-map [f16] 'clipboard-kill-ring-save)
534 (define-key global-map [f18] 'clipboard-yank)
535 ;; X11R6 versions:
536 (define-key global-map [cut] 'clipboard-kill-region)
537 (define-key global-map [copy] 'clipboard-kill-ring-save)
538 (define-key global-map [paste] 'clipboard-yank))
540 ;; The "Options" menu items
542 (defvar menu-bar-custom-menu (make-sparse-keymap "Customize"))
544 (define-key menu-bar-custom-menu [customize-apropos-groups]
545 `(menu-item ,(purecopy "Groups Matching Regexp...") customize-apropos-groups
546 :help ,(purecopy "Browse groups whose names match regexp")))
547 (define-key menu-bar-custom-menu [customize-apropos-faces]
548 `(menu-item ,(purecopy "Faces Matching Regexp...") customize-apropos-faces
549 :help ,(purecopy "Browse faces whose names match regexp")))
550 (define-key menu-bar-custom-menu [customize-apropos-options]
551 `(menu-item ,(purecopy "Options Matching Regexp...") customize-apropos-options
552 :help ,(purecopy "Browse options whose names match regexp")))
553 (define-key menu-bar-custom-menu [customize-apropos]
554 `(menu-item ,(purecopy "Settings Matching Regexp...") customize-apropos
555 :help ,(purecopy "Browse customizable settings whose names match regexp")))
556 (define-key menu-bar-custom-menu [separator-1]
557 menu-bar-separator)
558 (define-key menu-bar-custom-menu [customize-group]
559 `(menu-item ,(purecopy "Specific Group...") customize-group
560 :help ,(purecopy "Customize settings of specific group")))
561 (define-key menu-bar-custom-menu [customize-face]
562 `(menu-item ,(purecopy "Specific Face...") customize-face
563 :help ,(purecopy "Customize attributes of specific face")))
564 (define-key menu-bar-custom-menu [customize-option]
565 `(menu-item ,(purecopy "Specific Option...") customize-option
566 :help ,(purecopy "Customize value of specific option")))
567 (define-key menu-bar-custom-menu [separator-2]
568 menu-bar-separator)
569 (define-key menu-bar-custom-menu [customize-changed-options]
570 `(menu-item ,(purecopy "New Options...") customize-changed-options
571 :help ,(purecopy "Options added or changed in recent Emacs versions")))
572 (define-key menu-bar-custom-menu [customize-saved]
573 `(menu-item ,(purecopy "Saved Options") customize-saved
574 :help ,(purecopy "Customize previously saved options")))
575 (define-key menu-bar-custom-menu [separator-3]
576 menu-bar-separator)
577 (define-key menu-bar-custom-menu [customize-browse]
578 `(menu-item ,(purecopy "Browse Customization Groups") customize-browse
579 :help ,(purecopy "Browse all customization groups")))
580 (define-key menu-bar-custom-menu [customize]
581 `(menu-item ,(purecopy "Top-level Customization Group") customize
582 :help ,(purecopy "The master group called `Emacs'")))
584 ;(defvar menu-bar-preferences-menu (make-sparse-keymap "Preferences"))
586 (defmacro menu-bar-make-mm-toggle (fname doc help &optional props)
587 "Make a menu-item for a global minor mode toggle.
588 FNAME is the minor mode's name (variable and function).
589 DOC is the text to use for the menu entry.
590 HELP is the text to use for the tooltip.
591 PROPS are additional properties."
592 `(list 'menu-item (purecopy ,doc) ',fname
593 ,@(mapcar (lambda (p) (list 'quote p)) props)
594 :help (purecopy ,help)
595 :button '(:toggle . (and (default-boundp ',fname)
596 (default-value ',fname)))))
598 (defmacro menu-bar-make-toggle (name variable doc message help &rest body)
599 `(progn
600 (defun ,name (&optional interactively)
601 ,(concat "Toggle whether to " (downcase (substring help 0 1))
602 (substring help 1) ".
603 In an interactive call, record this option as a candidate for saving
604 by \"Save Options\" in Custom buffers.")
605 (interactive "p")
606 (if ,(if body `(progn . ,body)
607 `(progn
608 (custom-load-symbol ',variable)
609 (let ((set (or (get ',variable 'custom-set) 'set-default))
610 (get (or (get ',variable 'custom-get) 'default-value)))
611 (funcall set ',variable (not (funcall get ',variable))))))
612 (message ,message "enabled globally")
613 (message ,message "disabled globally"))
614 ;; The function `customize-mark-as-set' must only be called when
615 ;; a variable is set interactively, as the purpose is to mark it as
616 ;; a candidate for "Save Options", and we do not want to save options
617 ;; the user have already set explicitly in his init file.
618 (if interactively (customize-mark-as-set ',variable)))
619 (list 'menu-item (purecopy ,doc) ',name
620 :help (purecopy ,help)
621 :button '(:toggle . (and (default-boundp ',variable)
622 (default-value ',variable))))))
624 ;; Function for setting/saving default font.
626 (defun menu-set-font ()
627 "Interactively select a font and make it the default."
628 (interactive)
629 (let ((font (if (fboundp 'x-select-font)
630 (x-select-font)
631 (mouse-select-font)))
632 spec)
633 (when font
634 ;; Be careful here: when set-face-attribute is called for the
635 ;; :font attribute, Emacs tries to guess the best matching font
636 ;; by examining the other face attributes (Bug#2476).
637 (set-face-attribute 'default (selected-frame)
638 :width 'normal
639 :weight 'normal
640 :slant 'normal
641 :font font)
642 (let ((font-object (face-attribute 'default :font)))
643 (dolist (f (frame-list))
644 (and (not (eq f (selected-frame)))
645 (display-graphic-p f)
646 (set-face-attribute 'default f :font font-object)))
647 (set-face-attribute 'default t :font font-object))
648 (setq spec (list (list t (face-attr-construct 'default))))
649 (put 'default 'customized-face spec)
650 (custom-push-theme 'theme-face 'default 'user 'set spec)
651 (put 'default 'face-modified nil))))
655 ;;; Assemble all the top-level items of the "Options" menu
656 (define-key menu-bar-options-menu [customize]
657 `(menu-item ,(purecopy "Customize Emacs") ,menu-bar-custom-menu))
659 (defun menu-bar-options-save ()
660 "Save current values of Options menu items using Custom."
661 (interactive)
662 (let ((need-save nil))
663 ;; These are set with menu-bar-make-mm-toggle, which does not
664 ;; put on a customized-value property.
665 (dolist (elt '(line-number-mode column-number-mode size-indication-mode
666 cua-mode show-paren-mode transient-mark-mode
667 blink-cursor-mode display-time-mode display-battery-mode))
668 (and (customize-mark-to-save elt)
669 (setq need-save t)))
670 ;; These are set with `customize-set-variable'.
671 (dolist (elt '(scroll-bar-mode
672 debug-on-quit debug-on-error
673 tooltip-mode menu-bar-mode tool-bar-mode
674 save-place uniquify-buffer-name-style fringe-mode
675 indicate-empty-lines indicate-buffer-boundaries
676 case-fold-search font-use-system-font
677 current-language-environment default-input-method
678 ;; Saving `text-mode-hook' is somewhat questionable,
679 ;; as we might get more than we bargain for, if
680 ;; other code may has added hooks as well.
681 ;; Nonetheless, not saving it would like be confuse
682 ;; more often.
683 ;; -- Per Abrahamsen <abraham@dina.kvl.dk> 2002-02-11.
684 text-mode-hook))
685 (and (get elt 'customized-value)
686 (customize-mark-to-save elt)
687 (setq need-save t)))
688 (when (get 'default 'customized-face)
689 (put 'default 'saved-face (get 'default 'customized-face))
690 (put 'default 'customized-face nil)
691 (setq need-save t))
692 ;; Save if we changed anything.
693 (when need-save
694 (custom-save-all))))
696 (define-key menu-bar-options-menu [package]
697 '(menu-item "Manage Emacs Packages" package-list-packages
698 :help "Install or uninstall additional Emacs packages"))
700 (define-key menu-bar-options-menu [save]
701 `(menu-item ,(purecopy "Save Options") menu-bar-options-save
702 :help ,(purecopy "Save options set from the menu above")))
704 (define-key menu-bar-options-menu [custom-separator]
705 menu-bar-separator)
707 (define-key menu-bar-options-menu [menu-set-font]
708 `(menu-item ,(purecopy "Set Default Font...") menu-set-font
709 :visible (display-multi-font-p)
710 :help ,(purecopy "Select a default font")))
712 (if (featurep 'system-font-setting)
713 (define-key menu-bar-options-menu [menu-system-font]
714 (menu-bar-make-toggle toggle-use-system-font font-use-system-font
715 "Use system font"
716 "Use system font: %s"
717 "Use the monospaced font defined by the system")))
720 ;; The "Show/Hide" submenu of menu "Options"
722 (defvar menu-bar-showhide-menu (make-sparse-keymap "Show/Hide"))
724 (define-key menu-bar-showhide-menu [column-number-mode]
725 (menu-bar-make-mm-toggle column-number-mode
726 "Column Numbers"
727 "Show the current column number in the mode line"))
729 (define-key menu-bar-showhide-menu [line-number-mode]
730 (menu-bar-make-mm-toggle line-number-mode
731 "Line Numbers"
732 "Show the current line number in the mode line"))
734 (define-key menu-bar-showhide-menu [size-indication-mode]
735 (menu-bar-make-mm-toggle size-indication-mode
736 "Size Indication"
737 "Show the size of the buffer in the mode line"))
739 (define-key menu-bar-showhide-menu [linecolumn-separator]
740 menu-bar-separator)
742 (define-key menu-bar-showhide-menu [showhide-battery]
743 (menu-bar-make-mm-toggle display-battery-mode
744 "Battery Status"
745 "Display battery status information in mode line"))
747 (define-key menu-bar-showhide-menu [showhide-date-time]
748 (menu-bar-make-mm-toggle display-time-mode
749 "Time, Load and Mail"
750 "Display time, system load averages and \
751 mail status in mode line"))
753 (define-key menu-bar-showhide-menu [datetime-separator]
754 menu-bar-separator)
756 (define-key menu-bar-showhide-menu [showhide-speedbar]
757 `(menu-item ,(purecopy "Speedbar") speedbar-frame-mode
758 :help ,(purecopy "Display a Speedbar quick-navigation frame")
759 :button (:toggle
760 . (and (boundp 'speedbar-frame)
761 (frame-live-p (symbol-value 'speedbar-frame))
762 (frame-visible-p
763 (symbol-value 'speedbar-frame))))))
765 (defvar menu-bar-showhide-fringe-menu (make-sparse-keymap "Fringe"))
767 (defvar menu-bar-showhide-fringe-ind-menu
768 (make-sparse-keymap "Buffer boundaries"))
770 (defun menu-bar-showhide-fringe-ind-customize ()
771 "Show customization buffer for `indicate-buffer-boundaries'."
772 (interactive)
773 (customize-variable 'indicate-buffer-boundaries))
775 (define-key menu-bar-showhide-fringe-ind-menu [customize]
776 `(menu-item ,(purecopy "Other (Customize)")
777 menu-bar-showhide-fringe-ind-customize
778 :help ,(purecopy "Additional choices available through Custom buffer")
779 :visible (display-graphic-p)
780 :button (:radio . (not (member indicate-buffer-boundaries
781 '(nil left right
782 ((top . left) (bottom . right))
783 ((t . right) (top . left))))))))
785 (defun menu-bar-showhide-fringe-ind-mixed ()
786 "Display top and bottom indicators in opposite fringes, arrows in right."
787 (interactive)
788 (customize-set-variable 'indicate-buffer-boundaries
789 '((t . right) (top . left))))
791 (define-key menu-bar-showhide-fringe-ind-menu [mixed]
792 `(menu-item ,(purecopy "Opposite, Arrows Right") menu-bar-showhide-fringe-ind-mixed
793 :help
794 ,(purecopy "Show top/bottom indicators in opposite fringes, arrows in right")
795 :visible (display-graphic-p)
796 :button (:radio . (equal indicate-buffer-boundaries
797 '((t . right) (top . left))))))
799 (defun menu-bar-showhide-fringe-ind-box ()
800 "Display top and bottom indicators in opposite fringes."
801 (interactive)
802 (customize-set-variable 'indicate-buffer-boundaries
803 '((top . left) (bottom . right))))
805 (define-key menu-bar-showhide-fringe-ind-menu [box]
806 `(menu-item ,(purecopy "Opposite, No Arrows") menu-bar-showhide-fringe-ind-box
807 :help ,(purecopy "Show top/bottom indicators in opposite fringes, no arrows")
808 :visible (display-graphic-p)
809 :button (:radio . (equal indicate-buffer-boundaries
810 '((top . left) (bottom . right))))))
812 (defun menu-bar-showhide-fringe-ind-right ()
813 "Display buffer boundaries and arrows in the right fringe."
814 (interactive)
815 (customize-set-variable 'indicate-buffer-boundaries 'right))
817 (define-key menu-bar-showhide-fringe-ind-menu [right]
818 `(menu-item ,(purecopy "In Right Fringe") menu-bar-showhide-fringe-ind-right
819 :help ,(purecopy "Show buffer boundaries and arrows in right fringe")
820 :visible (display-graphic-p)
821 :button (:radio . (eq indicate-buffer-boundaries 'right))))
823 (defun menu-bar-showhide-fringe-ind-left ()
824 "Display buffer boundaries and arrows in the left fringe."
825 (interactive)
826 (customize-set-variable 'indicate-buffer-boundaries 'left))
828 (define-key menu-bar-showhide-fringe-ind-menu [left]
829 `(menu-item ,(purecopy "In Left Fringe") menu-bar-showhide-fringe-ind-left
830 :help ,(purecopy "Show buffer boundaries and arrows in left fringe")
831 :visible (display-graphic-p)
832 :button (:radio . (eq indicate-buffer-boundaries 'left))))
834 (defun menu-bar-showhide-fringe-ind-none ()
835 "Do not display any buffer boundary indicators."
836 (interactive)
837 (customize-set-variable 'indicate-buffer-boundaries nil))
839 (define-key menu-bar-showhide-fringe-ind-menu [none]
840 `(menu-item ,(purecopy "No Indicators") menu-bar-showhide-fringe-ind-none
841 :help ,(purecopy "Hide all buffer boundary indicators and arrows")
842 :visible (display-graphic-p)
843 :button (:radio . (eq indicate-buffer-boundaries nil))))
845 (define-key menu-bar-showhide-fringe-menu [showhide-fringe-ind]
846 `(menu-item ,(purecopy "Buffer Boundaries") ,menu-bar-showhide-fringe-ind-menu
847 :visible (display-graphic-p)
848 :help ,(purecopy "Indicate buffer boundaries in fringe")))
850 (define-key menu-bar-showhide-fringe-menu [indicate-empty-lines]
851 (menu-bar-make-toggle toggle-indicate-empty-lines indicate-empty-lines
852 "Empty Line Indicators"
853 "Indicating of empty lines %s"
854 "Indicate trailing empty lines in fringe, globally"))
856 (defun menu-bar-showhide-fringe-menu-customize ()
857 "Show customization buffer for `fringe-mode'."
858 (interactive)
859 (customize-variable 'fringe-mode))
861 (define-key menu-bar-showhide-fringe-menu [customize]
862 `(menu-item ,(purecopy "Customize Fringe") menu-bar-showhide-fringe-menu-customize
863 :help ,(purecopy "Detailed customization of fringe")
864 :visible (display-graphic-p)))
866 (defun menu-bar-showhide-fringe-menu-customize-reset ()
867 "Reset the fringe mode: display fringes on both sides of a window."
868 (interactive)
869 (customize-set-variable 'fringe-mode nil))
871 (define-key menu-bar-showhide-fringe-menu [default]
872 `(menu-item ,(purecopy "Default") menu-bar-showhide-fringe-menu-customize-reset
873 :help ,(purecopy "Default width fringe on both left and right side")
874 :visible (display-graphic-p)
875 :button (:radio . (eq fringe-mode nil))))
877 (defun menu-bar-showhide-fringe-menu-customize-right ()
878 "Display fringes only on the right of each window."
879 (interactive)
880 (require 'fringe)
881 (customize-set-variable 'fringe-mode '(0 . nil)))
883 (define-key menu-bar-showhide-fringe-menu [right]
884 `(menu-item ,(purecopy "On the Right") menu-bar-showhide-fringe-menu-customize-right
885 :help ,(purecopy "Fringe only on the right side")
886 :visible (display-graphic-p)
887 :button (:radio . (equal fringe-mode '(0 . nil)))))
889 (defun menu-bar-showhide-fringe-menu-customize-left ()
890 "Display fringes only on the left of each window."
891 (interactive)
892 (require 'fringe)
893 (customize-set-variable 'fringe-mode '(nil . 0)))
895 (define-key menu-bar-showhide-fringe-menu [left]
896 `(menu-item ,(purecopy "On the Left") menu-bar-showhide-fringe-menu-customize-left
897 :help ,(purecopy "Fringe only on the left side")
898 :visible (display-graphic-p)
899 :button (:radio . (equal fringe-mode '(nil . 0)))))
901 (defun menu-bar-showhide-fringe-menu-customize-disable ()
902 "Do not display window fringes."
903 (interactive)
904 (require 'fringe)
905 (customize-set-variable 'fringe-mode 0))
907 (define-key menu-bar-showhide-fringe-menu [none]
908 `(menu-item ,(purecopy "None") menu-bar-showhide-fringe-menu-customize-disable
909 :help ,(purecopy "Turn off fringe")
910 :visible (display-graphic-p)
911 :button (:radio . (eq fringe-mode 0))))
913 (define-key menu-bar-showhide-menu [showhide-fringe]
914 `(menu-item ,(purecopy "Fringe") ,menu-bar-showhide-fringe-menu
915 :visible (display-graphic-p)))
917 (defvar menu-bar-showhide-scroll-bar-menu (make-sparse-keymap "Scroll-bar"))
919 (define-key menu-bar-showhide-scroll-bar-menu [right]
920 `(menu-item ,(purecopy "On the Right")
921 menu-bar-right-scroll-bar
922 :help ,(purecopy "Scroll-bar on the right side")
923 :visible (display-graphic-p)
924 :button (:radio . (eq (cdr (assq 'vertical-scroll-bars
925 (frame-parameters))) 'right))))
926 (defun menu-bar-right-scroll-bar ()
927 "Display scroll bars on the right of each window."
928 (interactive)
929 (customize-set-variable 'scroll-bar-mode 'right))
931 (define-key menu-bar-showhide-scroll-bar-menu [left]
932 `(menu-item ,(purecopy "On the Left")
933 menu-bar-left-scroll-bar
934 :help ,(purecopy "Scroll-bar on the left side")
935 :visible (display-graphic-p)
936 :button (:radio . (eq (cdr (assq 'vertical-scroll-bars
937 (frame-parameters))) 'left))))
939 (defun menu-bar-left-scroll-bar ()
940 "Display scroll bars on the left of each window."
941 (interactive)
942 (customize-set-variable 'scroll-bar-mode 'left))
944 (define-key menu-bar-showhide-scroll-bar-menu [none]
945 `(menu-item ,(purecopy "None")
946 menu-bar-no-scroll-bar
947 :help ,(purecopy "Turn off scroll-bar")
948 :visible (display-graphic-p)
949 :button (:radio . (eq (cdr (assq 'vertical-scroll-bars
950 (frame-parameters))) nil))))
952 (defun menu-bar-no-scroll-bar ()
953 "Turn off scroll bars."
954 (interactive)
955 (customize-set-variable 'scroll-bar-mode nil))
957 (define-key menu-bar-showhide-menu [showhide-scroll-bar]
958 `(menu-item ,(purecopy "Scroll-bar") ,menu-bar-showhide-scroll-bar-menu
959 :visible (display-graphic-p)))
961 (define-key menu-bar-showhide-menu [showhide-tooltip-mode]
962 `(menu-item ,(purecopy "Tooltips") tooltip-mode
963 :help ,(purecopy "Turn tooltips on/off")
964 :visible (and (display-graphic-p) (fboundp 'x-show-tip))
965 :button (:toggle . tooltip-mode)))
967 (define-key menu-bar-showhide-menu [menu-bar-mode]
968 `(menu-item ,(purecopy "Menu-bar") toggle-menu-bar-mode-from-frame
969 :help ,(purecopy "Turn menu-bar on/off")
970 :button (:toggle . (> (frame-parameter nil 'menu-bar-lines) 0))))
972 (defun menu-bar-set-tool-bar-position (position)
973 (customize-set-variable 'tool-bar-mode t)
974 (dolist (frame (frame-list))
975 (set-frame-parameter frame 'tool-bar-position position))
976 (customize-set-variable 'default-frame-alist
977 (cons (cons 'tool-bar-position position)
978 (assq-delete-all 'tool-bar-position
979 default-frame-alist))))
981 (defun menu-bar-showhide-tool-bar-menu-customize-disable ()
982 "Do not display tool bars."
983 (interactive)
984 (customize-set-variable 'tool-bar-mode nil))
985 (defun menu-bar-showhide-tool-bar-menu-customize-enable-left ()
986 "Display tool bars on the left side."
987 (interactive)
988 (menu-bar-set-tool-bar-position 'left))
990 (defun menu-bar-showhide-tool-bar-menu-customize-enable-right ()
991 "Display tool bars on the right side."
992 (interactive)
993 (menu-bar-set-tool-bar-position 'right))
994 (defun menu-bar-showhide-tool-bar-menu-customize-enable-top ()
995 "Display tool bars on the top side."
996 (interactive)
997 (menu-bar-set-tool-bar-position 'top))
998 (defun menu-bar-showhide-tool-bar-menu-customize-enable-bottom ()
999 "Display tool bars on the bottom side."
1000 (interactive)
1001 (menu-bar-set-tool-bar-position 'bottom))
1003 (if (featurep 'move-toolbar)
1004 (progn
1005 (defvar menu-bar-showhide-tool-bar-menu (make-sparse-keymap "Tool-bar"))
1007 (define-key menu-bar-showhide-tool-bar-menu [showhide-tool-bar-left]
1008 `(menu-item ,(purecopy "On the left")
1009 menu-bar-showhide-tool-bar-menu-customize-enable-left
1010 :help ,(purecopy "Tool-bar at the left side")
1011 :visible (display-graphic-p)
1012 :button
1013 (:radio . (and tool-bar-mode
1014 (eq (frame-parameter nil 'tool-bar-position)
1015 'left)))))
1017 (define-key menu-bar-showhide-tool-bar-menu [showhide-tool-bar-right]
1018 `(menu-item ,(purecopy "On the right")
1019 menu-bar-showhide-tool-bar-menu-customize-enable-right
1020 :help ,(purecopy "Tool-bar at the right side")
1021 :visible (display-graphic-p)
1022 :button
1023 (:radio . (and tool-bar-mode
1024 (eq (frame-parameter nil 'tool-bar-position)
1025 'right)))))
1027 (define-key menu-bar-showhide-tool-bar-menu [showhide-tool-bar-bottom]
1028 `(menu-item ,(purecopy "On the bottom")
1029 menu-bar-showhide-tool-bar-menu-customize-enable-bottom
1030 :help ,(purecopy "Tool-bar at the bottom")
1031 :visible (display-graphic-p)
1032 :button
1033 (:radio . (and tool-bar-mode
1034 (eq (frame-parameter nil 'tool-bar-position)
1035 'bottom)))))
1037 (define-key menu-bar-showhide-tool-bar-menu [showhide-tool-bar-top]
1038 `(menu-item ,(purecopy "On the top")
1039 menu-bar-showhide-tool-bar-menu-customize-enable-top
1040 :help ,(purecopy "Tool-bar at the top")
1041 :visible (display-graphic-p)
1042 :button
1043 (:radio . (and tool-bar-mode
1044 (eq (frame-parameter nil 'tool-bar-position)
1045 'top)))))
1047 (define-key menu-bar-showhide-tool-bar-menu [showhide-tool-bar-none]
1048 `(menu-item ,(purecopy "None")
1049 menu-bar-showhide-tool-bar-menu-customize-disable
1050 :help ,(purecopy "Turn tool-bar off")
1051 :visible (display-graphic-p)
1052 :button (:radio . (eq tool-bar-mode nil))))
1054 (define-key menu-bar-showhide-menu [showhide-tool-bar]
1055 `(menu-item ,(purecopy "Tool-bar") ,menu-bar-showhide-tool-bar-menu
1056 :visible (display-graphic-p)))
1059 ;; else not tool bar that can move.
1060 (define-key menu-bar-showhide-menu [showhide-tool-bar]
1061 `(menu-item ,(purecopy "Tool-bar") toggle-tool-bar-mode-from-frame
1062 :help ,(purecopy "Turn tool-bar on/off")
1063 :visible (display-graphic-p)
1064 :button (:toggle . (> (frame-parameter nil 'tool-bar-lines) 0))))
1067 (define-key menu-bar-options-menu [showhide]
1068 `(menu-item ,(purecopy "Show/Hide") ,menu-bar-showhide-menu))
1070 (define-key menu-bar-options-menu [showhide-separator]
1071 menu-bar-separator)
1073 (define-key menu-bar-options-menu [mule]
1074 ;; It is better not to use backquote here,
1075 ;; because that makes a bootstrapping problem
1076 ;; if you need to recompile all the Lisp files using interpreted code.
1077 `(menu-item ,(purecopy "Mule (Multilingual Environment)") ,mule-menu-keymap
1078 ;; Most of the MULE menu actually does make sense in unibyte mode,
1079 ;; e.g. language selection.
1080 ;;; :visible '(default-value 'enable-multibyte-characters)
1082 ;(setq menu-bar-final-items (cons 'mule menu-bar-final-items))
1083 ;(define-key menu-bar-options-menu [preferences]
1084 ; `(menu-item ,(purecopy "Preferences") ,menu-bar-preferences-menu
1085 ; :help ,(purecopy "Toggle important global options")))
1087 (define-key menu-bar-options-menu [mule-separator]
1088 menu-bar-separator)
1090 (define-key menu-bar-options-menu [debug-on-quit]
1091 (menu-bar-make-toggle toggle-debug-on-quit debug-on-quit
1092 "Enter Debugger on Quit/C-g" "Debug on Quit %s"
1093 "Enter Lisp debugger when C-g is pressed"))
1094 (define-key menu-bar-options-menu [debug-on-error]
1095 (menu-bar-make-toggle toggle-debug-on-error debug-on-error
1096 "Enter Debugger on Error" "Debug on Error %s"
1097 "Enter Lisp debugger when an error is signaled"))
1098 (define-key menu-bar-options-menu [debugger-separator]
1099 menu-bar-separator)
1101 (define-key menu-bar-options-menu [blink-cursor-mode]
1102 (menu-bar-make-mm-toggle blink-cursor-mode
1103 "Blinking Cursor"
1104 "Whether the cursor blinks (Blink Cursor mode)"))
1105 (define-key menu-bar-options-menu [cursor-separator]
1106 menu-bar-separator)
1108 (define-key menu-bar-options-menu [save-place]
1109 (menu-bar-make-toggle toggle-save-place-globally save-place
1110 "Save Place in Files between Sessions"
1111 "Saving place in files %s"
1112 "Visit files of previous session when restarting Emacs"
1113 (require 'saveplace)
1114 ;; Do it by name, to avoid a free-variable
1115 ;; warning during byte compilation.
1116 (set-default
1117 'save-place (not (symbol-value 'save-place)))))
1119 (define-key menu-bar-options-menu [uniquify]
1120 (menu-bar-make-toggle toggle-uniquify-buffer-names uniquify-buffer-name-style
1121 "Use Directory Names in Buffer Names"
1122 "Directory name in buffer names (uniquify) %s"
1123 "Uniquify buffer names by adding parent directory names"
1124 (require 'uniquify)
1125 (setq uniquify-buffer-name-style
1126 (if (not uniquify-buffer-name-style)
1127 'forward))))
1129 (define-key menu-bar-options-menu [edit-options-separator]
1130 menu-bar-separator)
1131 (define-key menu-bar-options-menu [cua-mode]
1132 (menu-bar-make-mm-toggle cua-mode
1133 "C-x/C-c/C-v Cut and Paste (CUA)"
1134 "Use C-z/C-x/C-c/C-v keys for undo/cut/copy/paste"
1135 (:visible (or (not (boundp 'cua-enable-cua-keys))
1136 cua-enable-cua-keys))))
1138 (define-key menu-bar-options-menu [cua-emulation-mode]
1139 (menu-bar-make-mm-toggle cua-mode
1140 "Shift movement mark region (CUA)"
1141 "Use shifted movement keys to set and extend the region"
1142 (:visible (and (boundp 'cua-enable-cua-keys)
1143 (not cua-enable-cua-keys)))))
1145 (define-key menu-bar-options-menu [case-fold-search]
1146 (menu-bar-make-toggle toggle-case-fold-search case-fold-search
1147 "Case-Insensitive Search"
1148 "Case-Insensitive Search %s"
1149 "Ignore letter-case in search commands"))
1151 (defun menu-bar-text-mode-auto-fill ()
1152 (interactive)
1153 (toggle-text-mode-auto-fill)
1154 ;; This is somewhat questionable, as `text-mode-hook'
1155 ;; might have changed outside customize.
1156 ;; -- Per Abrahamsen <abraham@dina.kvl.dk> 2002-02-11.
1157 (customize-mark-as-set 'text-mode-hook))
1159 (define-key menu-bar-options-menu [auto-fill-mode]
1160 `(menu-item ,(purecopy "Auto Fill in Text Modes")
1161 menu-bar-text-mode-auto-fill
1162 :help ,(purecopy "Automatically fill text while typing (Auto Fill mode)")
1163 :button (:toggle . (if (listp text-mode-hook)
1164 (member 'turn-on-auto-fill text-mode-hook)
1165 (eq 'turn-on-auto-fill text-mode-hook)))))
1168 (defvar menu-bar-line-wrapping-menu (make-sparse-keymap "Line Wrapping"))
1170 (define-key menu-bar-line-wrapping-menu [word-wrap]
1171 `(menu-item ,(purecopy "Word Wrap (Visual Line mode)")
1172 (lambda ()
1173 (interactive)
1174 (unless visual-line-mode
1175 (visual-line-mode 1))
1176 (message ,(purecopy "Visual-Line mode enabled")))
1177 :help ,(purecopy "Wrap long lines at word boundaries")
1178 :button (:radio . (and (null truncate-lines)
1179 (not (truncated-partial-width-window-p))
1180 word-wrap))
1181 :visible (menu-bar-menu-frame-live-and-visible-p)))
1183 (define-key menu-bar-line-wrapping-menu [truncate]
1184 `(menu-item ,(purecopy "Truncate Long Lines")
1185 (lambda ()
1186 (interactive)
1187 (if visual-line-mode (visual-line-mode 0))
1188 (setq word-wrap nil)
1189 (toggle-truncate-lines 1))
1190 :help ,(purecopy "Truncate long lines at window edge")
1191 :button (:radio . (or truncate-lines
1192 (truncated-partial-width-window-p)))
1193 :visible (menu-bar-menu-frame-live-and-visible-p)
1194 :enable (not (truncated-partial-width-window-p))))
1196 (define-key menu-bar-line-wrapping-menu [window-wrap]
1197 `(menu-item ,(purecopy "Wrap at Window Edge")
1198 (lambda () (interactive)
1199 (if visual-line-mode (visual-line-mode 0))
1200 (setq word-wrap nil)
1201 (if truncate-lines (toggle-truncate-lines -1)))
1202 :help ,(purecopy "Wrap long lines at window edge")
1203 :button (:radio . (and (null truncate-lines)
1204 (not (truncated-partial-width-window-p))
1205 (not word-wrap)))
1206 :visible (menu-bar-menu-frame-live-and-visible-p)
1207 :enable (not (truncated-partial-width-window-p))))
1209 (define-key menu-bar-options-menu [line-wrapping]
1210 `(menu-item ,(purecopy "Line Wrapping in this Buffer") ,menu-bar-line-wrapping-menu))
1213 (define-key menu-bar-options-menu [highlight-separator]
1214 menu-bar-separator)
1215 (define-key menu-bar-options-menu [highlight-paren-mode]
1216 (menu-bar-make-mm-toggle show-paren-mode
1217 "Paren Match Highlighting"
1218 "Highlight matching/mismatched parentheses at cursor (Show Paren mode)"))
1219 (define-key menu-bar-options-menu [transient-mark-mode]
1220 (menu-bar-make-mm-toggle transient-mark-mode
1221 "Active Region Highlighting"
1222 "Make text in active region stand out in color (Transient Mark mode)"
1223 (:enable (not cua-mode))))
1226 ;; The "Tools" menu items
1228 (defun send-mail-item-name ()
1229 (let* ((known-send-mail-commands '((sendmail-user-agent . "sendmail")
1230 (mh-e-user-agent . "MH")
1231 (message-user-agent . "Gnus Message")
1232 (gnus-user-agent . "Gnus")))
1233 (name (assq mail-user-agent known-send-mail-commands)))
1234 (if name
1235 (setq name (cdr name))
1236 (setq name (symbol-name mail-user-agent))
1237 (if (string-match "\\(.+\\)-user-agent" name)
1238 (setq name (match-string 1 name))))
1239 name))
1241 (defun read-mail-item-name ()
1242 (let* ((known-rmail-commands '((rmail . "RMAIL")
1243 (mh-rmail . "MH")
1244 (gnus . "Gnus")))
1245 (known (assq read-mail-command known-rmail-commands)))
1246 (if known (cdr known) (symbol-name read-mail-command))))
1248 (defvar menu-bar-games-menu (make-sparse-keymap "Games"))
1250 (define-key menu-bar-tools-menu [games]
1251 `(menu-item ,(purecopy "Games") ,menu-bar-games-menu))
1253 (define-key menu-bar-tools-menu [separator-games]
1254 menu-bar-separator)
1256 (define-key menu-bar-games-menu [zone]
1257 `(menu-item ,(purecopy "Zone Out") zone
1258 :help ,(purecopy "Play tricks with Emacs display when Emacs is idle")))
1259 (define-key menu-bar-games-menu [tetris]
1260 `(menu-item ,(purecopy "Tetris") tetris
1261 :help ,(purecopy "Falling blocks game")))
1262 (define-key menu-bar-games-menu [solitaire]
1263 `(menu-item ,(purecopy "Solitaire") solitaire
1264 :help ,(purecopy "Get rid of all the stones")))
1265 (define-key menu-bar-games-menu [snake]
1266 `(menu-item ,(purecopy "Snake") snake
1267 :help ,(purecopy "Move snake around avoiding collisions")))
1268 (define-key menu-bar-games-menu [pong]
1269 `(menu-item ,(purecopy "Pong") pong
1270 :help ,(purecopy "Bounce the ball to your opponent")))
1271 (define-key menu-bar-games-menu [mult]
1272 `(menu-item ,(purecopy "Multiplication Puzzle") mpuz
1273 :help ,(purecopy "Exercise brain with multiplication")))
1274 (define-key menu-bar-games-menu [life]
1275 `(menu-item ,(purecopy "Life") life
1276 :help ,(purecopy "Watch how John Conway's cellular automaton evolves")))
1277 (define-key menu-bar-games-menu [land]
1278 `(menu-item ,(purecopy "Landmark") landmark
1279 :help ,(purecopy "Watch a neural-network robot learn landmarks")))
1280 (define-key menu-bar-games-menu [hanoi]
1281 `(menu-item ,(purecopy "Towers of Hanoi") hanoi
1282 :help ,(purecopy "Watch Towers-of-Hanoi puzzle solved by Emacs")))
1283 (define-key menu-bar-games-menu [gomoku]
1284 `(menu-item ,(purecopy "Gomoku") gomoku
1285 :help ,(purecopy "Mark 5 contiguous squares (like tic-tac-toe)")))
1286 (define-key menu-bar-games-menu [bubbles]
1287 `(menu-item ,(purecopy "Bubbles") bubbles
1288 :help ,(purecopy "Remove all bubbles using the fewest moves")))
1289 (define-key menu-bar-games-menu [black-box]
1290 `(menu-item ,(purecopy "Blackbox") blackbox
1291 :help ,(purecopy "Find balls in a black box by shooting rays")))
1292 (define-key menu-bar-games-menu [adventure]
1293 `(menu-item ,(purecopy "Adventure") dunnet
1294 :help ,(purecopy "Dunnet, a text Adventure game for Emacs")))
1295 (define-key menu-bar-games-menu [5x5]
1296 `(menu-item ,(purecopy "5x5") 5x5
1297 :help ,(purecopy "Fill in all the squares on a 5x5 board")))
1299 (defvar menu-bar-encryption-decryption-menu
1300 (make-sparse-keymap "Encryption/Decryption"))
1302 (define-key menu-bar-tools-menu [encryption-decryption]
1303 `(menu-item ,(purecopy "Encryption/Decryption") ,menu-bar-encryption-decryption-menu))
1305 (define-key menu-bar-tools-menu [separator-encryption-decryption]
1306 menu-bar-separator)
1308 (define-key menu-bar-encryption-decryption-menu [insert-keys]
1309 `(menu-item ,(purecopy "Insert Keys") epa-insert-keys
1310 :help ,(purecopy "Insert public keys after the current point")))
1312 (define-key menu-bar-encryption-decryption-menu [export-keys]
1313 `(menu-item ,(purecopy "Export Keys") epa-export-keys
1314 :help ,(purecopy "Export public keys to a file")))
1316 (define-key menu-bar-encryption-decryption-menu [import-keys-region]
1317 `(menu-item ,(purecopy "Import Keys from Region") epa-import-keys-region
1318 :help ,(purecopy "Import public keys from the current region")))
1320 (define-key menu-bar-encryption-decryption-menu [import-keys]
1321 `(menu-item ,(purecopy "Import Keys from File...") epa-import-keys
1322 :help ,(purecopy "Import public keys from a file")))
1324 (define-key menu-bar-encryption-decryption-menu [list-keys]
1325 `(menu-item ,(purecopy "List Keys") epa-list-keys
1326 :help ,(purecopy "Browse your public keyring")))
1328 (define-key menu-bar-encryption-decryption-menu [separator-keys]
1329 menu-bar-separator)
1331 (define-key menu-bar-encryption-decryption-menu [sign-region]
1332 `(menu-item ,(purecopy "Sign Region") epa-sign-region
1333 :help ,(purecopy "Create digital signature of the current region")))
1335 (define-key menu-bar-encryption-decryption-menu [verify-region]
1336 `(menu-item ,(purecopy "Verify Region") epa-verify-region
1337 :help ,(purecopy "Verify digital signature of the current region")))
1339 (define-key menu-bar-encryption-decryption-menu [encrypt-region]
1340 `(menu-item ,(purecopy "Encrypt Region") epa-encrypt-region
1341 :help ,(purecopy "Encrypt the current region")))
1343 (define-key menu-bar-encryption-decryption-menu [decrypt-region]
1344 `(menu-item ,(purecopy "Decrypt Region") epa-decrypt-region
1345 :help ,(purecopy "Decrypt the current region")))
1347 (define-key menu-bar-encryption-decryption-menu [separator-file]
1348 menu-bar-separator)
1350 (define-key menu-bar-encryption-decryption-menu [sign-file]
1351 `(menu-item ,(purecopy "Sign File...") epa-sign-file
1352 :help ,(purecopy "Create digital signature of a file")))
1354 (define-key menu-bar-encryption-decryption-menu [verify-file]
1355 `(menu-item ,(purecopy "Verify File...") epa-verify-file
1356 :help ,(purecopy "Verify digital signature of a file")))
1358 (define-key menu-bar-encryption-decryption-menu [encrypt-file]
1359 `(menu-item ,(purecopy "Encrypt File...") epa-encrypt-file
1360 :help ,(purecopy "Encrypt a file")))
1362 (define-key menu-bar-encryption-decryption-menu [decrypt-file]
1363 `(menu-item ,(purecopy "Decrypt File...") epa-decrypt-file
1364 :help ,(purecopy "Decrypt a file")))
1366 (define-key menu-bar-tools-menu [simple-calculator]
1367 `(menu-item ,(purecopy "Simple Calculator") calculator
1368 :help ,(purecopy "Invoke the Emacs built-in quick calculator")))
1369 (define-key menu-bar-tools-menu [calc]
1370 `(menu-item ,(purecopy "Programmable Calculator") calc
1371 :help ,(purecopy "Invoke the Emacs built-in full scientific calculator")))
1372 (define-key menu-bar-tools-menu [calendar]
1373 `(menu-item ,(purecopy "Calendar") calendar
1374 :help ,(purecopy "Invoke the Emacs built-in calendar")))
1376 (define-key menu-bar-tools-menu [separator-net]
1377 menu-bar-separator)
1379 (define-key menu-bar-tools-menu [directory-search]
1380 `(menu-item ,(purecopy "Directory Search") eudc-tools-menu))
1381 (define-key menu-bar-tools-menu [compose-mail]
1382 `(menu-item (format "Send Mail (with %s)" (send-mail-item-name)) compose-mail
1383 :visible (and mail-user-agent (not (eq mail-user-agent 'ignore)))
1384 :help ,(purecopy "Send a mail message")))
1385 (define-key menu-bar-tools-menu [rmail]
1386 `(menu-item (format "Read Mail (with %s)" (read-mail-item-name))
1387 menu-bar-read-mail
1388 :visible (and read-mail-command
1389 (not (eq read-mail-command 'ignore)))
1390 :help ,(purecopy "Read your mail and reply to it")))
1392 (defun menu-bar-read-mail ()
1393 "Read mail using `read-mail-command'."
1394 (interactive)
1395 (call-interactively read-mail-command))
1397 (define-key menu-bar-tools-menu [gnus]
1398 `(menu-item ,(purecopy "Read Net News (Gnus)") gnus
1399 :help ,(purecopy "Read network news groups")))
1401 (define-key menu-bar-tools-menu [separator-vc]
1402 menu-bar-separator)
1404 (define-key menu-bar-tools-menu [pcl-cvs]
1405 `(menu-item ,(purecopy "PCL-CVS") cvs-global-menu))
1406 (define-key menu-bar-tools-menu [vc] nil) ;Create the place for the VC menu.
1408 (define-key menu-bar-tools-menu [separator-compare]
1409 menu-bar-separator)
1411 (define-key menu-bar-tools-menu [epatch]
1412 `(menu-item ,(purecopy "Apply Patch") menu-bar-epatch-menu))
1413 (define-key menu-bar-tools-menu [ediff-merge]
1414 `(menu-item ,(purecopy "Merge") menu-bar-ediff-merge-menu))
1415 (define-key menu-bar-tools-menu [compare]
1416 `(menu-item ,(purecopy "Compare (Ediff)") menu-bar-ediff-menu))
1418 (define-key menu-bar-tools-menu [separator-spell]
1419 menu-bar-separator)
1421 (define-key menu-bar-tools-menu [spell]
1422 `(menu-item ,(purecopy "Spell Checking") ispell-menu-map))
1424 (define-key menu-bar-tools-menu [separator-prog]
1425 menu-bar-separator)
1427 (define-key menu-bar-tools-menu [semantic]
1428 `(menu-item ,(purecopy "Source Code Parsers (Semantic)")
1429 semantic-mode
1430 :help ,(purecopy "Toggle automatic parsing in source code buffers (Semantic mode)")
1431 :button (:toggle . (bound-and-true-p semantic-mode))))
1433 (define-key menu-bar-tools-menu [ede]
1434 `(menu-item ,(purecopy "Project support (EDE)")
1435 global-ede-mode
1436 :help ,(purecopy "Toggle the Emacs Development Environment (Global EDE mode)")
1437 :button (:toggle . (bound-and-true-p global-ede-mode))))
1439 (define-key menu-bar-tools-menu [gdb]
1440 `(menu-item ,(purecopy "Debugger (GDB)...") gdb
1441 :help ,(purecopy "Debug a program from within Emacs with GDB")))
1442 (define-key menu-bar-tools-menu [shell-on-region]
1443 `(menu-item ,(purecopy "Shell Command on Region...") shell-command-on-region
1444 :enable mark-active
1445 :help ,(purecopy "Pass marked region to a shell command")))
1446 (define-key menu-bar-tools-menu [shell]
1447 `(menu-item ,(purecopy "Shell Command...") shell-command
1448 :help ,(purecopy "Invoke a shell command and catch its output")))
1449 (define-key menu-bar-tools-menu [compile]
1450 `(menu-item ,(purecopy "Compile...") compile
1451 :help ,(purecopy "Invoke compiler or Make, view compilation errors")))
1452 (define-key menu-bar-tools-menu [grep]
1453 `(menu-item ,(purecopy "Search Files (Grep)...") grep
1454 :help ,(purecopy "Search files for strings or regexps (with Grep)")))
1457 ;; The "Help" menu items
1459 (defvar menu-bar-describe-menu (make-sparse-keymap "Describe"))
1461 (define-key menu-bar-describe-menu [mule-diag]
1462 `(menu-item ,(purecopy "Show All of Mule Status") mule-diag
1463 :visible (default-value 'enable-multibyte-characters)
1464 :help ,(purecopy "Display multilingual environment settings")))
1465 (define-key menu-bar-describe-menu [describe-coding-system-briefly]
1466 `(menu-item ,(purecopy "Describe Coding System (Briefly)")
1467 describe-current-coding-system-briefly
1468 :visible (default-value 'enable-multibyte-characters)))
1469 (define-key menu-bar-describe-menu [describe-coding-system]
1470 `(menu-item ,(purecopy "Describe Coding System...") describe-coding-system
1471 :visible (default-value 'enable-multibyte-characters)))
1472 (define-key menu-bar-describe-menu [describe-input-method]
1473 `(menu-item ,(purecopy "Describe Input Method...") describe-input-method
1474 :visible (default-value 'enable-multibyte-characters)
1475 :help ,(purecopy "Keyboard layout for specific input method")))
1476 (define-key menu-bar-describe-menu [describe-language-environment]
1477 `(menu-item ,(purecopy "Describe Language Environment")
1478 ,describe-language-environment-map))
1480 (define-key menu-bar-describe-menu [separator-desc-mule]
1481 menu-bar-separator)
1483 (define-key menu-bar-describe-menu [list-keybindings]
1484 `(menu-item ,(purecopy "List Key Bindings") describe-bindings
1485 :help ,(purecopy "Display all current key bindings (keyboard shortcuts)")))
1486 (define-key menu-bar-describe-menu [describe-current-display-table]
1487 `(menu-item ,(purecopy "Describe Display Table") describe-current-display-table
1488 :help ,(purecopy "Describe the current display table")))
1489 (define-key menu-bar-describe-menu [describe-package]
1490 `(menu-item ,(purecopy "Describe Package...") describe-package
1491 :help ,(purecopy "Display documentation of a Lisp package")))
1492 (define-key menu-bar-describe-menu [describe-face]
1493 `(menu-item ,(purecopy "Describe Face...") describe-face
1494 :help ,(purecopy "Display the properties of a face")))
1495 (define-key menu-bar-describe-menu [describe-variable]
1496 `(menu-item ,(purecopy "Describe Variable...") describe-variable
1497 :help ,(purecopy "Display documentation of variable/option")))
1498 (define-key menu-bar-describe-menu [describe-function]
1499 `(menu-item ,(purecopy "Describe Function...") describe-function
1500 :help ,(purecopy "Display documentation of function/command")))
1501 (define-key menu-bar-describe-menu [describe-key-1]
1502 `(menu-item ,(purecopy "Describe Key or Mouse Operation...") describe-key
1503 ;; Users typically don't identify keys and menu items...
1504 :help ,(purecopy "Display documentation of command bound to a \
1505 key, a click, or a menu-item")))
1506 (define-key menu-bar-describe-menu [describe-mode]
1507 `(menu-item ,(purecopy "Describe Buffer Modes") describe-mode
1508 :help ,(purecopy "Describe this buffer's major and minor mode")))
1510 (defvar menu-bar-search-documentation-menu
1511 (make-sparse-keymap "Search Documentation"))
1512 (defun menu-bar-read-lispref ()
1513 "Display the Emacs Lisp Reference manual in Info mode."
1514 (interactive)
1515 (info "elisp"))
1517 (defun menu-bar-read-lispintro ()
1518 "Display the Introduction to Emacs Lisp Programming in Info mode."
1519 (interactive)
1520 (info "eintr"))
1522 (defun search-emacs-glossary ()
1523 "Display the Glossary node of the Emacs manual in Info mode."
1524 (interactive)
1525 (info "(emacs)Glossary"))
1527 (defun emacs-index-search (topic)
1528 "Look up TOPIC in the indices of the Emacs User Manual."
1529 (interactive "sSubject to look up: ")
1530 (info "emacs")
1531 (Info-index topic))
1533 (defun elisp-index-search (topic)
1534 "Look up TOPIC in the indices of the Emacs Lisp Reference Manual."
1535 (interactive "sSubject to look up: ")
1536 (info "elisp")
1537 (Info-index topic))
1539 (define-key menu-bar-search-documentation-menu [search-documentation-strings]
1540 `(menu-item ,(purecopy "Search Documentation Strings...") apropos-documentation
1541 :help
1542 ,(purecopy "Find functions and variables whose doc strings match a regexp")))
1543 (define-key menu-bar-search-documentation-menu [find-any-object-by-name]
1544 `(menu-item ,(purecopy "Find Any Object by Name...") apropos
1545 :help ,(purecopy "Find symbols of any kind whose names match a regexp")))
1546 (define-key menu-bar-search-documentation-menu [find-option-by-value]
1547 `(menu-item ,(purecopy "Find Options by Value...") apropos-value
1548 :help ,(purecopy "Find variables whose values match a regexp")))
1549 (define-key menu-bar-search-documentation-menu [find-options-by-name]
1550 `(menu-item ,(purecopy "Find Options by Name...") apropos-variable
1551 :help ,(purecopy "Find variables whose names match a regexp")))
1552 (define-key menu-bar-search-documentation-menu [find-commands-by-name]
1553 `(menu-item ,(purecopy "Find Commands by Name...") apropos-command
1554 :help ,(purecopy "Find commands whose names match a regexp")))
1555 (define-key menu-bar-search-documentation-menu [sep1]
1556 menu-bar-separator)
1557 (define-key menu-bar-search-documentation-menu [lookup-command-in-manual]
1558 `(menu-item ,(purecopy "Look Up Command in User Manual...") Info-goto-emacs-command-node
1559 :help ,(purecopy "Display manual section that describes a command")))
1560 (define-key menu-bar-search-documentation-menu [lookup-key-in-manual]
1561 `(menu-item ,(purecopy "Look Up Key in User Manual...") Info-goto-emacs-key-command-node
1562 :help ,(purecopy "Display manual section that describes a key")))
1563 (define-key menu-bar-search-documentation-menu [lookup-subject-in-elisp-manual]
1564 `(menu-item ,(purecopy "Look Up Subject in ELisp Manual...") elisp-index-search
1565 :help ,(purecopy "Find description of a subject in Emacs Lisp manual")))
1566 (define-key menu-bar-search-documentation-menu [lookup-subject-in-emacs-manual]
1567 `(menu-item ,(purecopy "Look Up Subject in User Manual...") emacs-index-search
1568 :help ,(purecopy "Find description of a subject in Emacs User manual")))
1569 (define-key menu-bar-search-documentation-menu [emacs-terminology]
1570 `(menu-item ,(purecopy "Emacs Terminology") search-emacs-glossary
1571 :help ,(purecopy "Display the Glossary section of the Emacs manual")))
1573 (defvar menu-bar-manuals-menu (make-sparse-keymap "More Manuals"))
1575 (define-key menu-bar-manuals-menu [man]
1576 `(menu-item ,(purecopy "Read Man Page...") manual-entry
1577 :help ,(purecopy "Man-page docs for external commands and libraries")))
1578 (define-key menu-bar-manuals-menu [sep2]
1579 menu-bar-separator)
1580 (define-key menu-bar-manuals-menu [order-emacs-manuals]
1581 `(menu-item ,(purecopy "Ordering Manuals") view-order-manuals
1582 :help ,(purecopy "How to order manuals from the Free Software Foundation")))
1583 (define-key menu-bar-manuals-menu [lookup-subject-in-all-manuals]
1584 `(menu-item ,(purecopy "Lookup Subject in all Manuals...") info-apropos
1585 :help ,(purecopy "Find description of a subject in all installed manuals")))
1586 (define-key menu-bar-manuals-menu [other-manuals]
1587 `(menu-item ,(purecopy "All Other Manuals (Info)") Info-directory
1588 :help ,(purecopy "Read any of the installed manuals")))
1589 (define-key menu-bar-manuals-menu [emacs-lisp-reference]
1590 `(menu-item ,(purecopy "Emacs Lisp Reference") menu-bar-read-lispref
1591 :help ,(purecopy "Read the Emacs Lisp Reference manual")))
1592 (define-key menu-bar-manuals-menu [emacs-lisp-intro]
1593 `(menu-item ,(purecopy "Introduction to Emacs Lisp") menu-bar-read-lispintro
1594 :help ,(purecopy "Read the Introduction to Emacs Lisp Programming")))
1596 (define-key menu-bar-help-menu [about-gnu-project]
1597 `(menu-item ,(purecopy "About GNU") describe-gnu-project
1598 :help ,(purecopy "About the GNU System, GNU Project, and GNU/Linux")))
1599 (define-key menu-bar-help-menu [about-emacs]
1600 `(menu-item ,(purecopy "About Emacs") about-emacs
1601 :help ,(purecopy "Display version number, copyright info, and basic help")))
1602 (define-key menu-bar-help-menu [sep4]
1603 menu-bar-separator)
1604 (define-key menu-bar-help-menu [describe-no-warranty]
1605 `(menu-item ,(purecopy "(Non)Warranty") describe-no-warranty
1606 :help ,(purecopy "Explain that Emacs has NO WARRANTY")))
1607 (define-key menu-bar-help-menu [describe-copying]
1608 `(menu-item ,(purecopy "Copying Conditions") describe-copying
1609 :help ,(purecopy "Show the Emacs license (GPL)")))
1610 (define-key menu-bar-help-menu [getting-new-versions]
1611 `(menu-item ,(purecopy "Getting New Versions") describe-distribution
1612 :help ,(purecopy "How to get the latest version of Emacs")))
1613 (defun menu-bar-help-extra-packages ()
1614 "Display help about some additional packages available for Emacs."
1615 (interactive)
1616 (let (enable-local-variables)
1617 (view-file (expand-file-name "MORE.STUFF"
1618 data-directory))
1619 (goto-address-mode 1)))
1620 (define-key menu-bar-help-menu [sep2]
1621 menu-bar-separator)
1622 (define-key menu-bar-help-menu [external-packages]
1623 `(menu-item ,(purecopy "Finding Extra Packages") menu-bar-help-extra-packages
1624 :help ,(purecopy "Lisp packages distributed separately for use in Emacs")))
1625 (define-key menu-bar-help-menu [find-emacs-packages]
1626 `(menu-item ,(purecopy "Search Built-in Packages") finder-by-keyword
1627 :help ,(purecopy "Find built-in packages and features by keyword")))
1628 (define-key menu-bar-help-menu [more-manuals]
1629 `(menu-item ,(purecopy "More Manuals") ,menu-bar-manuals-menu))
1630 (define-key menu-bar-help-menu [emacs-manual]
1631 `(menu-item ,(purecopy "Read the Emacs Manual") info-emacs-manual
1632 :help ,(purecopy "Full documentation of Emacs features")))
1633 (define-key menu-bar-help-menu [describe]
1634 `(menu-item ,(purecopy "Describe") ,menu-bar-describe-menu))
1635 (define-key menu-bar-help-menu [search-documentation]
1636 `(menu-item ,(purecopy "Search Documentation") ,menu-bar-search-documentation-menu))
1637 (define-key menu-bar-help-menu [sep1]
1638 menu-bar-separator)
1639 (define-key menu-bar-help-menu [emacs-psychotherapist]
1640 `(menu-item ,(purecopy "Emacs Psychotherapist") doctor
1641 :help ,(purecopy "Our doctor will help you feel better")))
1642 (define-key menu-bar-help-menu [send-emacs-bug-report]
1643 `(menu-item ,(purecopy "Send Bug Report...") report-emacs-bug
1644 :help ,(purecopy "Send e-mail to Emacs maintainers")))
1645 (define-key menu-bar-help-menu [emacs-known-problems]
1646 `(menu-item ,(purecopy "Emacs Known Problems") view-emacs-problems
1647 :help ,(purecopy "Read about known problems with Emacs")))
1648 (define-key menu-bar-help-menu [emacs-news]
1649 `(menu-item ,(purecopy "Emacs News") view-emacs-news
1650 :help ,(purecopy "New features of this version")))
1651 (define-key menu-bar-help-menu [emacs-faq]
1652 `(menu-item ,(purecopy "Emacs FAQ") view-emacs-FAQ
1653 :help ,(purecopy "Frequently asked (and answered) questions about Emacs")))
1655 (defun help-with-tutorial-spec-language ()
1656 "Use the Emacs tutorial, specifying which language you want."
1657 (interactive)
1658 (help-with-tutorial t))
1660 (define-key menu-bar-help-menu [emacs-tutorial-language-specific]
1661 `(menu-item ,(purecopy "Emacs Tutorial (choose language)...")
1662 help-with-tutorial-spec-language
1663 :help ,(purecopy "Learn how to use Emacs (choose a language)")))
1664 (define-key menu-bar-help-menu [emacs-tutorial]
1665 `(menu-item ,(purecopy "Emacs Tutorial") help-with-tutorial
1666 :help ,(purecopy "Learn how to use Emacs")))
1668 (defun menu-bar-menu-frame-live-and-visible-p ()
1669 "Return non-nil if the menu frame is alive and visible.
1670 The menu frame is the frame for which we are updating the menu."
1671 (let ((menu-frame (or menu-updating-frame (selected-frame))))
1672 (and (frame-live-p menu-frame)
1673 (frame-visible-p menu-frame))))
1675 (defun menu-bar-non-minibuffer-window-p ()
1676 "Return non-nil if selected window of the menu frame is not a minibuf window.
1678 See the documentation of `menu-bar-menu-frame-live-and-visible-p'
1679 for the definition of the menu frame."
1680 (let ((menu-frame (or menu-updating-frame (selected-frame))))
1681 (not (window-minibuffer-p (frame-selected-window menu-frame)))))
1683 (defun kill-this-buffer () ; for the menu bar
1684 "Kill the current buffer.
1685 When called in the minibuffer, get out of the minibuffer
1686 using `abort-recursive-edit'."
1687 (interactive)
1688 (if (menu-bar-non-minibuffer-window-p)
1689 (kill-buffer (current-buffer))
1690 (abort-recursive-edit)))
1692 (defun kill-this-buffer-enabled-p ()
1693 (let ((count 0)
1694 (buffers (buffer-list)))
1695 (while buffers
1696 (or (string-match "^ " (buffer-name (car buffers)))
1697 (setq count (1+ count)))
1698 (setq buffers (cdr buffers)))
1699 (or (not (menu-bar-non-minibuffer-window-p))
1700 (> count 1))))
1702 (put 'dired 'menu-enable '(menu-bar-non-minibuffer-window-p))
1704 ;; Permit deleting frame if it would leave a visible or iconified frame.
1705 (defun delete-frame-enabled-p ()
1706 "Return non-nil if `delete-frame' should be enabled in the menu bar."
1707 (let ((frames (frame-list))
1708 (count 0))
1709 (while frames
1710 (if (frame-visible-p (car frames))
1711 (setq count (1+ count)))
1712 (setq frames (cdr frames)))
1713 (> count 1)))
1715 (defcustom yank-menu-length 20
1716 "Maximum length to display in the yank-menu."
1717 :type 'integer
1718 :group 'menu)
1720 (defun menu-bar-update-yank-menu (string old)
1721 (let ((front (car (cdr yank-menu)))
1722 (menu-string (if (<= (length string) yank-menu-length)
1723 string
1724 (concat
1725 (substring string 0 (/ yank-menu-length 2))
1726 "..."
1727 (substring string (- (/ yank-menu-length 2)))))))
1728 ;; Don't let the menu string be all dashes
1729 ;; because that has a special meaning in a menu.
1730 (if (string-match "\\`-+\\'" menu-string)
1731 (setq menu-string (concat menu-string " ")))
1732 ;; If we're supposed to be extending an existing string, and that
1733 ;; string really is at the front of the menu, then update it in place.
1734 (if (and old (or (eq old (car front))
1735 (string= old (car front))))
1736 (progn
1737 (setcar front string)
1738 (setcar (cdr front) menu-string))
1739 (setcdr yank-menu
1740 (cons
1741 (cons string (cons menu-string 'menu-bar-select-yank))
1742 (cdr yank-menu)))))
1743 (if (> (length (cdr yank-menu)) kill-ring-max)
1744 (setcdr (nthcdr kill-ring-max yank-menu) nil)))
1746 (put 'menu-bar-select-yank 'apropos-inhibit t)
1747 (defun menu-bar-select-yank ()
1748 "Insert the stretch of previously-killed text selected from menu.
1749 The menu shows all the killed text sequences stored in `kill-ring'."
1750 (interactive "*")
1751 (push-mark (point))
1752 (insert last-command-event))
1755 ;;; Buffers Menu
1757 (defcustom buffers-menu-max-size 10
1758 "Maximum number of entries which may appear on the Buffers menu.
1759 If this is 10, then only the ten most-recently-selected buffers are shown.
1760 If this is nil, then all buffers are shown.
1761 A large number or nil slows down menu responsiveness."
1762 :type '(choice integer
1763 (const :tag "All" nil))
1764 :group 'menu)
1766 (defcustom buffers-menu-buffer-name-length 30
1767 "Maximum length of the buffer name on the Buffers menu.
1768 If this is a number, then buffer names are truncated to this length.
1769 If this is nil, then buffer names are shown in full.
1770 A large number or nil makes the menu too wide."
1771 :type '(choice integer
1772 (const :tag "Full length" nil))
1773 :group 'menu)
1775 (defcustom buffers-menu-show-directories 'unless-uniquify
1776 "If non-nil, show directories in the Buffers menu for buffers that have them.
1777 The special value `unless-uniquify' means that directories will be shown
1778 unless `uniquify-buffer-name-style' is non-nil (in which case, buffer
1779 names should include enough of a buffer's directory to distinguish it
1780 from other buffers).
1782 Setting this variable directly does not take effect until next time the
1783 Buffers menu is regenerated."
1784 :set (lambda (symbol value)
1785 (set symbol value)
1786 (menu-bar-update-buffers t))
1787 :initialize 'custom-initialize-default
1788 :type '(choice (const :tag "Never" nil)
1789 (const :tag "Unless uniquify is enabled" unless-uniquify)
1790 (const :tag "Always" t))
1791 :group 'menu)
1793 (defcustom buffers-menu-show-status t
1794 "If non-nil, show modified/read-only status of buffers in the Buffers menu.
1795 Setting this variable directly does not take effect until next time the
1796 Buffers menu is regenerated."
1797 :set (lambda (symbol value)
1798 (set symbol value)
1799 (menu-bar-update-buffers t))
1800 :initialize 'custom-initialize-default
1801 :type 'boolean
1802 :group 'menu)
1804 (defvar list-buffers-directory nil
1805 "String to display in buffer listings for buffers not visiting a file.")
1806 (make-variable-buffer-local 'list-buffers-directory)
1808 (defun menu-bar-select-buffer ()
1809 (interactive)
1810 (switch-to-buffer last-command-event))
1812 (defun menu-bar-select-frame (frame)
1813 (make-frame-visible frame)
1814 (raise-frame frame)
1815 (select-frame frame))
1817 (defun menu-bar-update-buffers-1 (elt)
1818 (let* ((buf (car elt))
1819 (file
1820 (and (if (eq buffers-menu-show-directories 'unless-uniquify)
1821 (or (not (boundp 'uniquify-buffer-name-style))
1822 (null uniquify-buffer-name-style))
1823 buffers-menu-show-directories)
1824 (or (buffer-file-name buf)
1825 (buffer-local-value 'list-buffers-directory buf)))))
1826 (when file
1827 (setq file (file-name-directory file)))
1828 (when (and file (> (length file) 20))
1829 (setq file (concat "..." (substring file -17))))
1830 (cons (if buffers-menu-show-status
1831 (let ((mod (if (buffer-modified-p buf) "*" ""))
1832 (ro (if (buffer-local-value 'buffer-read-only buf) "%" "")))
1833 (if file
1834 (format "%s %s%s -- %s" (cdr elt) mod ro file)
1835 (format "%s %s%s" (cdr elt) mod ro)))
1836 (if file
1837 (format "%s -- %s" (cdr elt) file)
1838 (cdr elt)))
1839 buf)))
1841 ;; Used to cache the menu entries for commands in the Buffers menu
1842 (defvar menu-bar-buffers-menu-command-entries nil)
1844 (defun menu-bar-update-buffers (&optional force)
1845 ;; If user discards the Buffers item, play along.
1846 (and (lookup-key (current-global-map) [menu-bar buffer])
1847 (or force (frame-or-buffer-changed-p))
1848 (let ((buffers (buffer-list))
1849 (frames (frame-list))
1850 buffers-menu)
1851 ;; If requested, list only the N most recently selected buffers.
1852 (if (and (integerp buffers-menu-max-size)
1853 (> buffers-menu-max-size 1))
1854 (if (> (length buffers) buffers-menu-max-size)
1855 (setcdr (nthcdr buffers-menu-max-size buffers) nil)))
1857 ;; Make the menu of buffers proper.
1858 (setq buffers-menu
1859 (let (alist)
1860 ;; Put into each element of buffer-list
1861 ;; the name for actual display,
1862 ;; perhaps truncated in the middle.
1863 (dolist (buf buffers)
1864 (let ((name (buffer-name buf)))
1865 (unless (eq ?\s (aref name 0))
1866 (push (menu-bar-update-buffers-1
1867 (cons buf
1868 (if (and (integerp buffers-menu-buffer-name-length)
1869 (> (length name) buffers-menu-buffer-name-length))
1870 (concat
1871 (substring
1872 name 0 (/ buffers-menu-buffer-name-length 2))
1873 "..."
1874 (substring
1875 name (- (/ buffers-menu-buffer-name-length 2))))
1876 name)
1878 alist))))
1879 ;; Now make the actual list of items.
1880 (let ((buffers-vec (make-vector (length alist) nil))
1881 (i (length alist)))
1882 (dolist (pair alist)
1883 (setq i (1- i))
1884 (aset buffers-vec i
1885 (nconc (list (car pair)
1886 (cons nil nil))
1887 `(lambda ()
1888 (interactive)
1889 (switch-to-buffer ,(cdr pair))))))
1890 (list buffers-vec))))
1892 ;; Make a Frames menu if we have more than one frame.
1893 (when (cdr frames)
1894 (let* ((frames-vec (make-vector (length frames) nil))
1895 (frames-menu
1896 (cons 'keymap
1897 (list "Select Frame" frames-vec)))
1898 (i 0))
1899 (dolist (frame frames)
1900 (aset frames-vec i
1901 (nconc
1902 (list
1903 (frame-parameter frame 'name)
1904 (cons nil nil))
1905 `(lambda ()
1906 (interactive) (menu-bar-select-frame ,frame))))
1907 (setq i (1+ i)))
1908 ;; Put it after the normal buffers
1909 (setq buffers-menu
1910 (nconc buffers-menu
1911 `((frames-separator "--")
1912 (frames menu-item "Frames" ,frames-menu))))))
1914 ;; Add in some normal commands at the end of the menu. We use
1915 ;; the copy cached in `menu-bar-buffers-menu-command-entries'
1916 ;; if it's been set already. Note that we can't use constant
1917 ;; lists for the menu-entries, because the low-level menu-code
1918 ;; modifies them.
1919 (unless menu-bar-buffers-menu-command-entries
1920 (setq menu-bar-buffers-menu-command-entries
1921 (list '(command-separator "--")
1922 (list 'next-buffer
1923 'menu-item
1924 "Next Buffer"
1925 'next-buffer
1926 :help "Switch to the \"next\" buffer in a cyclic order")
1927 (list 'previous-buffer
1928 'menu-item
1929 "Previous Buffer"
1930 'previous-buffer
1931 :help "Switch to the \"previous\" buffer in a cyclic order")
1932 (list 'select-named-buffer
1933 'menu-item
1934 "Select Named Buffer..."
1935 'switch-to-buffer
1936 :help "Prompt for a buffer name, and select that buffer in the current window")
1937 (list 'list-all-buffers
1938 'menu-item
1939 "List All Buffers"
1940 'list-buffers
1941 :help "Pop up a window listing all Emacs buffers"
1942 ))))
1943 (setq buffers-menu
1944 (nconc buffers-menu menu-bar-buffers-menu-command-entries))
1946 ;; We used to "(define-key (current-global-map) [menu-bar buffer]"
1947 ;; but that did not do the right thing when the [menu-bar buffer]
1948 ;; entry above had been moved (e.g. to a parent keymap).
1949 (setcdr global-buffers-menu-map (cons "Select Buffer" buffers-menu)))))
1951 (add-hook 'menu-bar-update-hook 'menu-bar-update-buffers)
1953 (menu-bar-update-buffers)
1955 ;; this version is too slow
1956 ;;(defun format-buffers-menu-line (buffer)
1957 ;; "Returns a string to represent the given buffer in the Buffer menu.
1958 ;;nil means the buffer shouldn't be listed. You can redefine this."
1959 ;; (if (string-match "\\` " (buffer-name buffer))
1960 ;; nil
1961 ;; (with-current-buffer buffer
1962 ;; (let ((size (buffer-size)))
1963 ;; (format "%s%s %-19s %6s %-15s %s"
1964 ;; (if (buffer-modified-p) "*" " ")
1965 ;; (if buffer-read-only "%" " ")
1966 ;; (buffer-name)
1967 ;; size
1968 ;; mode-name
1969 ;; (or (buffer-file-name) ""))))))
1971 ;;; Set up a menu bar menu for the minibuffer.
1973 (dolist (map (list minibuffer-local-map
1974 ;; This shouldn't be necessary, but there's a funny
1975 ;; bug in keymap.c that I don't understand yet. -stef
1976 minibuffer-local-completion-map))
1977 (define-key map [menu-bar minibuf]
1978 (cons (purecopy "Minibuf") (make-sparse-keymap "Minibuf"))))
1980 (let ((map minibuffer-local-completion-map))
1981 (define-key map [menu-bar minibuf ?\?]
1982 `(menu-item ,(purecopy "List Completions") minibuffer-completion-help
1983 :help ,(purecopy "Display all possible completions")))
1984 (define-key map [menu-bar minibuf space]
1985 `(menu-item ,(purecopy "Complete Word") minibuffer-complete-word
1986 :help ,(purecopy "Complete at most one word")))
1987 (define-key map [menu-bar minibuf tab]
1988 `(menu-item ,(purecopy "Complete") minibuffer-complete
1989 :help ,(purecopy "Complete as far as possible"))))
1991 (let ((map minibuffer-local-map))
1992 (define-key map [menu-bar minibuf quit]
1993 `(menu-item ,(purecopy "Quit") abort-recursive-edit
1994 :help ,(purecopy "Abort input and exit minibuffer")))
1995 (define-key map [menu-bar minibuf return]
1996 `(menu-item ,(purecopy "Enter") exit-minibuffer
1997 :key-sequence ,(purecopy "\r")
1998 :help ,(purecopy "Terminate input and exit minibuffer")))
1999 (define-key map [menu-bar minibuf isearch-forward]
2000 `(menu-item ,(purecopy "Isearch History Forward") isearch-forward
2001 :help ,(purecopy "Incrementally search minibuffer history forward")))
2002 (define-key map [menu-bar minibuf isearch-backward]
2003 `(menu-item ,(purecopy "Isearch History Backward") isearch-backward
2004 :help ,(purecopy "Incrementally search minibuffer history backward")))
2005 (define-key map [menu-bar minibuf next]
2006 `(menu-item ,(purecopy "Next History Item") next-history-element
2007 :help ,(purecopy "Put next minibuffer history element in the minibuffer")))
2008 (define-key map [menu-bar minibuf previous]
2009 `(menu-item ,(purecopy "Previous History Item") previous-history-element
2010 :help ,(purecopy "Put previous minibuffer history element in the minibuffer"))))
2012 (define-minor-mode menu-bar-mode
2013 "Toggle display of a menu bar on each frame.
2014 This command applies to all frames that exist and frames to be
2015 created in the future.
2016 With a numeric argument, if the argument is positive,
2017 turn on menu bars; otherwise, turn off menu bars."
2018 :init-value t
2019 :global t
2020 :group 'frames
2022 ;; Turn the menu-bars on all frames on or off.
2023 (let ((val (if menu-bar-mode 1 0)))
2024 (dolist (frame (frame-list))
2025 (set-frame-parameter frame 'menu-bar-lines val))
2026 ;; If the user has given `default-frame-alist' a `menu-bar-lines'
2027 ;; parameter, replace it.
2028 (if (assq 'menu-bar-lines default-frame-alist)
2029 (setq default-frame-alist
2030 (cons (cons 'menu-bar-lines val)
2031 (assq-delete-all 'menu-bar-lines
2032 default-frame-alist)))))
2033 ;; Make the message appear when Emacs is idle. We can not call message
2034 ;; directly. The minor-mode message "Menu-bar mode disabled" comes
2035 ;; after this function returns, overwriting any message we do here.
2036 (when (and (called-interactively-p 'interactive) (not menu-bar-mode))
2037 (run-with-idle-timer 0 nil 'message
2038 "Menu-bar mode disabled. Use M-x menu-bar-mode to make the menu bar appear.")))
2040 (defun toggle-menu-bar-mode-from-frame (&optional arg)
2041 "Toggle menu bar on or off, based on the status of the current frame.
2042 See `menu-bar-mode' for more information."
2043 (interactive (list (or current-prefix-arg 'toggle)))
2044 (if (eq arg 'toggle)
2045 (menu-bar-mode (if (> (frame-parameter nil 'menu-bar-lines) 0) 0 1))
2046 (menu-bar-mode arg)))
2048 (declare-function x-menu-bar-open "term/x-win" (&optional frame))
2049 (declare-function w32-menu-bar-open "term/w32-win" (&optional frame))
2051 (defun menu-bar-open (&optional frame)
2052 "Start key navigation of the menu bar in FRAME.
2054 This function decides which method to use to access the menu
2055 depending on FRAME's terminal device. On X displays, it calls
2056 `x-menu-bar-open'; on Windows, `w32-menu-bar-open' otherwise it
2057 calls `tmm-menubar'.
2059 If FRAME is nil or not given, use the selected frame."
2060 (interactive)
2061 (let ((type (framep (or frame (selected-frame)))))
2062 (cond
2063 ((eq type 'x) (x-menu-bar-open frame))
2064 ((eq type 'w32) (w32-menu-bar-open frame))
2065 (t (with-selected-frame (or frame (selected-frame))
2066 (tmm-menubar))))))
2068 (global-set-key [f10] 'menu-bar-open)
2070 (provide 'menu-bar)
2072 ;; arch-tag: 6e6a3c22-4ec4-4d3d-8190-583f8ef94ced
2073 ;;; menu-bar.el ends here