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