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