Mercurial > hg > xemacs-beta
comparison lisp/menubar-items.el @ 282:c42ec1d1cded r21-0b39
Import from CVS: tag r21-0b39
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:33:18 +0200 |
parents | |
children | 558f606b08ae |
comparison
equal
deleted
inserted
replaced
281:090b52736db2 | 282:c42ec1d1cded |
---|---|
1 ;;; menubar-items.el --- Menubar and popup-menu content for XEmacs. | |
2 | |
3 ;; Copyright (C) 1991-1995, 1997-1998 Free Software Foundation, Inc. | |
4 ;; Copyright (C) 1995 Tinker Systems and INS Engineering Corp. | |
5 ;; Copyright (C) 1995 Sun Microsystems. | |
6 ;; Copyright (C) 1995, 1996 Ben Wing. | |
7 ;; Copyright (C) 1997 MORIOKA Tomohiko | |
8 | |
9 ;; Maintainer: XEmacs Development Team | |
10 ;; Keywords: frames, extensions, internal, dumped | |
11 | |
12 ;; This file is part of XEmacs. | |
13 | |
14 ;; XEmacs is free software; you can redistribute it and/or modify it | |
15 ;; under the terms of the GNU General Public License as published by | |
16 ;; the Free Software Foundation; either version 2, or (at your option) | |
17 ;; any later version. | |
18 | |
19 ;; XEmacs is distributed in the hope that it will be useful, but | |
20 ;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
22 ;; General Public License for more details. | |
23 | |
24 ;; You should have received a copy of the GNU General Public License | |
25 ;; along with Xmacs; see the file COPYING. If not, write to the | |
26 ;; Free Software Foundation, 59 Temple Place - Suite 330, | |
27 ;; Boston, MA 02111-1307, USA. | |
28 | |
29 ;;; Commentary: | |
30 | |
31 ;; This file is dumped with XEmacs (when window system and menubar support is | |
32 ;; compiled in). | |
33 | |
34 ;;; Code: | |
35 | |
36 ;;; Warning-free compile | |
37 (eval-when-compile | |
38 (defvar language-environment-list) | |
39 (defvar bookmark-alist) | |
40 (defvar language-info-alist) | |
41 (defvar current-language-environment) | |
42 (defvar tutorial-supported-languages)) | |
43 | |
44 (defconst default-menubar | |
45 (purecopy-menubar | |
46 ;; note backquote. | |
47 `( | |
48 ("File" | |
49 ["Open..." find-file] | |
50 ["Open in Other Window..." find-file-other-window] | |
51 ["Open in New Frame..." find-file-other-frame] | |
52 ["Insert File..." insert-file] | |
53 ["View File..." view-file] | |
54 "------" | |
55 ["Save" save-buffer | |
56 :active (buffer-modified-p) | |
57 :suffix (if put-buffer-names-in-file-menu (buffer-name) "")] | |
58 ["Save As..." write-file] | |
59 ["Save Some Buffers" save-some-buffers] | |
60 "-----" | |
61 ["Print Buffer" lpr-buffer | |
62 :active (fboundp 'lpr-buffer) | |
63 :suffix (if put-buffer-names-in-file-menu (buffer-name) "")] | |
64 ["Pretty-Print Buffer" ps-print-buffer-with-faces | |
65 :active (fboundp 'ps-print-buffer-with-faces) | |
66 :suffix (if put-buffer-names-in-file-menu (buffer-name) "")] | |
67 "-----" | |
68 ["New Frame" make-frame] | |
69 ["Frame on Other Display..." make-frame-on-display] | |
70 ["Delete Frame" delete-frame | |
71 :active (not (eq (next-frame (selected-frame) 'nomini 'window-system) | |
72 (selected-frame)))] | |
73 "-----" | |
74 ["Split Window" split-window-vertically] | |
75 ["Un-Split (Keep This)" delete-other-windows | |
76 :active (not (one-window-p t))] | |
77 ["Un-Split (Keep Others)" delete-window | |
78 :active (not (one-window-p t))] | |
79 "-----" | |
80 ["Revert Buffer" revert-buffer | |
81 :active (or buffer-file-name revert-buffer-function) | |
82 :suffix (if put-buffer-names-in-file-menu (buffer-name) "")] | |
83 ["Delete Buffer" kill-this-buffer | |
84 :active t | |
85 :suffix (if put-buffer-names-in-file-menu (buffer-name) "")] | |
86 "-----" | |
87 ["Exit XEmacs" save-buffers-kill-emacs] | |
88 ) | |
89 | |
90 ("Edit" | |
91 ["Undo" advertised-undo | |
92 :active (and (not (eq buffer-undo-list t)) | |
93 (or buffer-undo-list pending-undo-list)) | |
94 :suffix (if (or (eq last-command 'undo) | |
95 (eq last-command 'advertised-undo)) | |
96 "More" "")] | |
97 ["Redo" redo | |
98 :included (fboundp 'redo) | |
99 :active (not (or (eq buffer-undo-list t) | |
100 (eq last-buffer-undo-list nil) | |
101 (not (or (eq last-buffer-undo-list buffer-undo-list) | |
102 (and (null (car-safe buffer-undo-list)) | |
103 (eq last-buffer-undo-list | |
104 (cdr-safe buffer-undo-list))))) | |
105 (or (eq buffer-undo-list pending-undo-list) | |
106 (eq (cdr buffer-undo-list) pending-undo-list)))) | |
107 :suffix (if (eq last-command 'redo) "More" "")] | |
108 ["Cut" kill-primary-selection | |
109 :active (selection-owner-p)] | |
110 ["Copy" copy-primary-selection | |
111 :active (selection-owner-p)] | |
112 ["Paste" yank-clipboard-selection | |
113 :active (selection-exists-p 'CLIPBOARD)] | |
114 ["Clear" delete-primary-selection | |
115 :active (selection-owner-p)] | |
116 "----" | |
117 ["Search..." isearch-forward] | |
118 ["Search Backward..." isearch-backward] | |
119 ["Replace..." query-replace] | |
120 "----" | |
121 ["Search (Regexp)..." isearch-forward-regexp] | |
122 ["Search Backward (Regexp)..." isearch-backward-regexp] | |
123 ["Replace (Regexp)..." query-replace-regexp] | |
124 "----" | |
125 ["Goto Line..." goto-line] | |
126 ["What Line" what-line] | |
127 ("Bookmarks" | |
128 :filter bookmark-menu-filter) | |
129 "----" | |
130 ["Start Macro Recording" start-kbd-macro | |
131 :active (not defining-kbd-macro)] | |
132 ["End Macro Recording" end-kbd-macro | |
133 :active defining-kbd-macro] | |
134 ["Execute Last Macro" call-last-kbd-macro | |
135 :active last-kbd-macro] | |
136 "----" | |
137 ["Show Message Log" show-message-log] | |
138 ) | |
139 | |
140 ,@(if (featurep 'mule) | |
141 '(("Mule" | |
142 ("Describe language support") | |
143 ("Set language environment") | |
144 "--" | |
145 ["Toggle input method" toggle-input-method] | |
146 ["Select input method" select-input-method] | |
147 ["Describe input method" describe-input-method] | |
148 "--" | |
149 ["Describe current coding systems" | |
150 describe-current-coding-system] | |
151 ["Set coding system of buffer file" | |
152 set-buffer-file-coding-system] | |
153 ;; not implemented yet | |
154 ["Set coding system of terminal" | |
155 set-terminal-coding-system :active nil] | |
156 ;; not implemented yet | |
157 ["Set coding system of keyboard" | |
158 set-keyboard-coding-system :active nil] | |
159 ;; not implemented yet | |
160 ["Set coding system of process" | |
161 set-current-process-coding-system :active nil] | |
162 "--" | |
163 ["Show character table" view-charset-by-menu] | |
164 ;; not implemented yet | |
165 ["Show diagnosis for MULE" mule-diag :active nil] | |
166 ["Show many languages" view-hello-file]))) | |
167 | |
168 ("Apps" | |
169 ["Read Mail (VM)..." vm | |
170 :active (fboundp 'vm)] | |
171 ["Read Mail (MH)..." (mh-rmail t) | |
172 :active (fboundp 'mh-rmail)] | |
173 ["Send mail..." compose-mail | |
174 :active (fboundp 'compose-mail)] | |
175 ["Usenet News" gnus | |
176 :active (fboundp 'gnus)] | |
177 ["Browse the Web" w3 | |
178 :active (fboundp 'w3)] | |
179 ["Gopher" gopher | |
180 :active (fboundp 'gopher)] | |
181 "----" | |
182 ["Spell-Check Buffer" ispell-buffer | |
183 :active (fboundp 'ispell-buffer)] | |
184 ["Toggle VI emulation" toggle-viper-mode | |
185 :active (fboundp 'toggle-viper-mode)] | |
186 "----" | |
187 ("Calendar" | |
188 ["3-Month Calendar" calendar | |
189 :active (fboundp 'calendar)] | |
190 ["Diary" diary | |
191 :active (fboundp 'diary)] | |
192 ["Holidays" holidays | |
193 :active (fboundp 'holidays)] | |
194 ;; we're all pagans at heart ... | |
195 ["Phases of the Moon" phases-of-moon | |
196 :active (fboundp 'phases-of-moon)] | |
197 ["Sunrise/Sunset" sunrise-sunset | |
198 :active (fboundp 'sunrise-sunset)]) | |
199 | |
200 ("Games" | |
201 ["Mine Game" xmine | |
202 :active (fboundp 'xmine)] | |
203 ["Tetris" tetris | |
204 :active (fboundp 'tetris)] | |
205 ["Sokoban" sokoban | |
206 :active (fboundp 'sokoban)] | |
207 ["Quote from Zippy" yow | |
208 :active (fboundp 'yow)] | |
209 ["Psychoanalyst" doctor | |
210 :active (fboundp 'doctor)] | |
211 ["Psychoanalyze Zippy!" psychoanalyze-pinhead | |
212 :active (fboundp 'psychoanalyze-pinhead)] | |
213 ["Random Flames" flame | |
214 :active (fboundp 'flame)] | |
215 ["Dunnet (Adventure)" dunnet | |
216 :active (fboundp 'dunnet)] | |
217 ["Towers of Hanoi" hanoi | |
218 :active (fboundp 'hanoi)] | |
219 ["Game of Life" life | |
220 :active (fboundp 'life)] | |
221 ["Multiplication Puzzle" mpuz | |
222 :active (fboundp 'mpuz)])) | |
223 | |
224 ("Options" | |
225 ("Customize" | |
226 ("Emacs" :filter (lambda (&rest junk) | |
227 (cdr (custom-menu-create 'emacs)))) | |
228 ["Group..." customize-group] | |
229 ["Variable..." customize-variable] | |
230 ["Face..." customize-face] | |
231 ["Saved..." customize-saved] | |
232 ["Set..." customize-customized] | |
233 ["Apropos..." customize-apropos] | |
234 ["Browse..." customize-browse]) | |
235 ("Editing Options" | |
236 ["Overstrike" | |
237 (progn | |
238 (setq overwrite-mode (if overwrite-mode nil 'overwrite-mode-textual)) | |
239 (customize-set-variable 'overwrite-mode overwrite-mode)) | |
240 :style toggle :selected overwrite-mode] | |
241 ["Case Sensitive Search" | |
242 (customize-set-variable 'case-fold-search | |
243 (setq case-fold-search (not case-fold-search))) | |
244 :style toggle :selected (not case-fold-search)] | |
245 ["Case Matching Replace" | |
246 (customize-set-variable 'case-replace (not case-replace)) | |
247 :style toggle :selected case-replace] | |
248 ["Auto Delete Selection" | |
249 (customize-set-variable 'pending-delete-mode (not pending-delete-mode)) | |
250 :style toggle | |
251 :selected (and (boundp 'pending-delete-mode) pending-delete-mode) | |
252 :active (boundp 'pending-delete-mode)] | |
253 ["Active Regions" | |
254 (customize-set-variable 'zmacs-regions (not zmacs-regions)) | |
255 :style toggle :selected zmacs-regions] | |
256 ["Mouse Paste At Text Cursor" | |
257 (customize-set-variable 'mouse-yank-at-point (not mouse-yank-at-point)) | |
258 :style toggle :selected mouse-yank-at-point] | |
259 ("Newline at end of file..." | |
260 ["Don't require" | |
261 (customize-set-variable 'require-final-newline nil) | |
262 :style radio :selected (not require-final-newline)] | |
263 ["Require" | |
264 (customize-set-variable 'require-final-newline t) | |
265 :style radio :selected (eq require-final-newline t)] | |
266 ["Ask" | |
267 (customize-set-variable 'require-final-newline 'ask) | |
268 :style radio :selected (and require-final-newline | |
269 (not (eq require-final-newline t)))]) | |
270 ["Add Newline When Moving Past End" | |
271 (customize-set-variable 'next-line-add-newlines | |
272 (not next-line-add-newlines)) | |
273 :style toggle :selected next-line-add-newlines] | |
274 ) | |
275 ("General Options" | |
276 ["Teach Extended Commands" | |
277 (customize-set-variable 'teach-extended-commands-p | |
278 (not teach-extended-commands-p)) | |
279 :style toggle :selected teach-extended-commands-p] | |
280 ["Debug On Error" | |
281 (customize-set-variable 'debug-on-error (not debug-on-error)) | |
282 :style toggle :selected debug-on-error] | |
283 ["Debug On Quit" | |
284 (customize-set-variable 'debug-on-quit (not debug-on-quit)) | |
285 :style toggle :selected debug-on-quit] | |
286 ) | |
287 ("Printing Options" | |
288 ["Command-Line Switches for `lpr'/`lp'..." | |
289 ;; better to directly open a customization buffer, since the value | |
290 ;; must be a list of strings, which is somewhat complex to prompt for. | |
291 (customize-variable 'lpr-switches) | |
292 (boundp 'lpr-switches)] | |
293 ("Pretty-Print Paper Size" | |
294 ["Letter" | |
295 (customize-set-variable 'ps-paper-type 'letter) | |
296 :style radio | |
297 :selected (and (boundp 'ps-paper-type) (eq ps-paper-type 'letter)) | |
298 :active (boundp 'ps-paper-type)] | |
299 ["Letter-small" | |
300 (customize-set-variable 'ps-paper-type 'letter-small) | |
301 :style radio | |
302 :selected (and (boundp 'ps-paper-type) | |
303 (eq ps-paper-type 'letter-small)) | |
304 :active (boundp 'ps-paper-type)] | |
305 ["Legal" | |
306 (customize-set-variable 'ps-paper-type 'legal) | |
307 :style radio | |
308 :selected (and (boundp 'ps-paper-type) (eq ps-paper-type 'legal)) | |
309 :active (boundp 'ps-paper-type)] | |
310 ["Statement" | |
311 (customize-set-variable 'ps-paper-type 'statement) | |
312 :style radio | |
313 :selected (and (boundp 'ps-paper-type) (eq ps-paper-type 'statement)) | |
314 :active (boundp 'ps-paper-type)] | |
315 ["Executive" | |
316 (customize-set-variable 'ps-paper-type 'executive) | |
317 :style radio | |
318 :selected (and (boundp 'ps-paper-type) (eq ps-paper-type 'executive)) | |
319 :active (boundp 'ps-paper-type)] | |
320 ["Tabloid" | |
321 (customize-set-variable 'ps-paper-type 'tabloid) | |
322 :style radio | |
323 :selected (and (boundp 'ps-paper-type) (eq ps-paper-type 'tabloid)) | |
324 :active (boundp 'ps-paper-type)] | |
325 ["Ledger" | |
326 (customize-set-variable 'ps-paper-type 'ledger) | |
327 :style radio | |
328 :selected (and (boundp 'ps-paper-type) (eq ps-paper-type 'ledger)) | |
329 :active (boundp 'ps-paper-type)] | |
330 ["A3" | |
331 (customize-set-variable 'ps-paper-type 'a3) | |
332 :style radio | |
333 :selected (and (boundp 'ps-paper-type) (eq ps-paper-type 'a3)) | |
334 :active (boundp 'ps-paper-type)] | |
335 ["A4" | |
336 (customize-set-variable 'ps-paper-type 'a4) | |
337 :style radio | |
338 :selected (and (boundp 'ps-paper-type) (eq ps-paper-type 'a4)) | |
339 :active (boundp 'ps-paper-type)] | |
340 ["A4small" | |
341 (customize-set-variable 'ps-paper-type 'a4small) | |
342 :style radio | |
343 :selected (and (boundp 'ps-paper-type) (eq ps-paper-type 'a4small)) | |
344 :active (boundp 'ps-paper-type)] | |
345 ["B4" | |
346 (customize-set-variable 'ps-paper-type 'b4) | |
347 :style radio | |
348 :selected (and (boundp 'ps-paper-type) (eq ps-paper-type 'b4)) | |
349 :active (boundp 'ps-paper-type)] | |
350 ["B5" | |
351 (customize-set-variable 'ps-paper-type 'b5) | |
352 :style radio | |
353 :selected (and (boundp 'ps-paper-type) (eq ps-paper-type 'b5)) | |
354 :active (boundp 'ps-paper-type)] | |
355 ) | |
356 ["Color Printing" | |
357 (cond (ps-print-color-p | |
358 (customize-set-variable 'ps-print-color-p nil) | |
359 ;; I'm wondering whether all this muck is usefull. | |
360 (and (boundp 'original-face-background) | |
361 original-face-background | |
362 (set-face-background 'default original-face-background))) | |
363 (t | |
364 (customize-set-variable 'ps-print-color-p t) | |
365 (setq original-face-background | |
366 (face-background-instance 'default)) | |
367 (set-face-background 'default "white"))) | |
368 :style toggle | |
369 :selected (and (boundp 'ps-print-color-p) ps-print-color-p) | |
370 :active (boundp 'ps-print-color-p)]) | |
371 ("\"Other Window\" Location" | |
372 ["Always in Same Frame" | |
373 (customize-set-variable | |
374 'get-frame-for-buffer-default-instance-limit nil) | |
375 :style radio | |
376 :selected (null get-frame-for-buffer-default-instance-limit)] | |
377 ["Other Frame (2 Frames Max)" | |
378 (customize-set-variable 'get-frame-for-buffer-default-instance-limit 2) | |
379 :style radio | |
380 :selected (eq 2 get-frame-for-buffer-default-instance-limit)] | |
381 ["Other Frame (3 Frames Max)" | |
382 (customize-set-variable 'get-frame-for-buffer-default-instance-limit 3) | |
383 :style radio | |
384 :selected (eq 3 get-frame-for-buffer-default-instance-limit)] | |
385 ["Other Frame (4 Frames Max)" | |
386 (customize-set-variable 'get-frame-for-buffer-default-instance-limit 4) | |
387 :style radio | |
388 :selected (eq 4 get-frame-for-buffer-default-instance-limit)] | |
389 ["Other Frame (5 Frames Max)" | |
390 (customize-set-variable 'get-frame-for-buffer-default-instance-limit 5) | |
391 :style radio | |
392 :selected (eq 5 get-frame-for-buffer-default-instance-limit)] | |
393 ["Always Create New Frame" | |
394 (customize-set-variable 'get-frame-for-buffer-default-instance-limit 0) | |
395 :style radio | |
396 :selected (eq 0 get-frame-for-buffer-default-instance-limit)] | |
397 "-----" | |
398 ["Temp Buffers Always in Same Frame" | |
399 (customize-set-variable 'temp-buffer-show-function | |
400 'show-temp-buffer-in-current-frame) | |
401 :style radio | |
402 :selected (eq temp-buffer-show-function | |
403 'show-temp-buffer-in-current-frame)] | |
404 ["Temp Buffers Like Other Buffers" | |
405 (customize-set-variable 'temp-buffer-show-function nil) | |
406 :style radio | |
407 :selected (null temp-buffer-show-function)] | |
408 "-----" | |
409 ["Make current frame gnuserv target" | |
410 (customize-set-variable 'gnuserv-frame (if (eq gnuserv-frame t) nil t)) | |
411 :style toggle | |
412 :selected (and (boundp 'gnuserv-frame) (eq gnuserv-frame t)) | |
413 :active (boundp 'gnuserv-frame)] | |
414 ) | |
415 "-----" | |
416 ("Syntax Highlighting" | |
417 ["In This Buffer" | |
418 (progn ;; becomes buffer local | |
419 (font-lock-mode) | |
420 (customize-set-variable 'font-lock-mode font-lock-mode)) | |
421 :style toggle | |
422 :selected (and (boundp 'font-lock-mode) font-lock-mode) | |
423 :active (boundp 'font-lock-mode)] | |
424 ["Automatic" | |
425 (customize-set-variable 'font-lock-auto-fontify | |
426 (not font-lock-auto-fontify)) | |
427 :style toggle | |
428 :selected (and (boundp 'font-lock-auto-fontify) font-lock-auto-fontify) | |
429 :active (fboundp 'font-lock-mode)] | |
430 "-----" | |
431 ["Fonts" | |
432 (progn | |
433 (require 'font-lock) | |
434 (font-lock-use-default-fonts) | |
435 (customize-set-variable 'font-lock-use-fonts t) | |
436 (customize-set-variable 'font-lock-use-colors nil) | |
437 (font-lock-mode 1)) | |
438 :style radio | |
439 :selected (and (boundp 'font-lock-use-fonts) font-lock-use-fonts) | |
440 :active (fboundp 'font-lock-mode)] | |
441 ["Colors" | |
442 (progn | |
443 (require 'font-lock) | |
444 (font-lock-use-default-colors) | |
445 (customize-set-variable 'font-lock-use-colors t) | |
446 (customize-set-variable 'font-lock-use-fonts nil) | |
447 (font-lock-mode 1)) | |
448 :style radio | |
449 :selected (and (boundp 'font-lock-use-colors) font-lock-use-colors) | |
450 :active (boundp 'font-lock-mode)] | |
451 "-----" | |
452 ["Least" | |
453 (progn | |
454 (require 'font-lock) | |
455 (if (or (and (not (integerp font-lock-maximum-decoration)) | |
456 (not (eq t font-lock-maximum-decoration))) | |
457 (and (integerp font-lock-maximum-decoration) | |
458 (<= font-lock-maximum-decoration 0))) | |
459 nil | |
460 (customize-set-variable 'font-lock-maximum-decoration nil) | |
461 (font-lock-recompute-variables))) | |
462 :style radio | |
463 :active (fboundp 'font-lock-mode) | |
464 :selected (and (boundp 'font-lock-maximium-decoration) | |
465 (or (and (not (integerp font-lock-maximum-decoration)) | |
466 (not (eq t font-lock-maximum-decoration))) | |
467 (and (integerp font-lock-maximum-decoration) | |
468 (<= font-lock-maximum-decoration 0))))] | |
469 ["More" | |
470 (progn | |
471 (require 'font-lock) | |
472 (if (and (integerp font-lock-maximum-decoration) | |
473 (= 1 font-lock-maximum-decoration)) | |
474 nil | |
475 (customize-set-variable 'font-lock-maximum-decoration 1) | |
476 (font-lock-recompute-variables))) | |
477 :style radio | |
478 :active (fboundp 'font-lock-mode) | |
479 :selected (and (boundp 'font-lock-maximium-decoration) | |
480 (integerp font-lock-maximum-decoration) | |
481 (= 1 font-lock-maximum-decoration))] | |
482 ["Even More" | |
483 (progn | |
484 (require 'font-lock) | |
485 (if (and (integerp font-lock-maximum-decoration) | |
486 (= 2 font-lock-maximum-decoration)) | |
487 nil | |
488 (customize-set-variable 'font-lock-maximum-decoration 2) | |
489 (font-lock-recompute-variables))) | |
490 :style radio | |
491 :active (fboundp 'font-lock-mode) | |
492 :selected (and (boundp 'font-lock-maximum-decoration) | |
493 (integerp font-lock-maximum-decoration) | |
494 (= 2 font-lock-maximum-decoration))] | |
495 ["Most" | |
496 (progn | |
497 (require 'font-lock) | |
498 (if (or (eq font-lock-maximum-decoration t) | |
499 (and (integerp font-lock-maximum-decoration) | |
500 (>= font-lock-maximum-decoration 3))) | |
501 nil | |
502 (customize-set-variable 'font-lock-maximum-decoration t) | |
503 (font-lock-recompute-variables))) | |
504 :style radio | |
505 :active (fboundp 'font-lock-mode) | |
506 :selected (and (boundp 'font-lock-maximum-decoration) | |
507 (or (eq font-lock-maximum-decoration t) | |
508 (and (integerp font-lock-maximum-decoration) | |
509 (>= font-lock-maximum-decoration 3))))] | |
510 "-----" | |
511 ["Lazy" | |
512 (progn ;; becomes buffer local | |
513 (lazy-shot-mode) | |
514 (customize-set-variable 'lazy-shot-mode lazy-shot-mode) | |
515 ;; this shouldn't be necessary so there has to | |
516 ;; be a redisplay bug lurking somewhere (or | |
517 ;; possibly another event handler bug) | |
518 (redraw-modeline)) | |
519 :active (and (boundp 'font-lock-mode) (boundp 'lazy-shot-mode) | |
520 font-lock-mode) | |
521 :style toggle | |
522 :selected (and (boundp 'lazy-shot-mode) lazy-shot-mode)] | |
523 ["Caching" | |
524 (progn ;; becomes buffer local | |
525 (fast-lock-mode) | |
526 (customize-set-variable 'fast-lock-mode fast-lock-mode) | |
527 ;; this shouldn't be necessary so there has to | |
528 ;; be a redisplay bug lurking somewhere (or | |
529 ;; possibly another event handler bug) | |
530 (redraw-modeline)) | |
531 :active (and (boundp 'font-lock-mode) (boundp 'fast-lock-mode) | |
532 font-lock-mode) | |
533 :style toggle | |
534 :selected (and (boundp 'fast-lock-mode) fast-lock-mode)] | |
535 ) | |
536 ("Paren Highlighting" | |
537 ["None" | |
538 (customize-set-variable 'paren-mode nil) | |
539 :style radio | |
540 :selected (and (boundp 'paren-mode) (not paren-mode)) | |
541 :active (boundp 'paren-mode)] | |
542 ["Blinking Paren" | |
543 (customize-set-variable 'paren-mode 'blink-paren) | |
544 :style radio | |
545 :selected (and (boundp 'paren-mode) (eq paren-mode 'blink-paren)) | |
546 :active (boundp 'paren-mode)] | |
547 ["Steady Paren" | |
548 (customize-set-variable 'paren-mode 'paren) | |
549 :style radio | |
550 :selected (and (boundp 'paren-mode) (eq paren-mode 'paren)) | |
551 :active (boundp 'paren-mode)] | |
552 ["Expression" | |
553 (customize-set-variable 'paren-mode 'sexp) | |
554 :style radio | |
555 :selected (and (boundp 'paren-mode) (eq paren-mode 'sexp)) | |
556 :active (boundp 'paren-mode)] | |
557 ;; ["Nested Shading" | |
558 ;; (customize-set-variable 'paren-mode 'nested) | |
559 ;; :style radio | |
560 ;; :selected (and (boundp 'paren-mode) (eq paren-mode 'nested)) | |
561 ;; :active (boundp 'paren-mode)] | |
562 ) | |
563 "-----" | |
564 ("Frame Appearance" | |
565 ["Frame-Local Font Menu" | |
566 (customize-set-variable 'font-menu-this-frame-only-p | |
567 (not font-menu-this-frame-only-p)) | |
568 :style toggle | |
569 :selected (and (boundp 'font-menu-this-frame-only-p) | |
570 font-menu-this-frame-only-p)] | |
571 ,@(if (featurep 'scrollbar) | |
572 '(["Scrollbars" | |
573 (customize-set-variable 'scrollbars-visible-p | |
574 (not scrollbars-visible-p)) | |
575 :style toggle | |
576 :selected scrollbars-visible-p])) | |
577 ;; I don't think this is of any interest. - dverna apr. 98 | |
578 ;; ["3D Modeline" | |
579 ;; (progn | |
580 ;; (if (zerop (specifier-instance modeline-shadow-thickness)) | |
581 ;; (set-specifier modeline-shadow-thickness 2) | |
582 ;; (set-specifier modeline-shadow-thickness 0)) | |
583 ;; (redraw-modeline t)) | |
584 ;; :style toggle | |
585 ;; :selected (let ((thickness | |
586 ;; (specifier-instance modeline-shadow-thickness))) | |
587 ;; (and (integerp thickness) | |
588 ;; (> thickness 0)))] | |
589 ["Truncate Lines" | |
590 (progn ;; becomes buffer-local | |
591 (setq truncate-lines (not truncate-lines)) | |
592 (customize-set-variable 'truncate-lines truncate-lines)) | |
593 :style toggle | |
594 :selected truncate-lines] | |
595 ["Blinking Cursor" | |
596 (customize-set-variable 'blink-cursor-mode (not blink-cursor-mode)) | |
597 :style toggle | |
598 :selected (and (boundp 'blink-cursor-mode) blink-cursor-mode) | |
599 :active (boundp 'blink-cursor-mode)] | |
600 "-----" | |
601 ["Block cursor" | |
602 (progn | |
603 (customize-set-variable 'bar-cursor nil) | |
604 (force-cursor-redisplay)) | |
605 :style radio | |
606 :selected (null bar-cursor)] | |
607 ["Bar cursor (1 pixel)" | |
608 (progn | |
609 (customize-set-variable 'bar-cursor t) | |
610 (force-cursor-redisplay)) | |
611 :style radio | |
612 :selected (eq bar-cursor t)] | |
613 ["Bar cursor (2 pixels)" | |
614 (progn | |
615 (customize-set-variable 'bar-cursor 2) | |
616 (force-cursor-redisplay)) | |
617 :style radio | |
618 :selected (and bar-cursor (not (eq bar-cursor t)))] | |
619 "------" | |
620 ["Line Numbers" | |
621 (progn | |
622 (customize-set-variable 'line-number-mode (not line-number-mode)) | |
623 (redraw-modeline)) | |
624 :style toggle :selected line-number-mode] | |
625 ["Column Numbers" | |
626 (progn | |
627 (customize-set-variable 'column-number-mode | |
628 (not column-number-mode)) | |
629 (redraw-modeline)) | |
630 :style toggle :selected column-number-mode] | |
631 ) | |
632 ("Menubar Appearance" | |
633 ["Buffers Menu Length..." | |
634 (customize-set-variable | |
635 'buffers-menu-max-size | |
636 ;; would it be better to open a customization buffer ? | |
637 (let ((val | |
638 (read-number | |
639 "Enter number of buffers to display (or 0 for unlimited): "))) | |
640 (if (eq val 0) nil val)))] | |
641 ["Multi-Operation Buffers Sub-Menus" | |
642 (customize-set-variable 'complex-buffers-menu-p | |
643 (not complex-buffers-menu-p)) | |
644 :style toggle | |
645 :selected complex-buffers-menu-p] | |
646 ("Buffers Menu Sorting" | |
647 ["Most Recently Used" | |
648 (progn | |
649 (customize-set-variable 'buffers-menu-sort-function nil) | |
650 (customize-set-variable 'buffers-menu-grouping-function nil)) | |
651 :style radio | |
652 :selected (null buffers-menu-sort-function)] | |
653 ["Alphabetically" | |
654 (progn | |
655 (customize-set-variable 'buffers-menu-sort-function | |
656 'sort-buffers-menu-alphabetically) | |
657 (customize-set-variable 'buffers-menu-grouping-function nil)) | |
658 :style radio | |
659 :selected (eq 'sort-buffers-menu-alphabetically | |
660 buffers-menu-sort-function)] | |
661 ["By Major Mode, Then Alphabetically" | |
662 (progn | |
663 (customize-set-variable | |
664 'buffers-menu-sort-function | |
665 'sort-buffers-menu-by-mode-then-alphabetically) | |
666 (customize-set-variable | |
667 'buffers-menu-grouping-function | |
668 'group-buffers-menu-by-mode-then-alphabetically)) | |
669 :style radio | |
670 :selected (eq 'sort-buffers-menu-by-mode-then-alphabetically | |
671 buffers-menu-sort-function)]) | |
672 ["Submenus for Buffer Groups" | |
673 (customize-set-variable 'buffers-menu-submenus-for-groups-p | |
674 (not buffers-menu-submenus-for-groups-p)) | |
675 :style toggle | |
676 :selected buffers-menu-submenus-for-groups-p] | |
677 "---" | |
678 ["Ignore Scaled Fonts" | |
679 (customize-set-variable 'font-menu-ignore-scaled-fonts | |
680 (not font-menu-ignore-scaled-fonts)) | |
681 :style toggle | |
682 :selected (and (boundp 'font-menu-ignore-scaled-fonts) | |
683 font-menu-ignore-scaled-fonts)] | |
684 ) | |
685 ,@(if (featurep 'toolbar) | |
686 '(("Toolbar Appearance" | |
687 ["Visible" | |
688 (customize-set-variable 'toolbar-visible-p | |
689 (not toolbar-visible-p)) | |
690 :style toggle | |
691 :selected toolbar-visible-p] | |
692 ["Captioned" | |
693 (customize-set-variable 'toolbar-captioned-p | |
694 (not toolbar-captioned-p)) | |
695 :style toggle | |
696 :selected toolbar-captioned-p] | |
697 ("Default Location" | |
698 ["Top" | |
699 (customize-set-variable 'default-toolbar-position 'top) | |
700 :style radio | |
701 :selected (eq default-toolbar-position 'top)] | |
702 ["Bottom" | |
703 (customize-set-variable 'default-toolbar-position 'bottom) | |
704 :style radio | |
705 :selected (eq default-toolbar-position 'bottom)] | |
706 ["Left" | |
707 (customize-set-variable 'default-toolbar-position 'left) | |
708 :style radio | |
709 :selected (eq default-toolbar-position 'left)] | |
710 ["Right" | |
711 (customize-set-variable 'default-toolbar-position 'right) | |
712 :style radio | |
713 :selected (eq default-toolbar-position 'right)] | |
714 ) | |
715 ))) | |
716 ("Mouse" | |
717 ["Avoid Text..." | |
718 (customize-set-variable 'mouse-avoidance-mode | |
719 (if mouse-avoidance-mode nil 'banish)) | |
720 :style toggle | |
721 :selected (and (boundp 'mouse-avoidance-mode) mouse-avoidance-mode) | |
722 :active (and (boundp 'mouse-avoidance-mode) | |
723 window-system (eq (device-type) 'x))] | |
724 ["strokes-mode" | |
725 (customize-set-variable 'strokes-mode (not strokes-mode)) | |
726 :style toggle | |
727 :selected (and (boundp 'strokes-mode) strokes-mode) | |
728 :active (and (boundp 'strokes-mode) | |
729 window-system (eq (device-type) 'x))] | |
730 ) | |
731 ("Open URLs With" | |
732 ["Emacs-W3" | |
733 (customize-set-variable 'browse-url-browser-function 'browse-url-w3) | |
734 :style radio | |
735 :selected (and (boundp 'browse-url-browser-function) | |
736 (eq browse-url-browser-function 'browse-url-w3)) | |
737 :active (and (boundp 'browse-url-browser-function) | |
738 (fboundp 'browse-url-w3) | |
739 (fboundp 'w3-fetch))] | |
740 ["Netscape" | |
741 (customize-set-variable 'browse-url-browser-function | |
742 'browse-url-netscape) | |
743 :style radio | |
744 :selected (and (boundp 'browse-url-browser-function) | |
745 (eq browse-url-browser-function 'browse-url-netscape)) | |
746 :active (and (boundp 'browse-url-browser-function) | |
747 (fboundp 'browse-url-netscape))] | |
748 ["Mosaic" | |
749 (customize-set-variable 'browse-url-browser-function | |
750 'browse-url-mosaic) | |
751 :style radio | |
752 :selected (and (boundp 'browse-url-browser-function) | |
753 (eq browse-url-browser-function 'browse-url-mosaic)) | |
754 :active (and (boundp 'browse-url-browser-function) | |
755 (fboundp 'browse-url-mosaic))] | |
756 ["Mosaic (CCI)" | |
757 (customize-set-variable 'browse-url-browser-function 'browse-url-cci) | |
758 :style radio | |
759 :selected (and (boundp 'browse-url-browser-function) | |
760 (eq browse-url-browser-function 'browse-url-cci)) | |
761 :active (and (boundp 'browse-url-browser-function) | |
762 (fboundp 'browse-url-cci))] | |
763 ["IXI Mosaic" | |
764 (customize-set-variable 'browse-url-browser-function | |
765 'browse-url-iximosaic) | |
766 :style radio | |
767 :selected (and (boundp 'browse-url-browser-function) | |
768 (eq browse-url-browser-function 'browse-url-iximosaic)) | |
769 :active (and (boundp 'browse-url-browser-function) | |
770 (fboundp 'browse-url-iximosaic))] | |
771 ["Lynx (xterm)" | |
772 (customize-set-variable 'browse-url-browser-function | |
773 'browse-url-lynx-xterm) | |
774 :style radio | |
775 :selected (and (boundp 'browse-url-browser-function) | |
776 (eq browse-url-browser-function 'browse-url-lynx-xterm)) | |
777 :active (and (boundp 'browse-url-browser-function) | |
778 (fboundp 'browse-url-lynx-xterm))] | |
779 ["Lynx (xemacs)" | |
780 (customize-set-variable 'browse-url-browser-function | |
781 'browse-url-lynx-emacs) | |
782 :style radio | |
783 :selected (and (boundp 'browse-url-browser-function) | |
784 (eq browse-url-browser-function 'browse-url-lynx-emacs)) | |
785 :active (and (boundp 'browse-url-browser-function) | |
786 (fboundp 'browse-url-lynx-emacs))] | |
787 ["Grail" | |
788 (customize-set-variable 'browse-url-browser-function | |
789 'browse-url-grail) | |
790 :style radio | |
791 :selected (and (boundp 'browse-url-browser-function) | |
792 (eq browse-url-browser-function 'browse-url-grail)) | |
793 :active (and (boundp 'browse-url-browser-function) | |
794 (fboundp 'browse-url-grail))] | |
795 ) | |
796 "-----" | |
797 ["Browse Faces..." (customize-face nil)] | |
798 ("Font" :filter font-menu-family-constructor) | |
799 ("Size" :filter font-menu-size-constructor) | |
800 ("Weight" :filter font-menu-weight-constructor) | |
801 "-----" | |
802 ["Save Options" customize-save-customized] | |
803 ) | |
804 | |
805 ("Buffers" | |
806 :filter buffers-menu-filter | |
807 ["Read Only" (toggle-read-only) | |
808 :style toggle :selected buffer-read-only] | |
809 ["List All Buffers" list-buffers] | |
810 "--" | |
811 ) | |
812 | |
813 ("Tools" | |
814 ["Grep..." grep | |
815 :active (fboundp 'grep)] | |
816 ["Compile..." compile | |
817 :active (fboundp 'compile)] | |
818 ["Shell" shell | |
819 :active (fboundp 'shell)] | |
820 ["Shell Command..." shell-command | |
821 :active (fboundp 'shell-command)] | |
822 ["Shell Command on Region..." shell-command-on-region | |
823 :active (and (fboundp 'shell-command-on-region) (region-exists-p))] | |
824 ["Debug (GDB)..." gdb | |
825 :active (fboundp 'gdb)] | |
826 ["Debug (DBX)..." dbx | |
827 :active (fboundp 'dbx)] | |
828 "-----" | |
829 ("Tags" | |
830 ["Find Tag..." find-tag] | |
831 ["Find Other Window..." find-tag-other-window] | |
832 ["Next Tag..." (find-tag nil)] | |
833 ["Next Other Window..." (find-tag-other-window nil)] | |
834 ["Next File" next-file] | |
835 "-----" | |
836 ["Tags Search..." tags-search] | |
837 ["Tags Replace..." tags-query-replace] | |
838 ["Continue Search/Replace" tags-loop-continue] | |
839 "-----" | |
840 ["Pop stack" pop-tag-mark] | |
841 ["Apropos..." tags-apropos] | |
842 "-----" | |
843 ["Set Tags Table File..." visit-tags-table] | |
844 )) | |
845 | |
846 nil ; the partition: menus after this are flushright | |
847 | |
848 ("Help" | |
849 ["About XEmacs..." about-xemacs] | |
850 ("Basics" | |
851 ["Installation" describe-installation | |
852 :active (boundp 'Installation-string)] | |
853 ;; Tutorials. | |
854 ,(if (featurep 'mule) | |
855 ;; Mule tutorials. | |
856 (let ((lang language-info-alist) | |
857 submenu tut) | |
858 (while lang | |
859 (and (setq tut (assq 'tutorial (car lang))) | |
860 (not (string= (caar lang) "ASCII")) | |
861 (setq | |
862 submenu | |
863 (cons | |
864 `[,(caar lang) (help-with-tutorial nil ,(cdr tut))] | |
865 submenu))) | |
866 (setq lang (cdr lang))) | |
867 (append `("Tutorials" | |
868 :filter tutorials-menu-filter | |
869 ["Default" help-with-tutorial t | |
870 ,(concat "(" current-language-environment ")")]) | |
871 submenu)) | |
872 ;; Non mule tutorials. | |
873 (let ((lang tutorial-supported-languages) | |
874 submenu) | |
875 (while lang | |
876 (setq submenu | |
877 (cons | |
878 `[,(caar lang) | |
879 (help-with-tutorial ,(format "TUTORIAL.%s" | |
880 (cadr (car lang))))] | |
881 submenu)) | |
882 (setq lang (cdr lang))) | |
883 (append '("Tutorials" | |
884 ["English" help-with-tutorial]) | |
885 submenu))) | |
886 ["News" view-emacs-news] | |
887 ["Packages" finder-by-keyword] | |
888 ["Splash" xemacs-splash-buffer]) | |
889 "-----" | |
890 ("XEmacs FAQ" | |
891 ["FAQ (local)" xemacs-local-faq] | |
892 ["FAQ via WWW" xemacs-www-faq (boundp 'browse-url-browser-function)] | |
893 ["Home Page" xemacs-www-page (boundp 'browse-url-browser-function)]) | |
894 ("Samples" | |
895 ["Sample .emacs" (find-file (expand-file-name "sample.emacs" | |
896 data-directory))] | |
897 ["Sample .Xdefaults" (find-file (expand-file-name "sample.Xdefaults" | |
898 data-directory))] | |
899 ["Sample enriched" (find-file (expand-file-name "enriched.doc" | |
900 data-directory))]) | |
901 "-----" | |
902 ("Lookup in Info" | |
903 ["Key Binding..." Info-goto-emacs-key-command-node] | |
904 ["Command..." Info-goto-emacs-command-node] | |
905 ["Function..." Info-elisp-ref] | |
906 ["Topic..." Info-query]) | |
907 ("Manuals" | |
908 ["Info" info] | |
909 ["Unix Manual..." manual-entry]) | |
910 ("Commands & Keys" | |
911 ["Mode" describe-mode] | |
912 ["Apropos..." hyper-apropos] | |
913 ["Apropos Docs..." apropos-documentation] | |
914 "-----" | |
915 ["Key..." describe-key] | |
916 ["Bindings" describe-bindings] | |
917 ["Mouse Bindings" describe-pointer] | |
918 ["Recent Keys" view-lossage] | |
919 "-----" | |
920 ["Function..." describe-function] | |
921 ["Variable..." describe-variable] | |
922 ["Locate Command..." where-is]) | |
923 "-----" | |
924 ["Recent Messages" view-lossage] | |
925 ("Misc" | |
926 ["No Warranty" describe-no-warranty] | |
927 ["XEmacs License" describe-copying] | |
928 ["The Latest Version" describe-distribution]) | |
929 ["Submit Bug Report" send-pr])))) | |
930 | |
931 | |
932 (defun maybe-add-init-button () | |
933 "Don't call this. | |
934 Adds `Load .emacs' button to menubar when starting up with -q." | |
935 ;; by Stig@hackvan.com | |
936 (cond | |
937 (init-file-user nil) | |
938 ((file-exists-p (cond | |
939 ((eq system-type 'ms-dos) | |
940 (concat "~" (user-login-name) "/_emacs")) | |
941 ((eq system-type 'vax-vms) | |
942 "sys$login:.emacs") | |
943 (t | |
944 (concat "~" (user-login-name) "/.emacs")))) | |
945 (add-menu-button nil | |
946 ["Load .emacs" | |
947 (progn (delete-menu-item '("Load .emacs")) | |
948 (load-user-init-file (user-login-name))) | |
949 ] | |
950 "Help")) | |
951 (t nil))) | |
952 | |
953 (add-hook 'before-init-hook 'maybe-add-init-button) | |
954 | |
955 | |
956 ;;; The File menu | |
957 | |
958 (defvar put-buffer-names-in-file-menu t) | |
959 | |
960 | |
961 ;;; The Bookmarks menu | |
962 | |
963 (defun bookmark-menu-filter (&rest ignore) | |
964 (let ((definedp (and (boundp 'bookmark-alist) | |
965 bookmark-alist | |
966 t))) | |
967 `(,(if definedp | |
968 '("Jump to Bookmark" | |
969 :filter (lambda (&rest junk) | |
970 (mapcar #'(lambda (bmk) | |
971 `[,bmk (bookmark-jump ',bmk)]) | |
972 (bookmark-all-names)))) | |
973 ["Jump to Bookmark" nil nil]) | |
974 ["Set bookmark" bookmark-set | |
975 :active (fboundp 'bookmark-set)] | |
976 "---" | |
977 ["Insert contents" bookmark-menu-insert | |
978 :active (fboundp 'bookmark-menu-insert)] | |
979 ["Insert location" bookmark-menu-locate | |
980 :active (fboundp 'bookmark-menu-locate)] | |
981 "---" | |
982 ["Rename bookmark" bookmark-menu-rename | |
983 :active (fboundp 'bookmark-menu-rename)] | |
984 ,(if definedp | |
985 '("Delete Bookmark" | |
986 :filter (lambda (&rest junk) | |
987 (mapcar #'(lambda (bmk) | |
988 `[,bmk (bookmark-delete ',bmk)]) | |
989 (bookmark-all-names)))) | |
990 ["Delete Bookmark" nil nil]) | |
991 ["Edit Bookmark List" bookmark-bmenu-list ,definedp] | |
992 "---" | |
993 ["Save bookmarks" bookmark-save ,definedp] | |
994 ["Save bookmarks as..." bookmark-write ,definedp] | |
995 ["Load a bookmark file" bookmark-load | |
996 :active (fboundp 'bookmark-load)]))) | |
997 | |
998 ;;; The Buffers menu | |
999 | |
1000 (defgroup buffers-menu nil | |
1001 "Customization of `Buffers' menu." | |
1002 :group 'menu) | |
1003 | |
1004 (defcustom buffers-menu-max-size 25 | |
1005 "*Maximum number of entries which may appear on the \"Buffers\" menu. | |
1006 If this is 10, then only the ten most-recently-selected buffers will be | |
1007 shown. If this is nil, then all buffers will be shown. Setting this to | |
1008 a large number or nil will slow down menu responsiveness." | |
1009 :type '(choice (const :tag "Show all" nil) | |
1010 (integer 10)) | |
1011 :group 'buffers-menu) | |
1012 | |
1013 (defcustom complex-buffers-menu-p nil | |
1014 "*If non-nil, the buffers menu will contain several commands. | |
1015 Commands will be presented as submenus of each buffer line. If this | |
1016 is false, then there will be only one command: select that buffer." | |
1017 :type 'boolean | |
1018 :group 'buffers-menu) | |
1019 | |
1020 (defcustom buffers-menu-submenus-for-groups-p nil | |
1021 "*If non-nil, the buffers menu will contain one submenu per group of buffers. | |
1022 The grouping function is specified in `buffers-menu-grouping-function'. | |
1023 If this is an integer, do not build submenus if the number of buffers | |
1024 is not larger than this value." | |
1025 :type '(choice (const :tag "No Subgroups" nil) | |
1026 (integer :tag "Max. submenus" 10) | |
1027 (sexp :format "%t\n" :tag "Allow Subgroups" :value t)) | |
1028 :group 'buffers-menu) | |
1029 | |
1030 (defcustom buffers-menu-switch-to-buffer-function 'switch-to-buffer | |
1031 "*The function to call to select a buffer from the buffers menu. | |
1032 `switch-to-buffer' is a good choice, as is `pop-to-buffer'." | |
1033 :type '(radio (function-item switch-to-buffer) | |
1034 (function-item pop-to-buffer) | |
1035 (function :tag "Other")) | |
1036 :group 'buffers-menu) | |
1037 | |
1038 (defcustom buffers-menu-omit-function 'buffers-menu-omit-invisible-buffers | |
1039 "*If non-nil, a function specifying the buffers to omit from the buffers menu. | |
1040 This is passed a buffer and should return non-nil if the buffer should be | |
1041 omitted. The default value `buffers-menu-omit-invisible-buffers' omits | |
1042 buffers that are normally considered \"invisible\" (those whose name | |
1043 begins with a space)." | |
1044 :type '(choice (const :tag "None" nil) | |
1045 function) | |
1046 :group 'buffers-menu) | |
1047 | |
1048 (defcustom buffers-menu-format-buffer-line-function 'format-buffers-menu-line | |
1049 "*The function to call to return a string to represent a buffer in the | |
1050 buffers menu. The function is passed a buffer and should return a string. | |
1051 The default value `format-buffers-menu-line' just returns the name of | |
1052 the buffer. Also check out `slow-format-buffers-menu-line' which | |
1053 returns a whole bunch of info about a buffer." | |
1054 :type 'function | |
1055 :group 'buffers-menu) | |
1056 | |
1057 (defcustom buffers-menu-sort-function | |
1058 'sort-buffers-menu-by-mode-then-alphabetically | |
1059 "*If non-nil, a function to sort the list of buffers in the buffers menu. | |
1060 It will be passed two arguments (two buffers to compare) and should return | |
1061 T if the first is \"less\" than the second. One possible value is | |
1062 `sort-buffers-menu-alphabetically'; another is | |
1063 `sort-buffers-menu-by-mode-then-alphabetically'." | |
1064 :type '(choice (const :tag "None" nil) | |
1065 function) | |
1066 :group 'buffers-menu) | |
1067 | |
1068 (defcustom buffers-menu-grouping-function | |
1069 'group-buffers-menu-by-mode-then-alphabetically | |
1070 "*If non-nil, a function to group buffers in the buffers menu together. | |
1071 It will be passed two arguments, successive members of the sorted buffers | |
1072 list after being passed through `buffers-menu-sort-function'. It should | |
1073 return non-nil if the second buffer begins a new group. The return value | |
1074 should be the name of the old group, which may be used in hierarchical | |
1075 buffers menus. The last invocation of the function contains nil as the | |
1076 second argument, so that the name of the last group can be determined. | |
1077 | |
1078 The sensible values of this function are dependent on the value specified | |
1079 for `buffers-menu-sort-function'." | |
1080 :type '(choice (const :tag "None" nil) | |
1081 function) | |
1082 :group 'buffers-menu) | |
1083 | |
1084 (defun buffers-menu-omit-invisible-buffers (buf) | |
1085 "For use as a value of `buffers-menu-omit-function'. | |
1086 Omits normally invisible buffers (those whose name begins with a space)." | |
1087 (not (null (string-match "\\` " (buffer-name buf))))) | |
1088 | |
1089 (defun sort-buffers-menu-alphabetically (buf1 buf2) | |
1090 "For use as a value of `buffers-menu-sort-function'. | |
1091 Sorts the buffers in alphabetical order by name, but puts buffers beginning | |
1092 with a star at the end of the list." | |
1093 (let* ((nam1 (buffer-name buf1)) | |
1094 (nam2 (buffer-name buf2)) | |
1095 (star1p (not (null (string-match "\\`*" nam1)))) | |
1096 (star2p (not (null (string-match "\\`*" nam2))))) | |
1097 (if (not (eq star1p star2p)) | |
1098 (not star1p) | |
1099 (string-lessp nam1 nam2)))) | |
1100 | |
1101 (defun sort-buffers-menu-by-mode-then-alphabetically (buf1 buf2) | |
1102 "For use as a value of `buffers-menu-sort-function'. | |
1103 Sorts first by major mode and then alphabetically by name, but puts buffers | |
1104 beginning with a star at the end of the list." | |
1105 (let* ((nam1 (buffer-name buf1)) | |
1106 (nam2 (buffer-name buf2)) | |
1107 (star1p (not (null (string-match "\\`*" nam1)))) | |
1108 (star2p (not (null (string-match "\\`*" nam2)))) | |
1109 (mode1 (symbol-value-in-buffer 'major-mode buf1)) | |
1110 (mode2 (symbol-value-in-buffer 'major-mode buf2))) | |
1111 (cond ((not (eq star1p star2p)) (not star1p)) | |
1112 ((and star1p star2p (string-lessp nam1 nam2))) | |
1113 ((string-lessp mode1 mode2) t) | |
1114 ((string-lessp mode2 mode1) nil) | |
1115 (t (string-lessp nam1 nam2))))) | |
1116 | |
1117 ;; this version is too slow on some machines. | |
1118 (defun slow-format-buffers-menu-line (buffer) | |
1119 "For use as a value of `buffers-menu-format-buffer-line-function'. | |
1120 This returns a string containing a bunch of info about the buffer." | |
1121 (format "%s%s %-19s %6s %-15s %s" | |
1122 (if (buffer-modified-p buffer) "*" " ") | |
1123 (if (symbol-value-in-buffer 'buffer-read-only buffer) "%" " ") | |
1124 (buffer-name buffer) | |
1125 (buffer-size buffer) | |
1126 (symbol-value-in-buffer 'mode-name buffer) | |
1127 (or (buffer-file-name buffer) ""))) | |
1128 | |
1129 (defun format-buffers-menu-line (buffer) | |
1130 "For use as a value of `buffers-menu-format-buffer-line-function'. | |
1131 This just returns the buffer's name." | |
1132 (buffer-name buffer)) | |
1133 | |
1134 (defun group-buffers-menu-by-mode-then-alphabetically (buf1 buf2) | |
1135 "For use as a value of `buffers-menu-grouping-function'. | |
1136 This groups buffers by major mode. It only really makes sense if | |
1137 `buffers-menu-sorting-function' is | |
1138 `sort-buffers-menu-by-mode-then-alphabetically'." | |
1139 (cond ((string-match "\\`*" (buffer-name buf1)) | |
1140 (and (null buf2) "*Misc*")) | |
1141 ((or (null buf2) | |
1142 (string-match "\\`*" (buffer-name buf2)) | |
1143 (not (eq (symbol-value-in-buffer 'major-mode buf1) | |
1144 (symbol-value-in-buffer 'major-mode buf2)))) | |
1145 (symbol-value-in-buffer 'mode-name buf1)) | |
1146 (t nil))) | |
1147 | |
1148 (defun buffer-menu-save-buffer (buffer) | |
1149 (save-excursion | |
1150 (set-buffer buffer) | |
1151 (save-buffer))) | |
1152 | |
1153 (defun buffer-menu-write-file (buffer) | |
1154 (save-excursion | |
1155 (set-buffer buffer) | |
1156 (write-file (read-file-name | |
1157 (format "Write %s to file: " | |
1158 (buffer-name (current-buffer))))))) | |
1159 | |
1160 (defsubst build-buffers-menu-internal (buffers) | |
1161 (let (name line) | |
1162 (mapcar | |
1163 #'(lambda (buffer) | |
1164 (if (eq buffer t) | |
1165 "---" | |
1166 (setq line (funcall buffers-menu-format-buffer-line-function | |
1167 buffer)) | |
1168 (if complex-buffers-menu-p | |
1169 (delq nil | |
1170 (list line | |
1171 (vector "Switch to Buffer" | |
1172 (list buffers-menu-switch-to-buffer-function | |
1173 (setq name (buffer-name buffer))) | |
1174 t) | |
1175 (if (eq buffers-menu-switch-to-buffer-function | |
1176 'switch-to-buffer) | |
1177 (vector "Switch to Buffer, Other Frame" | |
1178 (list 'switch-to-buffer-other-frame | |
1179 (setq name (buffer-name buffer))) | |
1180 t) | |
1181 nil) | |
1182 (if (and (buffer-modified-p buffer) | |
1183 (buffer-file-name buffer)) | |
1184 (vector "Save Buffer" | |
1185 (list 'buffer-menu-save-buffer name) t) | |
1186 ["Save Buffer" nil nil] | |
1187 ) | |
1188 (vector "Save As..." | |
1189 (list 'buffer-menu-write-file name) t) | |
1190 (vector "Delete Buffer" (list 'kill-buffer name) | |
1191 t))) | |
1192 ;; ### We don't want buffer names to be translated, | |
1193 ;; ### so we put the buffer name in the suffix. | |
1194 ;; ### Also, avoid losing with non-ASCII buffer names. | |
1195 ;; ### We still lose, however, if complex-buffers-menu-p. --mrb | |
1196 (vector "" | |
1197 (list buffers-menu-switch-to-buffer-function | |
1198 (buffer-name buffer)) | |
1199 t line)))) | |
1200 buffers))) | |
1201 | |
1202 (defun buffers-menu-filter (menu) | |
1203 "This is the menu filter for the top-level buffers \"Buffers\" menu. | |
1204 It dynamically creates a list of buffers to use as the contents of the menu. | |
1205 Only the most-recently-used few buffers will be listed on the menu, for | |
1206 efficiency reasons. You can control how many buffers will be shown by | |
1207 setting `buffers-menu-max-size'. You can control the text of the menu | |
1208 items by redefining the function `format-buffers-menu-line'." | |
1209 (let ((buffers (delete-if buffers-menu-omit-function (buffer-list)))) | |
1210 (and (integerp buffers-menu-max-size) | |
1211 (> buffers-menu-max-size 1) | |
1212 (> (length buffers) buffers-menu-max-size) | |
1213 ;; shorten list of buffers (not with submenus!) | |
1214 (not (and buffers-menu-grouping-function | |
1215 buffers-menu-submenus-for-groups-p)) | |
1216 (setcdr (nthcdr buffers-menu-max-size buffers) nil)) | |
1217 (if buffers-menu-sort-function | |
1218 (setq buffers (sort buffers buffers-menu-sort-function))) | |
1219 (if (and buffers-menu-grouping-function | |
1220 buffers-menu-submenus-for-groups-p | |
1221 (or (not (integerp buffers-menu-submenus-for-groups-p)) | |
1222 (> (length buffers) buffers-menu-submenus-for-groups-p))) | |
1223 (let (groups groupnames current-group) | |
1224 (mapl | |
1225 #'(lambda (sublist) | |
1226 (let ((groupname (funcall buffers-menu-grouping-function | |
1227 (car sublist) (cadr sublist)))) | |
1228 (setq current-group (cons (car sublist) current-group)) | |
1229 (if groupname | |
1230 (progn | |
1231 (setq groups (cons (nreverse current-group) | |
1232 groups)) | |
1233 (setq groupnames (cons groupname groupnames)) | |
1234 (setq current-group nil))))) | |
1235 buffers) | |
1236 (setq buffers | |
1237 (mapcar* | |
1238 #'(lambda (groupname group) | |
1239 (cons groupname (build-buffers-menu-internal group))) | |
1240 (nreverse groupnames) | |
1241 (nreverse groups)))) | |
1242 (if buffers-menu-grouping-function | |
1243 (progn | |
1244 (setq buffers | |
1245 (mapcon | |
1246 #'(lambda (sublist) | |
1247 (cond ((funcall buffers-menu-grouping-function | |
1248 (car sublist) (cadr sublist)) | |
1249 (list (car sublist) t)) | |
1250 (t (list (car sublist))))) | |
1251 buffers)) | |
1252 ;; remove a trailing separator. | |
1253 (and (>= (length buffers) 2) | |
1254 (let ((lastcdr (nthcdr (- (length buffers) 2) buffers))) | |
1255 (if (eq t (cadr lastcdr)) | |
1256 (setcdr lastcdr nil)))))) | |
1257 (setq buffers (build-buffers-menu-internal buffers))) | |
1258 (append menu buffers) | |
1259 )) | |
1260 | |
1261 (defun language-environment-menu-filter (menu) | |
1262 "This is the menu filter for the \"Language Environment\" submenu." | |
1263 (mapcar (lambda (env-sym) | |
1264 `[ ,(capitalize (symbol-name env-sym)) | |
1265 (set-language-environment ',env-sym)]) | |
1266 language-environment-list)) | |
1267 | |
1268 | |
1269 ;;; The Options menu | |
1270 | |
1271 ;; We'll keep those variables here for a while, in order to provide a | |
1272 ;; function for porting the old options file that a user may own to Custom. | |
1273 | |
1274 (defvar options-save-faces nil | |
1275 "*Non-nil value means save-options will save information about faces. | |
1276 A nil value means save-options will not save face information. | |
1277 Set this non-nil only if you use M-x edit-faces to change face | |
1278 settings. If you use M-x customize-face or the \"Browse Faces...\" | |
1279 menu entry, you will see a button in the Customize Face buffer that you | |
1280 can use to permanently save your face changes. | |
1281 | |
1282 M-x edit-faces is deprecated. Support for it and this variable will | |
1283 be discontinued in a future release.") | |
1284 | |
1285 (defvar save-options-init-file nil | |
1286 "File into which to save forms to load the options file (nil for .emacs). | |
1287 Normally this is nil, which means save into your .emacs file (the value | |
1288 of `user-init-file'.") | |
1289 | |
1290 (defvar save-options-file ".xemacs-options" | |
1291 "File to save options into. | |
1292 This file is loaded from your .emacs file. | |
1293 If this is a relative filename, it is put into the same directory as your | |
1294 .emacs file.") | |
1295 | |
1296 | |
1297 | |
1298 ;;; The Help menu | |
1299 | |
1300 (if (featurep 'mule) | |
1301 (defun tutorials-menu-filter (menu-items) | |
1302 ;; If there's a tutorial for the current language environment, make it | |
1303 ;; appear first as the default one. Otherwise, use the english one. | |
1304 (let* ((menu menu-items) | |
1305 (item (pop menu-items))) | |
1306 (aset | |
1307 item 3 | |
1308 (concat "(" | |
1309 (if (assoc | |
1310 'tutorial | |
1311 (assoc current-language-environment language-info-alist)) | |
1312 current-language-environment | |
1313 "English") | |
1314 ")")) | |
1315 menu))) | |
1316 | |
1317 | |
1318 (set-menubar default-menubar) | |
1319 | |
1320 | |
1321 ;;; Popup menus. | |
1322 | |
1323 (defconst default-popup-menu | |
1324 '("XEmacs Commands" | |
1325 ["Undo" advertised-undo | |
1326 :active (and (not (eq buffer-undo-list t)) | |
1327 (or buffer-undo-list pending-undo-list)) | |
1328 :suffix (if (or (eq last-command 'undo) | |
1329 (eq last-command 'advertised-undo)) | |
1330 "More" "")] | |
1331 ["Cut" x-kill-primary-selection | |
1332 :active (and (eq 'x (device-type (selected-device))) | |
1333 (x-selection-owner-p))] | |
1334 ["Copy" x-copy-primary-selection | |
1335 :active (and (eq 'x (device-type (selected-device))) | |
1336 (x-selection-owner-p))] | |
1337 ["Paste" x-yank-clipboard-selection | |
1338 :active (and (eq 'x (device-type (selected-device))) | |
1339 (x-selection-exists-p 'CLIPBOARD))] | |
1340 ["Clear" x-delete-primary-selection | |
1341 :active (and (eq 'x (device-type (selected-device))) | |
1342 (x-selection-owner-p))] | |
1343 "-----" | |
1344 ["Select Block" mark-paragraph] | |
1345 ["Split Window" (split-window)] | |
1346 ["Unsplit Window" delete-other-windows] | |
1347 )) | |
1348 | |
1349 (defvar global-popup-menu nil | |
1350 "The global popup menu. This is present in all modes. | |
1351 See the function `popup-menu' for a description of menu syntax.") | |
1352 | |
1353 (defvar mode-popup-menu nil | |
1354 "The mode-specific popup menu. Automatically buffer local. | |
1355 This is appended to the default items in `global-popup-menu'. | |
1356 See the function `popup-menu' for a description of menu syntax.") | |
1357 (make-variable-buffer-local 'mode-popup-menu) | |
1358 | |
1359 ;; In an effort to avoid massive menu clutter, this mostly worthless menu is | |
1360 ;; superceded by any local popup menu... | |
1361 (setq-default mode-popup-menu default-popup-menu) | |
1362 | |
1363 (defvar activate-popup-menu-hook nil | |
1364 "Function or functions run before a mode-specific popup menu is made visible. | |
1365 These functions are called with no arguments, and should interrogate and | |
1366 modify the value of `global-popup-menu' or `mode-popup-menu' as desired. | |
1367 Note: this hook is only run if you use `popup-mode-menu' for activating the | |
1368 global and mode-specific commands; if you have your own binding for button3, | |
1369 this hook won't be run.") | |
1370 | |
1371 (defun popup-mode-menu () | |
1372 "Pop up a menu of global and mode-specific commands. | |
1373 The menu is computed by combining `global-popup-menu' and `mode-popup-menu'." | |
1374 (interactive "@_") | |
1375 (run-hooks 'activate-popup-menu-hook) | |
1376 (popup-menu | |
1377 (cond ((and global-popup-menu mode-popup-menu) | |
1378 (check-menu-syntax mode-popup-menu) | |
1379 (let* ((title (car mode-popup-menu)) | |
1380 (items (cdr mode-popup-menu)) | |
1381 filters) | |
1382 ;; Strip keywords from local menu for attaching them at the top | |
1383 (while (and items | |
1384 (symbolp (car items))) | |
1385 (setq items (append filters (list (car items)))) | |
1386 (setq items (cdr items))) | |
1387 ;; If filters contains a keyword already present in | |
1388 ;; `global-popup-menu' you will probably lose. | |
1389 (append (list (car global-popup-menu)) | |
1390 filters | |
1391 (cdr global-popup-menu) | |
1392 '("---" "---") | |
1393 (if popup-menu-titles (list title)) | |
1394 (if popup-menu-titles '("---" "---")) | |
1395 items))) | |
1396 (t | |
1397 (or mode-popup-menu | |
1398 global-popup-menu | |
1399 (error "No menu here.")))))) | |
1400 | |
1401 (defun popup-buffer-menu (event) | |
1402 "Pop up a copy of the Buffers menu (from the menubar) where the mouse is clicked." | |
1403 (interactive "e") | |
1404 (let ((window (and (event-over-text-area-p event) (event-window event))) | |
1405 (bmenu nil)) | |
1406 (or window | |
1407 (error "Pointer must be in a normal window")) | |
1408 (select-window window) | |
1409 (if current-menubar | |
1410 (setq bmenu (assoc "Buffers" current-menubar))) | |
1411 (if (null bmenu) | |
1412 (setq bmenu (assoc "Buffers" default-menubar))) | |
1413 (if (null bmenu) | |
1414 (error "Can't find the Buffers menu")) | |
1415 (popup-menu bmenu))) | |
1416 | |
1417 (defun popup-menubar-menu (event) | |
1418 "Pop up a copy of menu that also appears in the menubar" | |
1419 ;; by Stig@hackvan.com | |
1420 (interactive "e") | |
1421 (let ((window (and (event-over-text-area-p event) (event-window event))) | |
1422 popup-menubar) | |
1423 (or window | |
1424 (error "Pointer must be in a normal window")) | |
1425 (select-window window) | |
1426 (and current-menubar (run-hooks 'activate-menubar-hook)) | |
1427 ;; ##### Instead of having to copy this just to safely get rid of | |
1428 ;; any nil what we should really do is fix up the internal menubar | |
1429 ;; code to just ignore nil if generating a popup menu | |
1430 (setq popup-menubar (delete nil (copy-sequence (or current-menubar | |
1431 default-menubar)))) | |
1432 (popup-menu (cons "Menubar Menu" popup-menubar)) | |
1433 )) | |
1434 | |
1435 (global-set-key 'button3 'popup-mode-menu) | |
1436 ;; shift button3 and shift button2 are reserved for Hyperbole | |
1437 (global-set-key '(meta control button3) 'popup-buffer-menu) | |
1438 ;; The following command is way too dangerous with Custom. | |
1439 ;; (global-set-key '(meta shift button3) 'popup-menubar-menu) | |
1440 | |
1441 ;; Here's a test of the cool new menu features (from Stig). | |
1442 | |
1443 ;;(setq mode-popup-menu | |
1444 ;; '("Test Popup Menu" | |
1445 ;; :filter cdr | |
1446 ;; ["this item won't appear because of the menu filter" ding t] | |
1447 ;; "--:singleLine" | |
1448 ;; "singleLine" | |
1449 ;; "--:doubleLine" | |
1450 ;; "doubleLine" | |
1451 ;; "--:singleDashedLine" | |
1452 ;; "singleDashedLine" | |
1453 ;; "--:doubleDashedLine" | |
1454 ;; "doubleDashedLine" | |
1455 ;; "--:noLine" | |
1456 ;; "noLine" | |
1457 ;; "--:shadowEtchedIn" | |
1458 ;; "shadowEtchedIn" | |
1459 ;; "--:shadowEtchedOut" | |
1460 ;; "shadowEtchedOut" | |
1461 ;; "--:shadowDoubleEtchedIn" | |
1462 ;; "shadowDoubleEtchedIn" | |
1463 ;; "--:shadowDoubleEtchedOut" | |
1464 ;; "shadowDoubleEtchedOut" | |
1465 ;; "--:shadowEtchedInDash" | |
1466 ;; "shadowEtchedInDash" | |
1467 ;; "--:shadowEtchedOutDash" | |
1468 ;; "shadowEtchedOutDash" | |
1469 ;; "--:shadowDoubleEtchedInDash" | |
1470 ;; "shadowDoubleEtchedInDash" | |
1471 ;; "--:shadowDoubleEtchedOutDash" | |
1472 ;; "shadowDoubleEtchedOutDash" | |
1473 ;; )) | |
1474 | |
1475 (defun xemacs-splash-buffer () | |
1476 "Redisplay XEmacs splash screen in a buffer." | |
1477 (interactive) | |
1478 (let ((buffer (get-buffer-create "*Splash*"))) | |
1479 (set-buffer buffer) | |
1480 (erase-buffer buffer) | |
1481 (startup-splash-frame) | |
1482 (pop-to-buffer buffer) | |
1483 (delete-other-windows))) | |
1484 | |
1485 | |
1486 ;;; backwards compatibility | |
1487 (provide 'x-menubar) | |
1488 (provide 'menubar-items) | |
1489 | |
1490 ;;; x-menubar.el ends here. |