comparison lisp/x-menubar.el @ 209:41ff10fd062f r20-4b3

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