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