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