1 ;;; menubar-items.el --- Menubar and popup-menu content for XEmacs.
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, 2000 Ben Wing.
7 ;; Copyright (C) 1997 MORIOKA Tomohiko.
9 ;; Maintainer: XEmacs Development Team
10 ;; Keywords: frames, extensions, internal, dumped
12 ;; This file is part of XEmacs.
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)
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.
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.
31 ;; Created c. 1991 for Lucid Emacs. Originally called x-menubar.el.
32 ;; Contained four menus -- File, Edit, Buffers, Help.
33 ;; Dynamic menu changes possible only through activate-menubar-hook.
34 ;; Also contained menu manipulation funs, e.g. find-menu-item, add-menu.
35 ;; Options menu added for 19.9 by Jamie Zawinski, late 1993.
36 ;; Major reorganization c. 1994 by Ben Wing; added many items and moved
37 ;; some items to two new menus, Apps and Tools. (for 19.10?)
38 ;; Generic menubar functions moved to new file, menubar.el, by Ben Wing,
39 ;; 1995, for 19.12; also, creation of current buffers menu options,
40 ;; and buffers menu changed from purely most-recent to sorted alphabetical,
41 ;; by mode. Also added mode-popup-menu support.
42 ;; New API (add-submenu, add-menu-button) and menu filter support added
43 ;; late summer 1995 by Stig, for 19.13. Also popup-menubar-menu.
44 ;; Renamed to menubar-items.el c. 1998, with MS Win support.
45 ;; Options menu rewritten to use custom c. 1999 by ? (Jan Vroonhof?).
46 ;; Major reorganization Mar. 2000 by Ben Wing; added many items and changed
47 ;; top-level menus to File, Edit, View, Cmds, Tools, Options, Buffers.
48 ;; Accelerator spec functionality added Mar. 2000 by Ben Wing.
52 ;; This file is dumped with XEmacs (when window system and menubar support is
57 (defun Menubar-items-truncate-list (list n)
59 (if (<= (length x) 50) x (concat "..." (substring x -50))))
60 (if (<= (length list) n)
62 (butlast list (- (length list) n)))))
64 (defun submenu-generate-accelerator-spec (list &optional omit-chars-list)
65 "Add auto-generated accelerator specifications to a submenu.
66 This can be used to add accelerators to the return value of a menu filter
67 function. It correctly ignores unselectable items. It will destructively
68 modify the list passed to it. If an item already has an auto-generated
69 accelerator spec, this will be removed before the new one is added, making
70 this function idempotent.
72 If OMIT-CHARS-LIST is given, it should be a list of lowercase characters,
73 which will not be used as accelerators."
75 (dolist (item list list)
81 (menu-item-generate-accelerator-spec n omit-chars-list)
82 (menu-item-strip-accelerator-spec (aref item 0)))))
87 (menu-item-generate-accelerator-spec n omit-chars-list)
88 (menu-item-strip-accelerator-spec (car item)))))))))
90 (defun menu-item-strip-accelerator-spec (item)
91 "Strip an auto-generated accelerator spec off of ITEM.
92 ITEM should be a string. This removes specs added by
93 `menu-item-generate-accelerator-spec' and `submenu-generate-accelerator-spec'."
94 (if (string-match "%_. " item)
98 (defun menu-item-generate-accelerator-spec (n &optional omit-chars-list)
99 "Return an accelerator specification for use with auto-generated menus.
100 This should be concat'd onto the beginning of each menu line. The spec
101 allows the Nth line to be selected by the number N. '0' is used for the
102 10th line, and 'a' through 'z' are used for the following 26 lines.
104 If OMIT-CHARS-LIST is given, it should be a list of lowercase characters,
105 which will not be used as accelerators."
106 (cond ((< n 10) (concat "%_" (int-to-string n) " "))
113 (while (memq (int-to-char (+ m (- (char-to-int ?a) 1)))
120 (char-to-string (int-to-char (+ m (- (char-to-int ?a) 1))))
125 (defconst default-menubar
126 ; (purecopy-menubar ;purespace is dead
130 ["%_Open..." find-file]
131 ["Open in Other %_Window..." find-file-other-window]
132 ["Open in New %_Frame..." find-file-other-frame]
133 ["%_Hex Edit File..." hexl-find-file
134 :active (fboundp 'hexl-find-file)]
135 ["%_Insert File..." insert-file]
136 ["%_View File..." view-file]
138 ["%_Save" save-buffer
139 :active (buffer-modified-p)
140 :suffix (if put-buffer-names-in-file-menu (buffer-name) "")]
141 ["Save %_As..." write-file]
142 ["Save So%_me Buffers" save-some-buffers]
144 ,@(if (eq system-type 'windows-nt)
145 '(["Page Set%_up..." generic-page-setup]))
146 ["%_Print" generic-print-buffer
147 :active (or (valid-specifier-tag-p 'msprinter)
148 (and (not (eq system-type 'windows-nt))
149 (fboundp 'lpr-region)))
150 :suffix (if (region-active-p) "Selection..."
151 (if put-buffer-names-in-file-menu (concat (buffer-name) "...")
153 ,@(unless (eq system-type 'windows-nt)
154 '(["Prett%_y-Print" ps-print-buffer-with-faces
155 :active (fboundp 'ps-print-buffer-with-faces)
156 :suffix (if put-buffer-names-in-file-menu (buffer-name) "")]))
158 ["%_Revert Buffer" revert-buffer
159 :active (or buffer-file-name revert-buffer-function)
160 :suffix (if put-buffer-names-in-file-menu (buffer-name) "")]
161 ["Re%_cover File..." recover-file]
162 ["Recover S%_ession..." recover-session]
164 ["E%_xit XEmacs" save-buffers-kill-emacs]
168 ["%_Undo" advertised-undo
169 :active (and (not (eq buffer-undo-list t))
170 (or buffer-undo-list pending-undo-list))
171 :suffix (if (or (eq last-command 'undo)
172 (eq last-command 'advertised-undo))
175 :included (fboundp 'redo)
176 :active (not (or (eq buffer-undo-list t)
177 (eq last-buffer-undo-list nil)
178 (not (or (eq last-buffer-undo-list buffer-undo-list)
179 (and (null (car-safe buffer-undo-list))
180 (eq last-buffer-undo-list
181 (cdr-safe buffer-undo-list)))))
182 (or (eq buffer-undo-list pending-undo-list)
183 (eq (cdr buffer-undo-list) pending-undo-list))))
184 :suffix (if (eq last-command 'redo) "More" "")]
186 ["Cu%_t" kill-primary-selection
187 :active (selection-owner-p)]
188 ["%_Copy" copy-primary-selection
189 :active (selection-owner-p)]
190 ["%_Paste" yank-clipboard-selection
191 :active (selection-exists-p 'CLIPBOARD)]
192 ["%_Delete" delete-primary-selection
193 :active (selection-owner-p)]
195 ["Select %_All" mark-whole-buffer]
196 ["Select Pa%_ge" mark-page]
198 ["%_Find..." make-search-dialog]
199 ["R%_eplace..." query-replace]
200 ["Replace (Rege%_xp)..." query-replace-regexp]
201 ["%_List Matching Lines..." list-matching-lines]
202 ,@(when (featurep 'mule)
204 ("%_Multilingual (\"Mule\")"
205 ("%_Describe Language Support")
206 ("%_Set Language Environment")
208 ["T%_oggle Input Method" toggle-input-method]
209 ["Select %_Input Method" set-input-method]
210 ["D%_escribe Input Method" describe-input-method]
212 ["Describe Current %_Coding Systems"
213 describe-current-coding-system]
214 ["Set Coding System of %_Buffer File..."
215 set-buffer-file-coding-system]
216 ;; not implemented yet
217 ["Set Coding System of %_Terminal..."
218 set-terminal-coding-system :active nil]
219 ;; not implemented yet
220 ["Set Coding System of %_Keyboard..."
221 set-keyboard-coding-system :active nil]
222 ["Set Coding System of %_Process..."
223 set-buffer-process-coding-system
224 :active (get-buffer-process (current-buffer))]
226 ["Show Cha%_racter Table" view-charset-by-menu]
227 ;; not implemented yet
228 ["Show Dia%_gnosis for MULE" mule-diag :active nil]
229 ["Show \"%_hello\" in Many Languages" view-hello-file]))
234 ["%_New Frame" make-frame]
235 ["Frame on Other Displa%_y..." make-frame-on-display
236 :active (fboundp 'make-frame-on-display)]
237 ["%_Delete Frame" delete-frame
238 :active (not (eq (next-frame (selected-frame) 'nomini 'window-system)
241 ["%_Split Window" split-window-vertically]
242 ["S%_plit Window (Side by Side)" split-window-horizontally]
243 ["%_Un-Split (Keep This)" delete-other-windows
244 :active (not (one-window-p t))]
245 ["Un-Split (Keep %_Others)" delete-window
246 :active (not (one-window-p t))]
249 ["%_Narrow to Region" narrow-to-region :active (region-exists-p)]
250 ["Narrow to %_Page" narrow-to-page]
251 ["Narrow to %_Defun" narrow-to-defun]
253 ["%_Widen" widen :active (or (/= (point-min) 1)
254 (/= (point-max) (1+ (buffer-size))))]
257 ["Show Message %_Log" show-message-log]
259 ["%_Goto Line..." goto-line]
260 ["%_What Line" what-line]
262 :filter bookmark-menu-filter)
264 ["%_Jump to Previous Mark" (set-mark-command t)
269 ["Repeat %_Last Complex Command..." repeat-complex-command]
270 ["E%_valuate Lisp Expression..." eval-expression]
271 ["Execute %_Named Command..." execute-extended-command]
273 ["Start %_Macro Recording" start-kbd-macro
274 :included (not defining-kbd-macro)]
275 ["End %_Macro Recording" end-kbd-macro
276 :included defining-kbd-macro]
277 ["E%_xecute Last Macro" call-last-kbd-macro
278 :active last-kbd-macro]
280 ["%_Append to Last Macro" (start-kbd-macro t)
281 :active (and (not defining-kbd-macro) last-kbd-macro)]
282 ["%_Query User During Macro" kbd-macro-query
283 :active defining-kbd-macro]
284 ["Enter %_Recursive Edit During Macro" (kbd-macro-query t)
285 :active defining-kbd-macro]
287 ["E%_xecute Last Macro on Region Lines"
288 :active (and last-kbd-macro (region-exists-p))]
290 ["%_Name Last Macro..." name-last-kbd-macro
291 :active last-kbd-macro]
292 ["Assign Last Macro to %_Key..." assign-last-kbd-macro-to-key
293 :active (and last-kbd-macro
294 (fboundp 'assign-last-kbd-macro-to-key))]
296 ["%_Edit Macro..." edit-kbd-macro]
297 ["Edit %_Last Macro" edit-last-kbd-macro
298 :active last-kbd-macro]
300 ["%_Insert Named Macro into Buffer..." insert-kbd-macro]
301 ["Read Macro from Re%_gion" read-kbd-macro
302 :active (region-exists-p)]
306 ["D%_ynamic Abbrev Expand" dabbrev-expand]
307 ["Dynamic Abbrev %_Complete" dabbrev-completion]
308 ["Dynamic Abbrev Complete in %_All Buffers" (dabbrev-completion 16)]
311 ["%_Define Global Abbrev for " add-global-abbrev
312 :suffix (abbrev-string-to-be-defined nil)
314 ["Define %_Mode-Specific Abbrev for " add-mode-abbrev
315 :suffix (abbrev-string-to-be-defined nil)
317 ["Define Global Ex%_pansion for " inverse-add-global-abbrev
318 :suffix (inverse-abbrev-string-to-be-defined 1)
320 ["Define Mode-Specific Expa%_nsion for " inverse-add-mode-abbrev
321 :suffix (inverse-abbrev-string-to-be-defined 1)
324 ["E%_xpand Abbrev" expand-abbrev]
325 ["Expand Abbrevs in Re%_gion" expand-region-abbrevs
326 :active (region-exists-p)]
327 ["%_Unexpand Last Abbrev" unexpand-abbrev
328 :active (and (stringp last-abbrev-text)
329 (> last-abbrev-location 0))]
331 ["%_Kill All Abbrevs" kill-all-abbrevs]
332 ["%_Insert All Abbrevs into Buffer" insert-abbrevs]
333 ["%_List Abbrevs" list-abbrevs]
335 ["%_Edit Abbrevs" edit-abbrevs]
336 ["%_Redefine Abbrevs from Buffer" edit-abbrevs-redefine
337 :active (eq major-mode 'edit-abbrevs-mode)]
339 ["%_Save Abbrevs As..." write-abbrev-file]
340 ["L%_oad Abbrevs..." read-abbrev-file]
343 ["%_Copy to Register..." copy-to-register :active (region-exists-p)]
344 ["%_Paste Register..." insert-register]
346 ["%_Save Point to Register" point-to-register]
347 ["%_Jump to Register" register-to-point]
350 ["%_Kill Rectangle" kill-rectangle]
351 ["%_Yank Rectangle" yank-rectangle]
352 ["Rectangle %_to Register" copy-rectangle-to-register]
353 ["Rectangle %_from Register" insert-register]
354 ["%_Clear Rectangle" clear-rectangle]
355 ["%_Open Rectangle" open-rectangle]
356 ["%_Prefix Rectangle..." string-rectangle]
357 ["Rectangle %_Mousing"
358 (customize-set-variable 'mouse-track-rectangle-p
359 (not mouse-track-rectangle-p))
360 :style toggle :selected mouse-track-rectangle-p]
363 ["%_Lines in Region" sort-lines :active (region-exists-p)]
364 ["%_Paragraphs in Region" sort-paragraphs :active (region-exists-p)]
365 ["P%_ages in Region" sort-pages :active (region-exists-p)]
366 ["%_Columns in Region" sort-columns :active (region-exists-p)]
367 ["%_Regexp..." sort-regexp-fields :active (region-exists-p)]
370 ["%_Upcase Region" upcase-region :active (region-exists-p)]
371 ["%_Downcase Region" downcase-region :active (region-exists-p)]
372 ["%_Capitalize Region" capitalize-region :active (region-exists-p)]
373 ["%_Title-Case Region" capitalize-region-as-title
374 :active (region-exists-p)]
377 ["%_Line" center-line]
378 ["%_Paragraph" center-paragraph]
379 ["%_Region" center-region :active (region-exists-p)]
382 ["%_As Previous Line" indent-relative]
383 ["%_To Column..." indent-to-column]
385 ["%_Region" indent-region :active (region-exists-p)]
386 ["%_Balanced Expression" indent-sexp]
387 ["%_C Expression" indent-c-exp]
390 ["%_Buffer" ispell-buffer
391 :active (fboundp 'ispell-buffer)]
393 ["%_Word" ispell-word]
394 ["%_Complete Word" ispell-complete-word]
395 ["%_Region" ispell-region]
401 ("%_Add Download Site"
402 :filter (lambda (&rest junk)
403 (submenu-generate-accelerator-spec
404 (package-get-download-menu))))
405 ["%_Update Package Index" package-get-update-base]
406 ["%_List and Install" pui-list-packages]
407 ["U%_pdate Installed Packages" package-get-update-all]
408 ;; hack-o-matic, we can't force a load of package-base here
409 ;; since it triggers dialog box interactions which we can't
410 ;; deal with while using a menu
412 :filter (lambda (&rest junk)
414 (submenu-generate-accelerator-spec
415 (cdr (custom-menu-create 'packages)))
416 '("Please load Package Index"))))
418 ["%_Help" (Info-goto-node "(xemacs)Packages")])
420 ["Read Mail %_1 (VM)..." vm
421 :active (fboundp 'vm)]
422 ["Read Mail %_2 (MH)..." (mh-rmail t)
423 :active (fboundp 'mh-rmail)]
424 ["Send %_Mail..." compose-mail
425 :active (fboundp 'compose-mail)]
426 ["Usenet %_News" gnus
427 :active (fboundp 'gnus)]
428 ["Browse the %_Web" w3
429 :active (fboundp 'w3)])
434 (if (or (not (boundp 'grep-history)) (null grep-history))
437 (submenu-generate-accelerator-spec
438 (mapcar #'(lambda (string)
440 (list 'grep string)))
441 (Menubar-items-truncate-list grep-history 10)))))
442 (append menu '("---") items))))
443 ["%_Grep..." grep :active (fboundp 'grep)]
444 ["%_Kill Grep" kill-compilation
445 :active (and (fboundp 'kill-compilation)
446 (fboundp 'compilation-find-buffer)
447 (let ((buffer (condition-case nil
448 (compilation-find-buffer)
450 (and buffer (get-buffer-process buffer))))]
452 ["Grep %_All Files in Current Directory..."
456 (cons (concat grep-command " *")
457 (length grep-command))))
458 (call-interactively 'grep)))
459 :active (fboundp 'grep)]
460 ["Grep %_C and C Header Files in Current Directory..."
464 (cons (concat grep-command " *.[chCH]"
465 ; i wanted to also use *.cc and *.hh.
466 ; see long comment below under Perl.
468 (length grep-command))))
469 (call-interactively 'grep)))
470 :active (fboundp 'grep)]
471 ["Grep C Hea%_der Files in Current Directory..."
475 (cons (concat grep-command " *.[hH]"
476 ; i wanted to also use *.hh.
477 ; see long comment below under Perl.
479 (length grep-command))))
480 (call-interactively 'grep)))
481 :active (fboundp 'grep)]
482 ["Grep %_E-Lisp Files in Current Directory..."
486 (cons (concat grep-command " *.el")
487 (length grep-command))))
488 (call-interactively 'grep)))
489 :active (fboundp 'grep)]
490 ["Grep %_Perl Files in Current Directory..."
494 (cons (concat grep-command " *.pl"
495 ; i wanted to use this:
497 ; but grep complains if it can't
498 ; match anything in a glob, and
499 ; that screws other things up.
500 ; perhaps we need to first scan
501 ; each separate glob in the directory
502 ; to see if there are any files in
503 ; that glob, and if not, omit it.
505 (length grep-command))))
506 (call-interactively 'grep)))
507 :active (fboundp 'grep)]
508 ["Grep %_HTML Files in Current Directory..."
512 (cons (concat grep-command " *.*htm*")
513 (length grep-command))))
514 (call-interactively 'grep)))
515 :active (fboundp 'grep)]
517 ["%_Next Match" next-error
518 :active (and (fboundp 'compilation-errors-exist-p)
519 (compilation-errors-exist-p))]
520 ["Pre%_vious Match" previous-error
521 :active (and (fboundp 'compilation-errors-exist-p)
522 (compilation-errors-exist-p))]
523 ["%_First Match" first-error
524 :active (and (fboundp 'compilation-errors-exist-p)
525 (compilation-errors-exist-p))]
526 ["G%_oto Match" compile-goto-error
527 :active (and (fboundp 'compilation-errors-exist-p)
528 (compilation-errors-exist-p))]
530 ["%_Set Grep Command..."
533 (customize-set-variable
535 (read-shell-command "Default Grep Command: " grep-command)))
536 :active (fboundp 'grep)
542 (if (or (not (boundp 'compile-history)) (null compile-history))
545 (submenu-generate-accelerator-spec
546 (mapcar #'(lambda (string)
548 (list 'compile string)))
549 (Menubar-items-truncate-list compile-history 10)))))
550 (append menu '("---") items))))
551 ["%_Compile..." compile :active (fboundp 'compile)]
552 ["%_Repeat Compilation" recompile :active (fboundp 'recompile)]
553 ["%_Kill Compilation" kill-compilation
554 :active (and (fboundp 'kill-compilation)
555 (fboundp 'compilation-find-buffer)
556 (let ((buffer (condition-case nil
557 (compilation-find-buffer)
559 (and buffer (get-buffer-process buffer))))]
561 ["%_Next Error" next-error
562 :active (and (fboundp 'compilation-errors-exist-p)
563 (compilation-errors-exist-p))]
564 ["Pre%_vious Error" previous-error
565 :active (and (fboundp 'compilation-errors-exist-p)
566 (compilation-errors-exist-p))]
567 ["%_First Error" first-error
568 :active (and (fboundp 'compilation-errors-exist-p)
569 (compilation-errors-exist-p))]
570 ["G%_oto Error" compile-goto-error
571 :active (and (fboundp 'compilation-errors-exist-p)
572 (compilation-errors-exist-p))]
576 :active (fboundp 'gdb)]
578 :active (fboundp 'dbx)])
581 :active (fboundp 'shell)]
582 ["S%_hell Command..." shell-command
583 :active (fboundp 'shell-command)]
584 ["Shell Command on %_Region..." shell-command-on-region
585 :active (and (fboundp 'shell-command-on-region) (region-exists-p))])
588 ["%_Find Tag..." find-tag]
589 ["Find %_Other Window..." find-tag-other-window]
590 ["%_Next Tag..." (find-tag nil)]
591 ["N%_ext Other Window..." (find-tag-other-window nil)]
592 ["Next %_File" next-file]
594 ["Tags %_Search..." tags-search]
595 ["Tags %_Replace..." tags-query-replace]
596 ["%_Continue Search/Replace" tags-loop-continue]
598 ["%_Pop stack" pop-tag-mark]
599 ["%_Apropos..." tags-apropos]
601 ["%_Set Tags Table File..." visit-tags-table]
607 ["%_3-Month Calendar" calendar
608 :active (fboundp 'calendar)]
610 :active (fboundp 'diary)]
611 ["%_Holidays" holidays
612 :active (fboundp 'holidays)]
613 ;; we're all pagans at heart ...
614 ["%_Phases of the Moon" phases-of-moon
615 :active (fboundp 'phases-of-moon)]
616 ["%_Sunrise/Sunset" sunrise-sunset
617 :active (fboundp 'sunrise-sunset)])
621 :active (fboundp 'xmine)]
623 :active (fboundp 'tetris)]
625 :active (fboundp 'sokoban)]
626 ["Quote from %_Zippy" yow
627 :active (fboundp 'yow)]
628 ["%_Psychoanalyst" doctor
629 :active (fboundp 'doctor)]
630 ["Ps%_ychoanalyze Zippy!" psychoanalyze-pinhead
631 :active (fboundp 'psychoanalyze-pinhead)]
632 ["%_Random Flames" flame
633 :active (fboundp 'flame)]
634 ["%_Dunnet (Adventure)" dunnet
635 :active (fboundp 'dunnet)]
636 ["Towers of %_Hanoi" hanoi
637 :active (fboundp 'hanoi)]
638 ["Game of %_Life" life
639 :active (fboundp 'life)]
640 ["M%_ultiplication Puzzle" mpuz
641 :active (fboundp 'mpuz)])
647 ("%_Advanced (Customize)"
648 ("%_Emacs" :filter (lambda (&rest junk)
649 (cdr (custom-menu-create 'emacs))))
650 ["%_Group..." customize-group]
651 ["%_Variable..." customize-variable]
652 ["%_Face..." customize-face]
653 ["%_Saved..." customize-saved]
654 ["Se%_t..." customize-customized]
655 ["%_Apropos..." customize-apropos]
656 ["%_Browse..." customize-browse])
659 ["This Buffer %_Read Only" (toggle-read-only)
660 :style toggle :selected buffer-read-only]
661 ["%_Yank/Kill Interact With Clipboard"
662 (if (eq interprogram-cut-function 'own-clipboard)
664 (customize-set-variable 'interprogram-cut-function nil)
665 (customize-set-variable 'interprogram-paste-function nil))
666 (customize-set-variable 'interprogram-cut-function 'own-clipboard)
667 (customize-set-variable 'interprogram-paste-function 'get-clipboard))
669 :selected (eq interprogram-cut-function 'own-clipboard)]
672 (setq overwrite-mode (if overwrite-mode nil 'overwrite-mode-textual))
673 (customize-set-variable 'overwrite-mode overwrite-mode))
674 :style toggle :selected overwrite-mode]
676 (customize-set-variable 'abbrev-mode
677 (not (default-value 'abbrev-mode)))
679 :selected (default-value 'abbrev-mode)]
681 (customize-set-variable 'zmacs-regions (not zmacs-regions))
682 :style toggle :selected zmacs-regions]
684 ["%_Case Sensitive Search"
685 (customize-set-variable 'case-fold-search
686 (setq case-fold-search (not case-fold-search)))
687 :style toggle :selected (not case-fold-search)]
688 ["Case %_Matching Replace"
689 (customize-set-variable 'case-replace (not case-replace))
690 :style toggle :selected case-replace]
692 ("%_Newline at End of File..."
694 (customize-set-variable 'require-final-newline nil)
695 :style radio :selected (not require-final-newline)]
697 (customize-set-variable 'require-final-newline t)
698 :style radio :selected (eq require-final-newline t)]
700 (customize-set-variable 'require-final-newline 'ask)
701 :style radio :selected (and require-final-newline
702 (not (eq require-final-newline t)))])
703 ["Add Newline When Moving Past %_End"
704 (customize-set-variable 'next-line-add-newlines
705 (not next-line-add-newlines))
706 :style toggle :selected next-line-add-newlines])
707 ("%_Keyboard and Mouse"
708 ["%_Delete Key Deletes Selection"
709 (customize-set-variable 'pending-delete-mode (not pending-delete-mode))
711 :selected (and (boundp 'pending-delete-mode) pending-delete-mode)
712 :active (boundp 'pending-delete-mode)]
713 ["`%_kill-line' Kills Whole Line at %_Beg"
714 (customize-set-variable 'kill-whole-line (not kill-whole-line))
716 :selected kill-whole-line]
717 ["Size for %_Block-Movement Commands..."
718 (customize-set-variable 'block-movement-size
719 (read-number "Block Movement Size: "
720 t block-movement-size))]
724 (customize-set-variable 'viper-mode viper-mode))
725 :style toggle :selected (and (boundp 'viper-mode) viper-mode)
726 :active (fboundp 'toggle-viper-mode)]
728 ["S%_hifted Motion Keys Select Region"
729 (customize-set-variable 'shifted-motion-keys-select-region
730 (not shifted-motion-keys-select-region))
732 :selected shifted-motion-keys-select-region]
733 ["%_After Shifted Motion, Unshifted Motion Keys Deselect"
734 (customize-set-variable 'unshifted-motion-keys-deselect-region
735 (not unshifted-motion-keys-deselect-region))
737 :selected unshifted-motion-keys-deselect-region]
739 ["%_Set Key..." global-set-key]
740 ["%_Unset Key..." global-unset-key]
742 ["%_Mouse Paste at Text Cursor (not Clicked Location)"
743 (customize-set-variable 'mouse-yank-at-point (not mouse-yank-at-point))
744 :style toggle :selected mouse-yank-at-point]
746 ["%_Teach Extended Commands"
747 (customize-set-variable 'teach-extended-commands-p
748 (not teach-extended-commands-p))
749 :style toggle :selected teach-extended-commands-p]
752 ["Set Printer %_Name for Generic Print Support..."
753 (customize-set-variable
755 (read-string "Set printer name: " printer-name))]
757 ["Command-Line %_Switches for `lpr'/`lp'..."
758 ;; better to directly open a customization buffer, since the value
759 ;; must be a list of strings, which is somewhat complex to prompt for.
760 (customize-variable 'lpr-switches)
761 (boundp 'lpr-switches)]
762 ("%_Pretty-Print Paper Size"
764 (customize-set-variable 'ps-paper-type 'letter)
766 :selected (and (boundp 'ps-paper-type) (eq ps-paper-type 'letter))
767 :active (boundp 'ps-paper-type)]
769 (customize-set-variable 'ps-paper-type 'letter-small)
771 :selected (and (boundp 'ps-paper-type)
772 (eq ps-paper-type 'letter-small))
773 :active (boundp 'ps-paper-type)]
775 (customize-set-variable 'ps-paper-type 'legal)
777 :selected (and (boundp 'ps-paper-type) (eq ps-paper-type 'legal))
778 :active (boundp 'ps-paper-type)]
780 (customize-set-variable 'ps-paper-type 'statement)
782 :selected (and (boundp 'ps-paper-type) (eq ps-paper-type 'statement))
783 :active (boundp 'ps-paper-type)]
785 (customize-set-variable 'ps-paper-type 'executive)
787 :selected (and (boundp 'ps-paper-type) (eq ps-paper-type 'executive))
788 :active (boundp 'ps-paper-type)]
790 (customize-set-variable 'ps-paper-type 'tabloid)
792 :selected (and (boundp 'ps-paper-type) (eq ps-paper-type 'tabloid))
793 :active (boundp 'ps-paper-type)]
795 (customize-set-variable 'ps-paper-type 'ledger)
797 :selected (and (boundp 'ps-paper-type) (eq ps-paper-type 'ledger))
798 :active (boundp 'ps-paper-type)]
800 (customize-set-variable 'ps-paper-type 'a3)
802 :selected (and (boundp 'ps-paper-type) (eq ps-paper-type 'a3))
803 :active (boundp 'ps-paper-type)]
805 (customize-set-variable 'ps-paper-type 'a4)
807 :selected (and (boundp 'ps-paper-type) (eq ps-paper-type 'a4))
808 :active (boundp 'ps-paper-type)]
810 (customize-set-variable 'ps-paper-type 'a4small)
812 :selected (and (boundp 'ps-paper-type) (eq ps-paper-type 'a4small))
813 :active (boundp 'ps-paper-type)]
815 (customize-set-variable 'ps-paper-type 'b4)
817 :selected (and (boundp 'ps-paper-type) (eq ps-paper-type 'b4))
818 :active (boundp 'ps-paper-type)]
820 (customize-set-variable 'ps-paper-type 'b5)
822 :selected (and (boundp 'ps-paper-type) (eq ps-paper-type 'b5))
823 :active (boundp 'ps-paper-type)]
826 (cond (ps-print-color-p
827 (customize-set-variable 'ps-print-color-p nil)
828 ;; I'm wondering whether all this muck is useful.
829 (and (boundp 'original-face-background)
830 original-face-background
831 (set-face-background 'default original-face-background)))
833 (customize-set-variable 'ps-print-color-p t)
834 (setq original-face-background
835 (face-background-instance 'default))
836 (set-face-background 'default "white")))
838 :selected (and (boundp 'ps-print-color-p) ps-print-color-p)
839 :active (boundp 'ps-print-color-p)])
841 ("%_Compose Mail With"
842 ["Default Emacs Mailer"
843 (customize-set-variable 'mail-user-agent 'sendmail-user-agent)
845 :selected (eq mail-user-agent 'sendmail-user-agent)]
847 (customize-set-variable 'mail-user-agent 'mh-e-user-agent)
849 :selected (eq mail-user-agent 'mh-e-user-agent)
850 :active (get 'mh-e-user-agent 'composefunc)]
852 (customize-set-variable 'mail-user-agent 'message-user-agent)
854 :selected (eq mail-user-agent 'message-user-agent)
855 :active (get 'message-user-agent 'composefunc)]
857 ["Set My %_Email Address..."
858 (customize-set-variable
860 (read-string "Set email address: " user-mail-address))]
861 ["Set %_Machine Email Name..."
862 (customize-set-variable
864 (read-string "Set machine email name: " mail-host-address))]
865 ["Set %_SMTP Server..."
868 (customize-set-variable
869 'smtpmail-smtp-server
870 (read-string "Set SMTP server: " smtpmail-smtp-server)))
871 :active (and (boundp 'send-mail-function)
872 (eq send-mail-function 'smtpmail-send-it))]
876 (customize-set-variable 'smtpmail-debug-info
877 (not smtpmail-debug-info)))
879 :selected (and (boundp 'smtpmail-debug-info) smtpmail-debug-info)
880 :active (and (boundp 'send-mail-function)
881 (eq send-mail-function 'smtpmail-send-it))]
885 (customize-set-variable 'browse-url-browser-function 'browse-url-w3)
887 :selected (and (boundp 'browse-url-browser-function)
888 (eq browse-url-browser-function 'browse-url-w3))
889 :active (and (boundp 'browse-url-browser-function)
890 (fboundp 'browse-url-w3)
891 (fboundp 'w3-fetch))]
893 (customize-set-variable 'browse-url-browser-function
894 'browse-url-netscape)
896 :selected (and (boundp 'browse-url-browser-function)
897 (eq browse-url-browser-function 'browse-url-netscape))
898 :active (and (boundp 'browse-url-browser-function)
899 (fboundp 'browse-url-netscape))]
901 (customize-set-variable 'browse-url-browser-function
904 :selected (and (boundp 'browse-url-browser-function)
905 (eq browse-url-browser-function 'browse-url-mosaic))
906 :active (and (boundp 'browse-url-browser-function)
907 (fboundp 'browse-url-mosaic))]
909 (customize-set-variable 'browse-url-browser-function 'browse-url-cci)
911 :selected (and (boundp 'browse-url-browser-function)
912 (eq browse-url-browser-function 'browse-url-cci))
913 :active (and (boundp 'browse-url-browser-function)
914 (fboundp 'browse-url-cci))]
916 (customize-set-variable 'browse-url-browser-function
917 'browse-url-iximosaic)
919 :selected (and (boundp 'browse-url-browser-function)
920 (eq browse-url-browser-function 'browse-url-iximosaic))
921 :active (and (boundp 'browse-url-browser-function)
922 (fboundp 'browse-url-iximosaic))]
924 (customize-set-variable 'browse-url-browser-function
925 'browse-url-lynx-xterm)
927 :selected (and (boundp 'browse-url-browser-function)
928 (eq browse-url-browser-function 'browse-url-lynx-xterm))
929 :active (and (boundp 'browse-url-browser-function)
930 (fboundp 'browse-url-lynx-xterm))]
932 (customize-set-variable 'browse-url-browser-function
933 'browse-url-lynx-emacs)
935 :selected (and (boundp 'browse-url-browser-function)
936 (eq browse-url-browser-function 'browse-url-lynx-emacs))
937 :active (and (boundp 'browse-url-browser-function)
938 (fboundp 'browse-url-lynx-emacs))]
940 (customize-set-variable 'browse-url-browser-function
943 :selected (and (boundp 'browse-url-browser-function)
944 (eq browse-url-browser-function 'browse-url-grail))
945 :active (and (boundp 'browse-url-browser-function)
946 (fboundp 'browse-url-grail))]
948 (customize-set-variable 'browse-url-browser-function
951 :selected (and (boundp 'browse-url-browser-function)
952 (eq browse-url-browser-function 'browse-url-kfm))
953 :active (and (boundp 'browse-url-browser-function)
954 (fboundp 'browse-url-kfm))]
958 (customize-set-variable 'debug-on-error (not debug-on-error))
959 :style toggle :selected debug-on-error]
961 (customize-set-variable 'debug-on-quit (not debug-on-quit))
962 :style toggle :selected debug-on-quit]
964 (customize-set-variable 'debug-on-signal (not debug-on-signal))
965 :style toggle :selected debug-on-signal]
966 ["%_Stack Trace on Error"
967 (customize-set-variable 'stack-trace-on-error
968 (not stack-trace-on-error))
969 :style toggle :selected stack-trace-on-error]
970 ["Stack Trace on Si%_gnal"
971 (customize-set-variable 'stack-trace-on-signal
972 (not stack-trace-on-signal))
973 :style toggle :selected stack-trace-on-signal]
977 ,@(if (featurep 'scrollbar)
979 (customize-set-variable 'scrollbars-visible-p
980 (not scrollbars-visible-p))
982 :selected scrollbars-visible-p]))
984 (progn;; becomes buffer-local
985 (setq truncate-lines (not truncate-lines))
986 (customize-set-variable 'truncate-lines truncate-lines))
988 :selected (not truncate-lines)]
991 (customize-set-variable 'modeline-3d-p
994 :selected modeline-3d-p]
995 ("Modeline %_Horizontal Scrolling"
997 (customize-set-variable 'modeline-scrolling-method nil)
999 :selected (not modeline-scrolling-method)]
1001 (customize-set-variable 'modeline-scrolling-method t)
1003 :selected (eq modeline-scrolling-method t)]
1005 (customize-set-variable 'modeline-scrolling-method 'scrollbar)
1007 :selected (eq modeline-scrolling-method 'scrollbar)]
1009 ,@(if (featurep 'toolbar)
1011 ["%_Toolbars Visible"
1012 (customize-set-variable 'toolbar-visible-p
1013 (not toolbar-visible-p))
1015 :selected toolbar-visible-p]
1016 ["Toolbars Ca%_ptioned"
1017 (customize-set-variable 'toolbar-captioned-p
1018 (not toolbar-captioned-p))
1020 :active toolbar-visible-p
1021 :selected toolbar-captioned-p]
1022 ("Default Toolba%_r Location"
1024 (customize-set-variable 'default-toolbar-position 'top)
1026 :active toolbar-visible-p
1027 :selected (eq default-toolbar-position 'top)]
1029 (customize-set-variable 'default-toolbar-position 'bottom)
1031 :active toolbar-visible-p
1032 :selected (eq default-toolbar-position 'bottom)]
1034 (customize-set-variable 'default-toolbar-position 'left)
1036 :active toolbar-visible-p
1037 :selected (eq default-toolbar-position 'left)]
1039 (customize-set-variable 'default-toolbar-position 'right)
1041 :active toolbar-visible-p
1042 :selected (eq default-toolbar-position 'right)]
1045 ,@(if (featurep 'gutter)
1047 ["B%_uffers Tab Visible"
1048 (customize-set-variable 'gutter-buffers-tab-visible-p
1049 (not gutter-buffers-tab-visible-p))
1051 :selected gutter-buffers-tab-visible-p]
1052 ("Default %_Gutter Location"
1054 (customize-set-variable 'default-gutter-position 'top)
1056 :selected (eq default-gutter-position 'top)]
1058 (customize-set-variable 'default-gutter-position 'bottom)
1060 :selected (eq default-gutter-position 'bottom)]
1062 (customize-set-variable 'default-gutter-position 'left)
1064 :selected (eq default-gutter-position 'left)]
1066 (customize-set-variable 'default-gutter-position 'right)
1068 :selected (eq default-gutter-position 'right)]
1072 ["%_Blinking Cursor"
1073 (customize-set-variable 'blink-cursor-mode (not blink-cursor-mode))
1075 :selected (and (boundp 'blink-cursor-mode) blink-cursor-mode)
1076 :active (boundp 'blink-cursor-mode)]
1079 (customize-set-variable 'bar-cursor nil)
1080 (force-cursor-redisplay))
1082 :selected (null bar-cursor)]
1083 ["Bar Cursor (%_1 Pixel)"
1085 (customize-set-variable 'bar-cursor t)
1086 (force-cursor-redisplay))
1088 :selected (eq bar-cursor t)]
1089 ["Bar Cursor (%_2 Pixels)"
1091 (customize-set-variable 'bar-cursor 2)
1092 (force-cursor-redisplay))
1094 :selected (and bar-cursor (not (eq bar-cursor t)))]
1096 ("Pa%_ren Highlighting"
1098 (customize-set-variable 'paren-mode nil)
1100 :selected (and (boundp 'paren-mode) (not paren-mode))
1101 :active (boundp 'paren-mode)]
1103 (customize-set-variable 'paren-mode 'blink-paren)
1105 :selected (and (boundp 'paren-mode) (eq paren-mode 'blink-paren))
1106 :active (boundp 'paren-mode)]
1108 (customize-set-variable 'paren-mode 'paren)
1110 :selected (and (boundp 'paren-mode) (eq paren-mode 'paren))
1111 :active (boundp 'paren-mode)]
1113 (customize-set-variable 'paren-mode 'sexp)
1115 :selected (and (boundp 'paren-mode) (eq paren-mode 'sexp))
1116 :active (boundp 'paren-mode)]
1117 ;; ["Nes%_ted Shading"
1118 ;; (customize-set-variable 'paren-mode 'nested)
1120 ;; :selected (and (boundp 'paren-mode) (eq paren-mode 'nested))
1121 ;; :active (boundp 'paren-mode)]
1126 (customize-set-variable 'line-number-mode (not line-number-mode))
1128 :style toggle :selected line-number-mode]
1131 (customize-set-variable 'column-number-mode
1132 (not column-number-mode))
1134 :style toggle :selected column-number-mode]
1136 ("\"Other %_Window\" Location"
1137 ["%_Always in Same Frame"
1138 (customize-set-variable
1139 'get-frame-for-buffer-default-instance-limit nil)
1141 :selected (null get-frame-for-buffer-default-instance-limit)]
1142 ["Other Frame (%_2 Frames Max)"
1143 (customize-set-variable 'get-frame-for-buffer-default-instance-limit
1146 :selected (eq 2 get-frame-for-buffer-default-instance-limit)]
1147 ["Other Frame (%_3 Frames Max)"
1148 (customize-set-variable 'get-frame-for-buffer-default-instance-limit
1151 :selected (eq 3 get-frame-for-buffer-default-instance-limit)]
1152 ["Other Frame (%_4 Frames Max)"
1153 (customize-set-variable 'get-frame-for-buffer-default-instance-limit
1156 :selected (eq 4 get-frame-for-buffer-default-instance-limit)]
1157 ["Other Frame (%_5 Frames Max)"
1158 (customize-set-variable 'get-frame-for-buffer-default-instance-limit
1161 :selected (eq 5 get-frame-for-buffer-default-instance-limit)]
1162 ["Always Create %_New Frame"
1163 (customize-set-variable 'get-frame-for-buffer-default-instance-limit
1166 :selected (eq 0 get-frame-for-buffer-default-instance-limit)]
1168 ["%_Temp Buffers Always in Same Frame"
1169 (customize-set-variable 'temp-buffer-show-function
1170 'show-temp-buffer-in-current-frame)
1172 :selected (eq temp-buffer-show-function
1173 'show-temp-buffer-in-current-frame)]
1174 ["Temp Buffers %_Like Other Buffers"
1175 (customize-set-variable 'temp-buffer-show-function nil)
1177 :selected (null temp-buffer-show-function)]
1179 ["%_Make Current Frame Gnuserv Target"
1180 (customize-set-variable 'gnuserv-frame (if (eq gnuserv-frame t) nil
1183 :selected (and (boundp 'gnuserv-frame) (eq gnuserv-frame t))
1184 :active (boundp 'gnuserv-frame)]
1188 ["%_Frame-Local Font Menu"
1189 (customize-set-variable 'font-menu-this-frame-only-p
1190 (not font-menu-this-frame-only-p))
1192 :selected (and (boundp 'font-menu-this-frame-only-p)
1193 font-menu-this-frame-only-p)]
1194 ["%_Alt/Meta Selects Menu Items"
1195 (if (eq menu-accelerator-enabled 'menu-force)
1196 (customize-set-variable 'menu-accelerator-enabled nil)
1197 (customize-set-variable 'menu-accelerator-enabled 'menu-force))
1199 :selected (eq menu-accelerator-enabled 'menu-force)]
1201 ["Buffers Menu %_Length..."
1202 (customize-set-variable
1203 'buffers-menu-max-size
1204 ;; would it be better to open a customization buffer ?
1207 "Enter number of buffers to display (or 0 for unlimited): ")))
1208 (if (eq val 0) nil val)))]
1209 ["%_Multi-Operation Buffers Sub-Menus"
1210 (customize-set-variable 'complex-buffers-menu-p
1211 (not complex-buffers-menu-p))
1213 :selected complex-buffers-menu-p]
1214 ["S%_ubmenus for Buffer Groups"
1215 (customize-set-variable 'buffers-menu-submenus-for-groups-p
1216 (not buffers-menu-submenus-for-groups-p))
1218 :selected buffers-menu-submenus-for-groups-p]
1219 ["%_Verbose Buffer Menu Entries"
1220 (if (eq buffers-menu-format-buffer-line-function
1221 'slow-format-buffers-menu-line)
1222 (customize-set-variable 'buffers-menu-format-buffer-line-function
1223 'format-buffers-menu-line)
1224 (customize-set-variable 'buffers-menu-format-buffer-line-function
1225 'slow-format-buffers-menu-line))
1227 :selected (eq buffers-menu-format-buffer-line-function
1228 'slow-format-buffers-menu-line)]
1229 ("Buffers Menu %_Sorting"
1230 ["%_Most Recently Used"
1232 (customize-set-variable 'buffers-menu-sort-function nil)
1233 (customize-set-variable 'buffers-menu-grouping-function nil))
1235 :selected (null buffers-menu-sort-function)]
1238 (customize-set-variable 'buffers-menu-sort-function
1239 'sort-buffers-menu-alphabetically)
1240 (customize-set-variable 'buffers-menu-grouping-function nil))
1242 :selected (eq 'sort-buffers-menu-alphabetically
1243 buffers-menu-sort-function)]
1244 ["%_By Major Mode, Then Alphabetically"
1246 (customize-set-variable
1247 'buffers-menu-sort-function
1248 'sort-buffers-menu-by-mode-then-alphabetically)
1249 (customize-set-variable
1250 'buffers-menu-grouping-function
1251 'group-buffers-menu-by-mode-then-alphabetically))
1253 :selected (eq 'sort-buffers-menu-by-mode-then-alphabetically
1254 buffers-menu-sort-function)])
1256 ["%_Ignore Scaled Fonts"
1257 (customize-set-variable 'font-menu-ignore-scaled-fonts
1258 (not font-menu-ignore-scaled-fonts))
1260 :selected (and (boundp 'font-menu-ignore-scaled-fonts)
1261 font-menu-ignore-scaled-fonts)]
1263 ("S%_yntax Highlighting"
1265 (progn;; becomes buffer local
1267 (customize-set-variable 'font-lock-mode font-lock-mode))
1269 :selected (and (boundp 'font-lock-mode) font-lock-mode)
1270 :active (boundp 'font-lock-mode)]
1272 (customize-set-variable 'font-lock-auto-fontify
1273 (not font-lock-auto-fontify))
1275 :selected (and (boundp 'font-lock-auto-fontify) font-lock-auto-fontify)
1276 :active (fboundp 'font-lock-mode)]
1278 ["Force %_Rehighlight in this Buffer"
1279 (customize-set-variable 'font-lock-auto-fontify
1280 (not font-lock-auto-fontify))
1282 :selected (and (boundp 'font-lock-auto-fontify) font-lock-auto-fontify)
1283 :active (fboundp 'font-lock-mode)]
1287 (require 'font-lock)
1288 (font-lock-use-default-fonts)
1289 (customize-set-variable 'font-lock-use-fonts t)
1290 (customize-set-variable 'font-lock-use-colors nil)
1293 :selected (and (boundp 'font-lock-use-fonts) font-lock-use-fonts)
1294 :active (fboundp 'font-lock-mode)]
1297 (require 'font-lock)
1298 (font-lock-use-default-colors)
1299 (customize-set-variable 'font-lock-use-colors t)
1300 (customize-set-variable 'font-lock-use-fonts nil)
1303 :selected (and (boundp 'font-lock-use-colors) font-lock-use-colors)
1304 :active (boundp 'font-lock-mode)]
1308 (require 'font-lock)
1309 (if (or (and (not (integerp font-lock-maximum-decoration))
1310 (not (eq t font-lock-maximum-decoration)))
1311 (and (integerp font-lock-maximum-decoration)
1312 (<= font-lock-maximum-decoration 0)))
1314 (customize-set-variable 'font-lock-maximum-decoration nil)
1315 (font-lock-recompute-variables)))
1317 :active (fboundp 'font-lock-mode)
1318 :selected (and (boundp 'font-lock-maximum-decoration)
1319 (or (and (not (integerp font-lock-maximum-decoration))
1320 (not (eq t font-lock-maximum-decoration)))
1321 (and (integerp font-lock-maximum-decoration)
1322 (<= font-lock-maximum-decoration 0))))]
1325 (require 'font-lock)
1326 (if (and (integerp font-lock-maximum-decoration)
1327 (= 1 font-lock-maximum-decoration))
1329 (customize-set-variable 'font-lock-maximum-decoration 1)
1330 (font-lock-recompute-variables)))
1332 :active (fboundp 'font-lock-mode)
1333 :selected (and (boundp 'font-lock-maximum-decoration)
1334 (integerp font-lock-maximum-decoration)
1335 (= 1 font-lock-maximum-decoration))]
1338 (require 'font-lock)
1339 (if (and (integerp font-lock-maximum-decoration)
1340 (= 2 font-lock-maximum-decoration))
1342 (customize-set-variable 'font-lock-maximum-decoration 2)
1343 (font-lock-recompute-variables)))
1345 :active (fboundp 'font-lock-mode)
1346 :selected (and (boundp 'font-lock-maximum-decoration)
1347 (integerp font-lock-maximum-decoration)
1348 (= 2 font-lock-maximum-decoration))]
1351 (require 'font-lock)
1352 (if (or (eq font-lock-maximum-decoration t)
1353 (and (integerp font-lock-maximum-decoration)
1354 (>= font-lock-maximum-decoration 3)))
1356 (customize-set-variable 'font-lock-maximum-decoration t)
1357 (font-lock-recompute-variables)))
1359 :active (fboundp 'font-lock-mode)
1360 :selected (and (boundp 'font-lock-maximum-decoration)
1361 (or (eq font-lock-maximum-decoration t)
1362 (and (integerp font-lock-maximum-decoration)
1363 (>= font-lock-maximum-decoration 3))))]
1366 (progn;; becomes buffer local
1368 (customize-set-variable 'lazy-lock-mode lazy-lock-mode)
1369 ;; this shouldn't be necessary so there has to
1370 ;; be a redisplay bug lurking somewhere (or
1371 ;; possibly another event handler bug)
1373 :active (and (boundp 'font-lock-mode) (boundp 'lazy-lock-mode)
1376 :selected (and (boundp 'lazy-lock-mode) lazy-lock-mode)]
1378 (progn;; becomes buffer local
1380 (customize-set-variable 'lazy-shot-mode lazy-shot-mode)
1381 ;; this shouldn't be necessary so there has to
1382 ;; be a redisplay bug lurking somewhere (or
1383 ;; possibly another event handler bug)
1385 :active (and (boundp 'font-lock-mode) (boundp 'lazy-shot-mode)
1388 :selected (and (boundp 'lazy-shot-mode) lazy-shot-mode)]
1390 (progn;; becomes buffer local
1392 (customize-set-variable 'fast-lock-mode fast-lock-mode)
1393 ;; this shouldn't be necessary so there has to
1394 ;; be a redisplay bug lurking somewhere (or
1395 ;; possibly another event handler bug)
1397 :active (and (boundp 'font-lock-mode) (boundp 'fast-lock-mode)
1400 :selected (and (boundp 'fast-lock-mode) fast-lock-mode)]
1402 ("%_Font" :filter font-menu-family-constructor)
1403 ("Font Si%_ze" :filter font-menu-size-constructor)
1404 ;; ("Font Weig%_ht" :filter font-menu-weight-constructor)
1405 ["Edit Fa%_ces..." (customize-face nil)]
1408 ;; #### there should be something that holds the name that the init
1409 ;; file should be created as, when it's not present.
1410 (progn (find-file (or user-init-file "~/.xemacs/init.el"))
1411 (or (eq major-mode 'emacs-lisp-mode)
1412 (emacs-lisp-mode)))]
1413 ["%_Save Options to Init File" customize-save-customized]
1417 :filter buffers-menu-filter
1418 ["Go To %_Previous Buffer" switch-to-other-buffer]
1419 ["Go To %_Buffer..." switch-to-buffer]
1421 ["%_List All Buffers" list-buffers]
1422 ["%_Delete Buffer" kill-this-buffer
1423 :suffix (if put-buffer-names-in-file-menu (buffer-name) "")]
1427 nil ; the partition: menus after this are flushright
1430 ["%_About XEmacs..." about-xemacs]
1432 ["What's %_New in XEmacs" view-emacs-news]
1433 ["%_Obtaining XEmacs" describe-distribution]
1435 ("%_Info (Online Docs)"
1436 ["%_Info Contents" info]
1437 ["Lookup %_Key Binding..." Info-goto-emacs-key-command-node]
1438 ["Lookup %_Command..." Info-goto-emacs-command-node]
1439 ["Lookup %_Function..." Info-elisp-ref]
1440 ["Lookup %_Topic..." Info-query])
1442 ["%_FAQ (local)" xemacs-local-faq]
1443 ["FAQ via %_WWW" xemacs-www-faq
1444 :active (fboundp 'browse-url)]
1445 ["%_Home Page" xemacs-www-page
1446 :active (fboundp 'browse-url)])
1448 :filter tutorials-menu-filter)
1451 (find-file (locate-data-file "sample.init.el"))
1452 :active (locate-data-file "sample.init.el")]
1454 (find-file (locate-data-file "sample.gtkrc"))
1455 :included (featurep 'gtk)
1456 :active (locate-data-file "sample.gtkrc")]
1457 ["Sample .%_Xdefaults"
1458 (find-file (locate-data-file "sample.Xdefaults"))
1459 :included (featurep 'x)
1460 :active (locate-data-file "sample.Xdefaults")]
1461 ["Sample %_enriched"
1462 (find-file (locate-data-file "enriched.doc"))
1463 :active (locate-data-file "enriched.doc")])
1464 ("%_Commands & Keys"
1465 ["%_Mode" describe-mode]
1466 ["%_Apropos..." hyper-apropos]
1467 ["Apropos %_Docs..." apropos-documentation]
1469 ["%_Key..." describe-key]
1470 ["%_Bindings" describe-bindings]
1471 ["%_Mouse Bindings" describe-pointer]
1472 ["%_Recent Keys" view-lossage]
1474 ["%_Function..." describe-function]
1475 ["%_Variable..." describe-variable]
1476 ["%_Locate Command..." where-is])
1478 ["%_Recent Messages" view-lossage]
1480 ["%_Current Installation Info" describe-installation
1481 :active (boundp 'Installation-string)]
1482 ["%_No Warranty" describe-no-warranty]
1483 ["XEmacs %_License" describe-copying]
1484 ["Find %_Packages" finder-by-keyword]
1485 ["View %_Splash Screen" xemacs-splash-buffer]
1486 ["%_Unix Manual..." manual-entry])
1487 ["Send %_Bug Report..." report-xemacs-bug
1488 :active (fboundp 'report-xemacs-bug)])))
1491 (defun maybe-add-init-button ()
1493 Adds `Load .emacs' button to menubar when starting up with -q."
1494 (when (and (not load-user-init-file-p)
1495 (file-exists-p (expand-file-name ".emacs" "~")))
1500 (mapc #'(lambda (buf)
1501 (with-current-buffer buf
1502 (delete-menu-item '("Load .emacs"))))
1504 (load-user-init-file))
1508 (add-hook 'before-init-hook 'maybe-add-init-button)
1513 (defvar put-buffer-names-in-file-menu t)
1516 ;;; The Bookmarks menu
1518 (defun bookmark-menu-filter (&rest ignore)
1519 (declare (special bookmark-alist))
1520 (let ((definedp (and (boundp 'bookmark-alist)
1524 '("%_Jump to Bookmark"
1525 :filter (lambda (&rest junk)
1526 (submenu-generate-accelerator-spec
1527 (mapcar #'(lambda (bmk)
1528 `[,bmk (bookmark-jump ',bmk)])
1529 (bookmark-all-names)))))
1530 ["%_Jump to Bookmark" nil nil])
1531 ["Set %_Bookmark" bookmark-set
1532 :active (fboundp 'bookmark-set)]
1534 ["Insert %_Contents" bookmark-menu-insert
1535 :active (fboundp 'bookmark-menu-insert)]
1536 ["Insert L%_ocation" bookmark-menu-locate
1537 :active (fboundp 'bookmark-menu-locate)]
1539 ["%_Rename Bookmark" bookmark-menu-rename
1540 :active (fboundp 'bookmark-menu-rename)]
1542 '("%_Delete Bookmark"
1543 :filter (lambda (&rest junk)
1544 (submenu-generate-accelerator-spec
1545 (mapcar #'(lambda (bmk)
1546 `[,bmk (bookmark-delete ',bmk)])
1547 (bookmark-all-names)))))
1548 ["%_Delete Bookmark" nil nil])
1549 ["%_Edit Bookmark List" bookmark-bmenu-list ,definedp]
1551 ["%_Save Bookmarks" bookmark-save ,definedp]
1552 ["Save Bookmarks %_As..." bookmark-write ,definedp]
1553 ["%_Load a Bookmark File" bookmark-load
1554 :active (fboundp 'bookmark-load)])))
1556 ;;; The Buffers menu
1558 (defgroup buffers-menu nil
1559 "Customization of `Buffers' menu."
1562 (defvar buffers-menu-omit-chars-list '(?b ?p ?l ?d))
1564 (defcustom buffers-menu-max-size 25
1565 "*Maximum number of entries which may appear on the \"Buffers\" menu.
1566 If this is 10, then only the ten most-recently-selected buffers will be
1567 shown. If this is nil, then all buffers will be shown. Setting this to
1568 a large number or nil will slow down menu responsiveness."
1569 :type '(choice (const :tag "Show all" nil)
1571 :group 'buffers-menu)
1573 (defcustom complex-buffers-menu-p nil
1574 "*If non-nil, the buffers menu will contain several commands.
1575 Commands will be presented as submenus of each buffer line. If this
1576 is false, then there will be only one command: select that buffer."
1578 :group 'buffers-menu)
1580 (defcustom buffers-menu-submenus-for-groups-p nil
1581 "*If non-nil, the buffers menu will contain one submenu per group of buffers.
1582 The grouping function is specified in `buffers-menu-grouping-function'.
1583 If this is an integer, do not build submenus if the number of buffers
1584 is not larger than this value."
1585 :type '(choice (const :tag "No Subgroups" nil)
1586 (integer :tag "Max. submenus" 10)
1587 (sexp :format "%t\n" :tag "Allow Subgroups" :value t))
1588 :group 'buffers-menu)
1590 (defcustom buffers-menu-switch-to-buffer-function 'switch-to-buffer
1591 "*The function to call to select a buffer from the buffers menu.
1592 `switch-to-buffer' is a good choice, as is `pop-to-buffer'."
1593 :type '(radio (function-item switch-to-buffer)
1594 (function-item pop-to-buffer)
1595 (function :tag "Other"))
1596 :group 'buffers-menu)
1598 (defcustom buffers-menu-omit-function 'buffers-menu-omit-invisible-buffers
1599 "*If non-nil, a function specifying the buffers to omit from the buffers menu.
1600 This is passed a buffer and should return non-nil if the buffer should be
1601 omitted. The default value `buffers-menu-omit-invisible-buffers' omits
1602 buffers that are normally considered \"invisible\" (those whose name
1603 begins with a space)."
1604 :type '(choice (const :tag "None" nil)
1606 :group 'buffers-menu)
1608 (defcustom buffers-menu-format-buffer-line-function 'format-buffers-menu-line
1609 "*The function to call to return a string to represent a buffer in
1610 the buffers menu. The function is passed a buffer and a number
1611 (starting with 1) indicating which buffer line in the menu is being
1612 processed and should return a string containing an accelerator
1613 spec. (Check out `menu-item-generate-accelerator-spec' as a convenient
1614 way of generating the accelerator specs.) The default value
1615 `format-buffers-menu-line' just returns the name of the buffer and
1616 uses the number as the accelerator. Also check out
1617 `slow-format-buffers-menu-line' which returns a whole bunch of info
1620 Note: Gross Compatibility Hack: Older versions of this function prototype
1621 only expected one argument, not two. We deal gracefully with such
1622 functions by simply calling them with one argument and leaving out the
1623 line number. However, this may go away at any time, so make sure to
1624 update all of your functions of this type."
1626 :group 'buffers-menu)
1628 (defcustom buffers-menu-sort-function
1629 'sort-buffers-menu-by-mode-then-alphabetically
1630 "*If non-nil, a function to sort the list of buffers in the buffers menu.
1631 It will be passed two arguments (two buffers to compare) and should return
1632 t if the first is \"less\" than the second. One possible value is
1633 `sort-buffers-menu-alphabetically'; another is
1634 `sort-buffers-menu-by-mode-then-alphabetically'."
1635 :type '(choice (const :tag "None" nil)
1637 :group 'buffers-menu)
1639 (defcustom buffers-menu-grouping-function
1640 'group-buffers-menu-by-mode-then-alphabetically
1641 "*If non-nil, a function to group buffers in the buffers menu together.
1642 It will be passed two arguments, successive members of the sorted buffers
1643 list after being passed through `buffers-menu-sort-function'. It should
1644 return non-nil if the second buffer begins a new group. The return value
1645 should be the name of the old group, which may be used in hierarchical
1646 buffers menus. The last invocation of the function contains nil as the
1647 second argument, so that the name of the last group can be determined.
1649 The sensible values of this function are dependent on the value specified
1650 for `buffers-menu-sort-function'."
1651 :type '(choice (const :tag "None" nil)
1653 :group 'buffers-menu)
1655 (defun sort-buffers-menu-alphabetically (buf1 buf2)
1656 "For use as a value of `buffers-menu-sort-function'.
1657 Sorts the buffers in alphabetical order by name, but puts buffers beginning
1658 with a star at the end of the list."
1659 (let* ((nam1 (buffer-name buf1))
1660 (nam2 (buffer-name buf2))
1661 (inv1p (not (null (string-match "\\` " nam1))))
1662 (inv2p (not (null (string-match "\\` " nam2))))
1663 (star1p (not (null (string-match "\\`*" nam1))))
1664 (star2p (not (null (string-match "\\`*" nam2)))))
1665 (cond ((not (eq inv1p inv2p))
1667 ((not (eq star1p star2p))
1670 (string-lessp nam1 nam2)))))
1672 (defun sort-buffers-menu-by-mode-then-alphabetically (buf1 buf2)
1673 "For use as a value of `buffers-menu-sort-function'.
1674 Sorts first by major mode and then alphabetically by name, but puts buffers
1675 beginning with a star at the end of the list."
1676 (let* ((nam1 (buffer-name buf1))
1677 (nam2 (buffer-name buf2))
1678 (inv1p (not (null (string-match "\\` " nam1))))
1679 (inv2p (not (null (string-match "\\` " nam2))))
1680 (star1p (not (null (string-match "\\`*" nam1))))
1681 (star2p (not (null (string-match "\\`*" nam2))))
1682 (mode1 (symbol-value-in-buffer 'major-mode buf1))
1683 (mode2 (symbol-value-in-buffer 'major-mode buf2)))
1684 (cond ((not (eq inv1p inv2p))
1686 ((not (eq star1p star2p))
1688 ((and star1p star2p (string-lessp nam1 nam2)))
1689 ((string-lessp mode1 mode2)
1691 ((string-lessp mode2 mode1)
1694 (string-lessp nam1 nam2)))))
1696 ;; this version is too slow on some machines.
1697 ;; (vintage 1990, that is)
1698 (defun slow-format-buffers-menu-line (buffer n)
1699 "For use as a value of `buffers-menu-format-buffer-line-function'.
1700 This returns a string containing a bunch of info about the buffer."
1701 (concat (menu-item-generate-accelerator-spec n buffers-menu-omit-chars-list)
1702 (format "%s%s %-19s %6s %-15s %s"
1703 (if (buffer-modified-p buffer) "*" " ")
1704 (if (symbol-value-in-buffer 'buffer-read-only buffer)
1706 (buffer-name buffer)
1707 (buffer-size buffer)
1708 (symbol-value-in-buffer 'mode-name buffer)
1709 (or (buffer-file-name buffer) ""))))
1711 (defun format-buffers-menu-line (buffer n)
1712 "For use as a value of `buffers-menu-format-buffer-line-function'.
1713 This just returns the buffer's name."
1714 (concat (menu-item-generate-accelerator-spec n buffers-menu-omit-chars-list)
1715 (buffer-name buffer)))
1717 (defun group-buffers-menu-by-mode-then-alphabetically (buf1 buf2)
1718 "For use as a value of `buffers-menu-grouping-function'.
1719 This groups buffers by major mode. It only really makes sense if
1720 `buffers-menu-sorting-function' is
1721 `sort-buffers-menu-by-mode-then-alphabetically'."
1722 (cond ((string-match "\\`*" (buffer-name buf1))
1723 (and (null buf2) "*Misc*"))
1725 (string-match "\\`*" (buffer-name buf2))
1726 (not (eq (symbol-value-in-buffer 'major-mode buf1)
1727 (symbol-value-in-buffer 'major-mode buf2))))
1728 (symbol-value-in-buffer 'mode-name buf1))
1731 (defun buffer-menu-save-buffer (buffer)
1736 (defun buffer-menu-write-file (buffer)
1739 (write-file (read-file-name
1740 (format "Write %s to file: "
1741 (buffer-name (current-buffer)))))))
1743 (defsubst build-buffers-menu-internal (buffers)
1744 (let (name line (n 0))
1751 ; #### a truly Kyle-friendly hack.
1752 (let ((fn buffers-menu-format-buffer-line-function))
1753 (if (= (function-max-args fn) 1)
1755 (funcall fn buffer n))))
1756 (if complex-buffers-menu-p
1759 (vector "S%_witch to Buffer"
1760 (list buffers-menu-switch-to-buffer-function
1761 (setq name (buffer-name buffer)))
1763 (if (eq buffers-menu-switch-to-buffer-function
1765 (vector "Switch to Buffer, Other %_Frame"
1766 (list 'switch-to-buffer-other-frame
1767 (setq name (buffer-name buffer)))
1770 (if (and (buffer-modified-p buffer)
1771 (buffer-file-name buffer))
1772 (vector "%_Save Buffer"
1773 (list 'buffer-menu-save-buffer name) t)
1774 ["%_Save Buffer" nil nil]
1776 (vector "Save %_As..."
1777 (list 'buffer-menu-write-file name) t)
1778 (vector "%_Delete Buffer" (list 'kill-buffer name)
1780 ;; #### We don't want buffer names to be translated,
1781 ;; #### so we put the buffer name in the suffix.
1782 ;; #### Also, avoid losing with non-ASCII buffer names.
1783 ;; #### We still lose, however, if complex-buffers-menu-p. --mrb
1785 (list buffers-menu-switch-to-buffer-function
1786 (buffer-name buffer))
1790 (defun buffers-menu-filter (menu)
1791 "This is the menu filter for the top-level buffers \"Buffers\" menu.
1792 It dynamically creates a list of buffers to use as the contents of the menu.
1793 Only the most-recently-used few buffers will be listed on the menu, for
1794 efficiency reasons. You can control how many buffers will be shown by
1795 setting `buffers-menu-max-size'. You can control the text of the menu
1796 items by redefining the function `format-buffers-menu-line'."
1797 (let ((buffers (delete-if buffers-menu-omit-function (buffer-list))))
1798 (and (integerp buffers-menu-max-size)
1799 (> buffers-menu-max-size 1)
1800 (> (length buffers) buffers-menu-max-size)
1801 ;; shorten list of buffers (not with submenus!)
1802 (not (and buffers-menu-grouping-function
1803 buffers-menu-submenus-for-groups-p))
1804 (setcdr (nthcdr buffers-menu-max-size buffers) nil))
1805 (if buffers-menu-sort-function
1806 (setq buffers (sort buffers buffers-menu-sort-function)))
1807 (if (and buffers-menu-grouping-function
1808 buffers-menu-submenus-for-groups-p
1809 (or (not (integerp buffers-menu-submenus-for-groups-p))
1810 (> (length buffers) buffers-menu-submenus-for-groups-p)))
1811 (let (groups groupnames current-group)
1814 (let ((groupname (funcall buffers-menu-grouping-function
1815 (car sublist) (cadr sublist))))
1816 (setq current-group (cons (car sublist) current-group))
1819 (setq groups (cons (nreverse current-group)
1821 (setq groupnames (cons groupname groupnames))
1822 (setq current-group nil)))))
1826 #'(lambda (groupname group)
1827 (cons groupname (build-buffers-menu-internal group)))
1828 (nreverse groupnames)
1829 (nreverse groups))))
1830 (if buffers-menu-grouping-function
1835 (cond ((funcall buffers-menu-grouping-function
1836 (car sublist) (cadr sublist))
1837 (list (car sublist) t))
1838 (t (list (car sublist)))))
1840 ;; remove a trailing separator.
1841 (and (>= (length buffers) 2)
1842 (let ((lastcdr (nthcdr (- (length buffers) 2) buffers)))
1843 (if (eq t (cadr lastcdr))
1844 (setcdr lastcdr nil))))))
1845 (setq buffers (build-buffers-menu-internal buffers)))
1846 (append menu buffers)
1849 (defun language-environment-menu-filter (menu)
1850 "This is the menu filter for the \"Language Environment\" submenu."
1851 (declare (special language-environment-list))
1853 (mapcar (lambda (env-sym)
1855 `[ ,(concat (menu-item-generate-accelerator-spec n)
1856 (capitalize (symbol-name env-sym)))
1857 (set-language-environment ',env-sym)])
1858 language-environment-list)))
1861 ;;; The Options menu
1863 ;; We'll keep those variables here for a while, in order to provide a
1864 ;; function for porting the old options file that a user may own to Custom.
1866 (defvar options-save-faces nil
1867 "*Non-nil value means save-options will save information about faces.
1868 A nil value means save-options will not save face information.
1869 Set this non-nil only if you use M-x edit-faces to change face
1870 settings. If you use M-x customize-face or the \"Browse Faces...\"
1871 menu entry, you will see a button in the Customize Face buffer that you
1872 can use to permanently save your face changes.
1874 M-x edit-faces is deprecated. Support for it and this variable will
1875 be discontinued in a future release.")
1877 (defvar save-options-init-file nil
1878 "File into which to save forms to load the options file (nil for .emacs).
1879 Normally this is nil, which means save into your .emacs file (the value
1880 of `user-init-file'.")
1882 (defvar save-options-file ".xemacs-options"
1883 "File to save options into.
1884 This file is loaded from your .emacs file.
1885 If this is a relative filename, it is put into the same directory as your
1892 (defun tutorials-menu-filter (menu-items)
1893 (declare (special language-info-alist
1894 current-language-environment
1895 tutorial-supported-languages))
1897 (if (featurep 'mule)
1899 (assoc current-language-environment language-info-alist))
1900 `([,(concat "%_Default (" current-language-environment ")")
1901 help-with-tutorial]))
1902 '(["%_English" help-with-tutorial]))
1903 (submenu-generate-accelerator-spec
1904 (if (featurep 'mule)
1906 (mapcan #'(lambda (lang)
1907 (let ((tut (assq 'tutorial lang)))
1909 (not (string= (car lang) "ASCII"))
1910 ;; skip current language, since we already
1911 ;; included it first
1912 (not (string= (car lang)
1913 current-language-environment))
1915 (help-with-tutorial nil ,(cdr tut))]))))
1916 language-info-alist)
1917 ;; Non mule tutorials.
1918 (mapcar #'(lambda (lang)
1920 (help-with-tutorial ,(format "TUTORIAL.%s"
1922 tutorial-supported-languages)))))
1924 (set-menubar default-menubar)
1929 (defconst default-popup-menu
1931 ["%_Undo" advertised-undo
1932 :active (and (not (eq buffer-undo-list t))
1933 (or buffer-undo-list pending-undo-list))
1934 :suffix (if (or (eq last-command 'undo)
1935 (eq last-command 'advertised-undo))
1937 ["Cu%_t" kill-primary-selection
1938 :active (selection-owner-p)]
1939 ["%_Copy" copy-primary-selection
1940 :active (selection-owner-p)]
1941 ["%_Paste" yank-clipboard-selection
1942 :active (selection-exists-p 'CLIPBOARD)]
1943 ["%_Delete" delete-primary-selection
1944 :active (selection-owner-p)]
1946 ["Select %_Block" mark-paragraph]
1947 ["Sp%_lit Window" split-window-vertically]
1948 ["U%_nsplit Window" delete-other-windows]
1951 ;; In an effort to avoid massive menu clutter, this mostly worthless menu is
1952 ;; superseded by any local popup menu...
1953 (setq-default mode-popup-menu default-popup-menu)
1958 (defun xemacs-splash-buffer ()
1959 "Redisplay XEmacs splash screen in a buffer."
1961 (let ((buffer (get-buffer-create "*Splash*"))
1964 (setq buffer-read-only t)
1965 (erase-buffer buffer)
1966 (setq tmout (display-splash-frame))
1968 (make-local-hook 'kill-buffer-hook)
1969 (add-hook 'kill-buffer-hook
1971 (disable-timeout ,tmout))
1973 (pop-to-buffer buffer)
1974 (delete-other-windows)))
1977 ;;; backwards compatibility
1978 (provide 'x-menubar)
1979 (provide 'menubar-items)
1981 ;;; menubar-items.el ends here.