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