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-history (list count label-length)
58 "Truncate a history LIST to first COUNT items.
59 Return a list of (label value) lists with labels truncated to last
60 LABEL-LENGTH characters of value."
62 (if (<= (length x) label-length)
65 (concat "..." (substring x (- label-length))) x)))
66 (if (<= (length list) count)
68 (butlast list (- (length list) count)))))
70 (defun submenu-generate-accelerator-spec (list &optional omit-chars-list)
71 "Add auto-generated accelerator specifications to a submenu.
72 This can be used to add accelerators to the return value of a menu filter
73 function. It correctly ignores unselectable items. It will destructively
74 modify the list passed to it. If an item already has an auto-generated
75 accelerator spec, this will be removed before the new one is added, making
76 this function idempotent.
78 If OMIT-CHARS-LIST is given, it should be a list of lowercase characters,
79 which will not be used as accelerators."
81 (dolist (item list list)
87 (menu-item-generate-accelerator-spec n omit-chars-list)
88 (menu-item-strip-accelerator-spec (aref item 0)))))
93 (menu-item-generate-accelerator-spec n omit-chars-list)
94 (menu-item-strip-accelerator-spec (car item)))))))))
96 (defun menu-item-strip-accelerator-spec (item)
97 "Strip an auto-generated accelerator spec off of ITEM.
98 ITEM should be a string. This removes specs added by
99 `menu-item-generate-accelerator-spec' and `submenu-generate-accelerator-spec'."
100 (if (string-match "%_. " item)
104 (defun menu-item-generate-accelerator-spec (n &optional omit-chars-list)
105 "Return an accelerator specification for use with auto-generated menus.
106 This should be concat'd onto the beginning of each menu line. The spec
107 allows the Nth line to be selected by the number N. '0' is used for the
108 10th line, and 'a' through 'z' are used for the following 26 lines.
110 If OMIT-CHARS-LIST is given, it should be a list of lowercase characters,
111 which will not be used as accelerators."
112 (cond ((< n 10) (concat "%_" (int-to-string n) " "))
119 (while (memq (int-to-char (+ m (- (char-to-int ?a) 1)))
126 (char-to-string (int-to-char (+ m (- (char-to-int ?a) 1))))
131 (defconst default-menubar
132 ; (purecopy-menubar ;purespace is dead
136 ["%_Open..." find-file]
137 ["Open in Other %_Window..." find-file-other-window]
138 ["Open in New %_Frame..." find-file-other-frame]
139 ["%_Hex Edit File..." hexl-find-file
140 :active (fboundp 'hexl-find-file)]
141 ["%_Insert File..." insert-file]
142 ["%_View File..." view-file]
144 ["%_Save" save-buffer
145 :active (buffer-modified-p)
146 :suffix (if put-buffer-names-in-file-menu (buffer-name) "")]
147 ["Save %_As..." write-file]
148 ["Save So%_me Buffers" save-some-buffers]
150 ,@(if (valid-specifier-tag-p 'msprinter)
151 '(["Page Set%_up..." generic-page-setup]))
152 ["%_Print" generic-print-buffer
153 :active (or (valid-specifier-tag-p 'msprinter)
154 (and (not (eq system-type 'windows-nt))
155 (fboundp 'lpr-region)))
156 :suffix (if (region-active-p) "Selection..."
157 (if put-buffer-names-in-file-menu (concat (buffer-name) "...")
159 ,@(unless (valid-specifier-tag-p 'msprinter)
160 '(["Prett%_y-Print" ps-print-buffer-with-faces
161 :active (fboundp 'ps-print-buffer-with-faces)
162 :suffix (if put-buffer-names-in-file-menu (buffer-name) "")]))
164 ["%_Revert Buffer" revert-buffer
165 :active (or buffer-file-name revert-buffer-function)
166 :suffix (if put-buffer-names-in-file-menu (buffer-name) "")]
167 ["Re%_cover File..." recover-file]
168 ["Recover S%_ession..." recover-session]
170 ["E%_xit XEmacs" save-buffers-kill-emacs]
174 ["%_Undo" advertised-undo
175 :active (and (not (eq buffer-undo-list t))
176 (or buffer-undo-list pending-undo-list))
177 :suffix (if (or (eq last-command 'undo)
178 (eq last-command 'advertised-undo))
181 :included (fboundp 'redo)
182 :active (not (or (eq buffer-undo-list t)
183 (eq last-buffer-undo-list nil)
184 (not (or (eq last-buffer-undo-list buffer-undo-list)
185 (and (null (car-safe buffer-undo-list))
186 (eq last-buffer-undo-list
187 (cdr-safe buffer-undo-list)))))
188 (or (eq buffer-undo-list pending-undo-list)
189 (eq (cdr buffer-undo-list) pending-undo-list))))
190 :suffix (if (eq last-command 'redo) "More" "")]
192 ["Cu%_t" kill-primary-selection
193 :active (selection-owner-p)]
194 ["%_Copy" copy-primary-selection
195 :active (selection-owner-p)]
196 ["%_Paste" yank-clipboard-selection
197 :active (selection-exists-p 'CLIPBOARD)]
198 ["%_Delete" delete-primary-selection
199 :active (selection-owner-p)]
201 ["Select %_All" mark-whole-buffer]
202 ["Select Pa%_ge" mark-page]
204 ["%_Find..." make-search-dialog]
205 ["R%_eplace..." query-replace]
206 ["Replace (Rege%_xp)..." query-replace-regexp]
207 ["%_List Matching Lines..." list-matching-lines]
208 ,@(when (featurep 'mule)
210 ("%_Multilingual (\"Mule\")"
211 ("%_Describe Language Support")
212 ("%_Set Language Environment")
214 ["T%_oggle Input Method" toggle-input-method]
215 ["Select %_Input Method" set-input-method]
216 ["D%_escribe Input Method" describe-input-method]
218 ["Describe Current %_Coding Systems"
219 describe-current-coding-system]
220 ["Set Coding System of %_Buffer File..."
221 set-buffer-file-coding-system]
222 ;; not implemented yet
223 ["Set Coding System of %_Terminal..."
224 set-terminal-coding-system :active nil]
225 ;; not implemented yet
226 ["Set Coding System of %_Keyboard..."
227 set-keyboard-coding-system :active nil]
228 ["Set Coding System of %_Process..."
229 set-buffer-process-coding-system
230 :active (get-buffer-process (current-buffer))]
232 ["Show Cha%_racter Table" view-charset-by-menu]
233 ;; not implemented yet
234 ["Show Dia%_gnosis for MULE" mule-diag :active nil]
235 ["Show \"%_hello\" in Many Languages" view-hello-file]))
240 ["%_New Frame" make-frame]
241 ["Frame on Other Displa%_y..." make-frame-on-display
242 :active (fboundp 'make-frame-on-display)]
243 ["%_Delete Frame" delete-frame
244 :active (not (eq (next-frame (selected-frame) 'nomini 'window-system)
247 ["%_Split Window" split-window-vertically]
248 ["S%_plit Window (Side by Side)" split-window-horizontally]
249 ["%_Un-Split (Keep This)" delete-other-windows
250 :active (not (one-window-p t))]
251 ["Un-Split (Keep %_Others)" delete-window
252 :active (not (one-window-p t))]
255 ["%_Narrow to Region" narrow-to-region :active (region-exists-p)]
256 ["Narrow to %_Page" narrow-to-page]
257 ["Narrow to %_Defun" narrow-to-defun]
259 ["%_Widen" widen :active (or (/= (point-min) 1)
260 (/= (point-max) (1+ (buffer-size))))]
263 ["Show Message %_Log" show-message-log]
265 ["%_Goto Line..." goto-line]
266 ["%_What Line" what-line]
268 :filter bookmark-menu-filter)
270 ["%_Jump to Previous Mark" (set-mark-command t)
275 ["Repeat %_Last Complex Command..." repeat-complex-command]
276 ["E%_valuate Lisp Expression..." eval-expression]
277 ["Execute %_Named Command..." execute-extended-command]
279 ["Start %_Macro Recording" start-kbd-macro
280 :included (not defining-kbd-macro)]
281 ["End %_Macro Recording" end-kbd-macro
282 :included defining-kbd-macro]
283 ["E%_xecute Last Macro" call-last-kbd-macro
284 :active last-kbd-macro]
286 ["%_Append to Last Macro" (start-kbd-macro t)
287 :active (and (not defining-kbd-macro) last-kbd-macro)]
288 ["%_Query User During Macro" kbd-macro-query
289 :active defining-kbd-macro]
290 ["Enter %_Recursive Edit During Macro" (kbd-macro-query t)
291 :active defining-kbd-macro]
293 ["E%_xecute Last Macro on Region Lines"
294 :active (and last-kbd-macro (region-exists-p))]
296 ["%_Name Last Macro..." name-last-kbd-macro
297 :active last-kbd-macro]
298 ["Assign Last Macro to %_Key..." assign-last-kbd-macro-to-key
299 :active (and last-kbd-macro
300 (fboundp 'assign-last-kbd-macro-to-key))]
302 ["%_Edit Macro..." edit-kbd-macro]
303 ["Edit %_Last Macro" edit-last-kbd-macro
304 :active last-kbd-macro]
306 ["%_Insert Named Macro into Buffer..." insert-kbd-macro]
307 ["Read Macro from Re%_gion" read-kbd-macro
308 :active (region-exists-p)]
312 ["D%_ynamic Abbrev Expand" dabbrev-expand]
313 ["Dynamic Abbrev %_Complete" dabbrev-completion]
314 ["Dynamic Abbrev Complete in %_All Buffers" (dabbrev-completion 16)]
317 ["%_Define Global Abbrev for " add-global-abbrev
318 :suffix (abbrev-string-to-be-defined nil)
320 ["Define %_Mode-Specific Abbrev for " add-mode-abbrev
321 :suffix (abbrev-string-to-be-defined nil)
323 ["Define Global Ex%_pansion for " inverse-add-global-abbrev
324 :suffix (inverse-abbrev-string-to-be-defined 1)
326 ["Define Mode-Specific Expa%_nsion for " inverse-add-mode-abbrev
327 :suffix (inverse-abbrev-string-to-be-defined 1)
330 ["E%_xpand Abbrev" expand-abbrev]
331 ["Expand Abbrevs in Re%_gion" expand-region-abbrevs
332 :active (region-exists-p)]
333 ["%_Unexpand Last Abbrev" unexpand-abbrev
334 :active (and (stringp last-abbrev-text)
335 (> last-abbrev-location 0))]
337 ["%_Kill All Abbrevs" kill-all-abbrevs]
338 ["%_Insert All Abbrevs into Buffer" insert-abbrevs]
339 ["%_List Abbrevs" list-abbrevs]
341 ["%_Edit Abbrevs" edit-abbrevs]
342 ["%_Redefine Abbrevs from Buffer" edit-abbrevs-redefine
343 :active (eq major-mode 'edit-abbrevs-mode)]
345 ["%_Save Abbrevs As..." write-abbrev-file]
346 ["L%_oad Abbrevs..." read-abbrev-file]
349 ["%_Copy to Register..." copy-to-register :active (region-exists-p)]
350 ["%_Paste Register..." insert-register]
352 ["%_Save Point to Register" point-to-register]
353 ["%_Jump to Register" register-to-point]
356 ["%_Kill Rectangle" kill-rectangle]
357 ["%_Yank Rectangle" yank-rectangle]
358 ["Rectangle %_to Register" copy-rectangle-to-register]
359 ["Rectangle %_from Register" insert-register]
360 ["%_Clear Rectangle" clear-rectangle]
361 ["%_Open Rectangle" open-rectangle]
362 ["%_Prefix Rectangle..." string-rectangle]
363 ["Rectangle %_Mousing"
364 (customize-set-variable 'mouse-track-rectangle-p
365 (not mouse-track-rectangle-p))
366 :style toggle :selected mouse-track-rectangle-p]
369 ["%_Lines in Region" sort-lines :active (region-exists-p)]
370 ["%_Paragraphs in Region" sort-paragraphs :active (region-exists-p)]
371 ["P%_ages in Region" sort-pages :active (region-exists-p)]
372 ["%_Columns in Region" sort-columns :active (region-exists-p)]
373 ["%_Regexp..." sort-regexp-fields :active (region-exists-p)]
376 ["%_Upcase Region" upcase-region :active (region-exists-p)]
377 ["%_Downcase Region" downcase-region :active (region-exists-p)]
378 ["%_Capitalize Region" capitalize-region :active (region-exists-p)]
379 ["%_Title-Case Region" capitalize-region-as-title
380 :active (region-exists-p)]
383 ["%_Line" center-line]
384 ["%_Paragraph" center-paragraph]
385 ["%_Region" center-region :active (region-exists-p)]
388 ["%_As Previous Line" indent-relative]
389 ["%_To Column..." indent-to-column]
391 ["%_Region" indent-region :active (region-exists-p)]
392 ["%_Balanced Expression" indent-sexp]
393 ["%_C Expression" indent-c-exp]
396 ["%_Buffer" ispell-buffer
397 :active (fboundp 'ispell-buffer)]
399 ["%_Word" ispell-word]
400 ["%_Complete Word" ispell-complete-word]
401 ["%_Region" ispell-region]
407 ("%_Add Download Site"
408 :filter (lambda (&rest junk)
409 (submenu-generate-accelerator-spec
410 (package-get-download-menu))))
411 ["%_Update Package Index" package-get-update-base]
412 ["%_List and Install" pui-list-packages]
413 ["U%_pdate Installed Packages" package-get-update-all]
414 ;; hack-o-matic, we can't force a load of package-base here
415 ;; since it triggers dialog box interactions which we can't
416 ;; deal with while using a menu
418 :filter (lambda (&rest junk)
420 (submenu-generate-accelerator-spec
421 (cdr (custom-menu-create 'packages)))
422 '("Please load Package Index"))))
424 ["%_Help" (Info-goto-node "(xemacs)Packages")])
426 ["Read Mail %_1 (VM)..." vm
427 :active (fboundp 'vm)]
428 ["Read Mail %_2 (MH)..." (mh-rmail t)
429 :active (fboundp 'mh-rmail)]
430 ["Send %_Mail..." compose-mail
431 :active (fboundp 'compose-mail)]
432 ["Usenet %_News" gnus
433 :active (fboundp 'gnus)]
434 ["Browse the %_Web" w3
435 :active (fboundp 'w3)])
440 (if (or (not (boundp 'grep-history)) (null grep-history))
443 (submenu-generate-accelerator-spec
444 (mapcar #'(lambda (label-value)
445 (vector (first label-value)
446 (list 'grep (second label-value))))
447 (Menubar-items-truncate-history
448 grep-history 10 50)))))
449 (append menu '("---") items))))
450 ["%_Grep..." grep :active (fboundp 'grep)]
451 ["%_Kill Grep" kill-compilation
452 :active (and (fboundp 'kill-compilation)
453 (fboundp 'compilation-find-buffer)
454 (let ((buffer (condition-case nil
455 (compilation-find-buffer)
457 (and buffer (get-buffer-process buffer))))]
459 ["Grep %_All Files in Current Directory..."
463 (cons (concat grep-command " *")
464 (length grep-command))))
465 (call-interactively 'grep)))
466 :active (fboundp 'grep)]
467 ["Grep %_C and C Header Files in Current Directory..."
471 (cons (concat grep-command " *.[chCH]"
472 ; i wanted to also use *.cc and *.hh.
473 ; see long comment below under Perl.
475 (length grep-command))))
476 (call-interactively 'grep)))
477 :active (fboundp 'grep)]
478 ["Grep C Hea%_der Files in Current Directory..."
482 (cons (concat grep-command " *.[hH]"
483 ; i wanted to also use *.hh.
484 ; see long comment below under Perl.
486 (length grep-command))))
487 (call-interactively 'grep)))
488 :active (fboundp 'grep)]
489 ["Grep %_E-Lisp Files in Current Directory..."
493 (cons (concat grep-command " *.el")
494 (length grep-command))))
495 (call-interactively 'grep)))
496 :active (fboundp 'grep)]
497 ["Grep %_Perl Files in Current Directory..."
501 (cons (concat grep-command " *.pl"
502 ; i wanted to use this:
504 ; but grep complains if it can't
505 ; match anything in a glob, and
506 ; that screws other things up.
507 ; perhaps we need to first scan
508 ; each separate glob in the directory
509 ; to see if there are any files in
510 ; that glob, and if not, omit it.
512 (length grep-command))))
513 (call-interactively 'grep)))
514 :active (fboundp 'grep)]
515 ["Grep %_HTML Files in Current Directory..."
519 (cons (concat grep-command " *.*htm*")
520 (length grep-command))))
521 (call-interactively 'grep)))
522 :active (fboundp 'grep)]
524 ["%_Next Match" next-error
525 :active (and (fboundp 'compilation-errors-exist-p)
526 (compilation-errors-exist-p))]
527 ["Pre%_vious Match" previous-error
528 :active (and (fboundp 'compilation-errors-exist-p)
529 (compilation-errors-exist-p))]
530 ["%_First Match" first-error
531 :active (and (fboundp 'compilation-errors-exist-p)
532 (compilation-errors-exist-p))]
533 ["G%_oto Match" compile-goto-error
534 :active (and (fboundp 'compilation-errors-exist-p)
535 (compilation-errors-exist-p))]
537 ["%_Set Grep Command..."
540 (customize-set-variable
542 (read-shell-command "Default Grep Command: " grep-command)))
543 :active (fboundp 'grep)
549 (if (or (not (boundp 'compile-history)) (null compile-history))
552 (submenu-generate-accelerator-spec
553 (mapcar #'(lambda (label-value)
554 (vector (first label-value)
555 (list 'compile (second label-value))))
556 (Menubar-items-truncate-history
557 compile-history 10 50)))))
558 (append menu '("---") items))))
559 ["%_Compile..." compile :active (fboundp 'compile)]
560 ["%_Repeat Compilation" recompile :active (fboundp 'recompile)]
561 ["%_Kill Compilation" kill-compilation
562 :active (and (fboundp 'kill-compilation)
563 (fboundp 'compilation-find-buffer)
564 (let ((buffer (condition-case nil
565 (compilation-find-buffer)
567 (and buffer (get-buffer-process buffer))))]
569 ["%_Next Error" next-error
570 :active (and (fboundp 'compilation-errors-exist-p)
571 (compilation-errors-exist-p))]
572 ["Pre%_vious Error" previous-error
573 :active (and (fboundp 'compilation-errors-exist-p)
574 (compilation-errors-exist-p))]
575 ["%_First Error" first-error
576 :active (and (fboundp 'compilation-errors-exist-p)
577 (compilation-errors-exist-p))]
578 ["G%_oto Error" compile-goto-error
579 :active (and (fboundp 'compilation-errors-exist-p)
580 (compilation-errors-exist-p))]
584 :active (fboundp 'gdb)]
586 :active (fboundp 'dbx)])
589 :active (fboundp 'shell)]
590 ["S%_hell Command..." shell-command
591 :active (fboundp 'shell-command)]
592 ["Shell Command on %_Region..." shell-command-on-region
593 :active (and (fboundp 'shell-command-on-region) (region-exists-p))])
596 ["%_Find Tag..." find-tag]
597 ["Find %_Other Window..." find-tag-other-window]
598 ["%_Next Tag..." (find-tag nil)]
599 ["N%_ext Other Window..." (find-tag-other-window nil)]
600 ["Next %_File" next-file]
602 ["Tags %_Search..." tags-search]
603 ["Tags %_Replace..." tags-query-replace]
604 ["%_Continue Search/Replace" tags-loop-continue]
606 ["%_Pop stack" pop-tag-mark]
607 ["%_Apropos..." tags-apropos]
609 ["%_Set Tags Table File..." visit-tags-table]
615 ["%_3-Month Calendar" calendar
616 :active (fboundp 'calendar)]
618 :active (fboundp 'diary)]
619 ["%_Holidays" holidays
620 :active (fboundp 'holidays)]
621 ;; we're all pagans at heart ...
622 ["%_Phases of the Moon" phases-of-moon
623 :active (fboundp 'phases-of-moon)]
624 ["%_Sunrise/Sunset" sunrise-sunset
625 :active (fboundp 'sunrise-sunset)])
629 :active (fboundp 'xmine)]
631 :active (fboundp 'tetris)]
633 :active (fboundp 'sokoban)]
634 ["Quote from %_Zippy" yow
635 :active (fboundp 'yow)]
636 ["%_Psychoanalyst" doctor
637 :active (fboundp 'doctor)]
638 ["Ps%_ychoanalyze Zippy!" psychoanalyze-pinhead
639 :active (fboundp 'psychoanalyze-pinhead)]
640 ["%_Random Flames" flame
641 :active (fboundp 'flame)]
642 ["%_Dunnet (Adventure)" dunnet
643 :active (fboundp 'dunnet)]
644 ["Towers of %_Hanoi" hanoi
645 :active (fboundp 'hanoi)]
646 ["Game of %_Life" life
647 :active (fboundp 'life)]
648 ["M%_ultiplication Puzzle" mpuz
649 :active (fboundp 'mpuz)])
655 ("%_Advanced (Customize)"
656 ("%_Emacs" :filter (lambda (&rest junk)
657 (cdr (custom-menu-create 'emacs))))
658 ["%_Group..." customize-group]
659 ["%_Variable..." customize-variable]
660 ["%_Face..." customize-face]
661 ["%_Saved..." customize-saved]
662 ["Se%_t..." customize-customized]
663 ["%_Apropos..." customize-apropos]
664 ["%_Browse..." customize-browse])
667 ["This Buffer %_Read Only" (toggle-read-only)
668 :style toggle :selected buffer-read-only]
669 ["%_Yank/Kill Interact With Clipboard"
670 (if (eq interprogram-cut-function 'own-clipboard)
672 (customize-set-variable 'interprogram-cut-function nil)
673 (customize-set-variable 'interprogram-paste-function nil))
674 (customize-set-variable 'interprogram-cut-function 'own-clipboard)
675 (customize-set-variable 'interprogram-paste-function 'get-clipboard))
677 :selected (eq interprogram-cut-function 'own-clipboard)]
680 (setq overwrite-mode (if overwrite-mode nil 'overwrite-mode-textual))
681 (customize-set-variable 'overwrite-mode overwrite-mode))
682 :style toggle :selected overwrite-mode]
684 (customize-set-variable 'abbrev-mode
685 (not (default-value 'abbrev-mode)))
687 :selected (default-value 'abbrev-mode)]
689 (customize-set-variable 'zmacs-regions (not zmacs-regions))
690 :style toggle :selected zmacs-regions]
692 ["%_Case Sensitive Search"
693 (customize-set-variable 'case-fold-search
694 (setq case-fold-search (not case-fold-search)))
695 :style toggle :selected (not case-fold-search)]
696 ["Case %_Matching Replace"
697 (customize-set-variable 'case-replace (not case-replace))
698 :style toggle :selected case-replace]
700 ("%_Newline at End of File..."
702 (customize-set-variable 'require-final-newline nil)
703 :style radio :selected (not require-final-newline)]
705 (customize-set-variable 'require-final-newline t)
706 :style radio :selected (eq require-final-newline t)]
708 (customize-set-variable 'require-final-newline 'ask)
709 :style radio :selected (and require-final-newline
710 (not (eq require-final-newline t)))])
711 ["Add Newline When Moving Past %_End"
712 (customize-set-variable 'next-line-add-newlines
713 (not next-line-add-newlines))
714 :style toggle :selected next-line-add-newlines])
715 ("%_Keyboard and Mouse"
716 ["%_Delete Key Deletes Selection"
717 (customize-set-variable 'pending-delete-mode (not pending-delete-mode))
719 :selected (and (boundp 'pending-delete-mode) pending-delete-mode)
720 :active (boundp 'pending-delete-mode)]
721 ["`%_kill-line' Kills Whole Line at %_Beg"
722 (customize-set-variable 'kill-whole-line (not kill-whole-line))
724 :selected kill-whole-line]
725 ["Size for %_Block-Movement Commands..."
726 (customize-set-variable 'block-movement-size
727 (read-number "Block Movement Size: "
728 t block-movement-size))]
732 (customize-set-variable 'viper-mode viper-mode))
733 :style toggle :selected (and (boundp 'viper-mode) viper-mode)
734 :active (fboundp 'toggle-viper-mode)]
736 ["S%_hifted Motion Keys Select Region"
737 (customize-set-variable 'shifted-motion-keys-select-region
738 (not shifted-motion-keys-select-region))
740 :selected shifted-motion-keys-select-region]
741 ["%_After Shifted Motion, Unshifted Motion Keys Deselect"
742 (customize-set-variable 'unshifted-motion-keys-deselect-region
743 (not unshifted-motion-keys-deselect-region))
745 :selected unshifted-motion-keys-deselect-region]
747 ["%_Set Key..." global-set-key]
748 ["%_Unset Key..." global-unset-key]
750 ["%_Mouse Paste at Text Cursor (not Clicked Location)"
751 (customize-set-variable 'mouse-yank-at-point (not mouse-yank-at-point))
752 :style toggle :selected mouse-yank-at-point]
754 ["%_Teach Extended Commands"
755 (customize-set-variable 'teach-extended-commands-p
756 (not teach-extended-commands-p))
757 :style toggle :selected teach-extended-commands-p]
760 ["Set Printer %_Name for Generic Print Support..."
761 (customize-set-variable
763 (read-string "Set printer name: " printer-name))]
765 ["Command-Line %_Switches for `lpr'/`lp'..."
766 ;; better to directly open a customization buffer, since the value
767 ;; must be a list of strings, which is somewhat complex to prompt for.
768 (customize-variable 'lpr-switches)
769 (boundp 'lpr-switches)]
770 ("%_Pretty-Print Paper Size"
772 (customize-set-variable 'ps-paper-type 'letter)
774 :selected (and (boundp 'ps-paper-type) (eq ps-paper-type 'letter))
775 :active (boundp 'ps-paper-type)]
777 (customize-set-variable 'ps-paper-type 'letter-small)
779 :selected (and (boundp 'ps-paper-type)
780 (eq ps-paper-type 'letter-small))
781 :active (boundp 'ps-paper-type)]
783 (customize-set-variable 'ps-paper-type 'legal)
785 :selected (and (boundp 'ps-paper-type) (eq ps-paper-type 'legal))
786 :active (boundp 'ps-paper-type)]
788 (customize-set-variable 'ps-paper-type 'statement)
790 :selected (and (boundp 'ps-paper-type) (eq ps-paper-type 'statement))
791 :active (boundp 'ps-paper-type)]
793 (customize-set-variable 'ps-paper-type 'executive)
795 :selected (and (boundp 'ps-paper-type) (eq ps-paper-type 'executive))
796 :active (boundp 'ps-paper-type)]
798 (customize-set-variable 'ps-paper-type 'tabloid)
800 :selected (and (boundp 'ps-paper-type) (eq ps-paper-type 'tabloid))
801 :active (boundp 'ps-paper-type)]
803 (customize-set-variable 'ps-paper-type 'ledger)
805 :selected (and (boundp 'ps-paper-type) (eq ps-paper-type 'ledger))
806 :active (boundp 'ps-paper-type)]
808 (customize-set-variable 'ps-paper-type 'a3)
810 :selected (and (boundp 'ps-paper-type) (eq ps-paper-type 'a3))
811 :active (boundp 'ps-paper-type)]
813 (customize-set-variable 'ps-paper-type 'a4)
815 :selected (and (boundp 'ps-paper-type) (eq ps-paper-type 'a4))
816 :active (boundp 'ps-paper-type)]
818 (customize-set-variable 'ps-paper-type 'a4small)
820 :selected (and (boundp 'ps-paper-type) (eq ps-paper-type 'a4small))
821 :active (boundp 'ps-paper-type)]
823 (customize-set-variable 'ps-paper-type 'b4)
825 :selected (and (boundp 'ps-paper-type) (eq ps-paper-type 'b4))
826 :active (boundp 'ps-paper-type)]
828 (customize-set-variable 'ps-paper-type 'b5)
830 :selected (and (boundp 'ps-paper-type) (eq ps-paper-type 'b5))
831 :active (boundp 'ps-paper-type)]
834 (cond (ps-print-color-p
835 (customize-set-variable 'ps-print-color-p nil)
836 ;; I'm wondering whether all this muck is useful.
837 (and (boundp 'original-face-background)
838 original-face-background
839 (set-face-background 'default original-face-background)))
841 (customize-set-variable 'ps-print-color-p t)
842 (setq original-face-background
843 (face-background-instance 'default))
844 (set-face-background 'default "white")))
846 :selected (and (boundp 'ps-print-color-p) ps-print-color-p)
847 :active (boundp 'ps-print-color-p)])
849 ("%_Compose Mail With"
850 ["Default Emacs Mailer"
851 (customize-set-variable 'mail-user-agent 'sendmail-user-agent)
853 :selected (eq mail-user-agent 'sendmail-user-agent)]
855 (customize-set-variable 'mail-user-agent 'mh-e-user-agent)
857 :selected (eq mail-user-agent 'mh-e-user-agent)
858 :active (get 'mh-e-user-agent 'composefunc)]
860 (customize-set-variable 'mail-user-agent 'message-user-agent)
862 :selected (eq mail-user-agent 'message-user-agent)
863 :active (get 'message-user-agent 'composefunc)]
865 ["Set My %_Email Address..."
866 (customize-set-variable
868 (read-string "Set email address: " user-mail-address))]
869 ["Set %_Machine Email Name..."
870 (customize-set-variable
872 (read-string "Set machine email name: " mail-host-address))]
873 ["Set %_SMTP Server..."
876 (customize-set-variable
877 'smtpmail-smtp-server
878 (read-string "Set SMTP server: " smtpmail-smtp-server)))
879 :active (and (boundp 'send-mail-function)
880 (eq send-mail-function 'smtpmail-send-it))]
884 (customize-set-variable 'smtpmail-debug-info
885 (not smtpmail-debug-info)))
887 :selected (and (boundp 'smtpmail-debug-info) smtpmail-debug-info)
888 :active (and (boundp 'send-mail-function)
889 (eq send-mail-function 'smtpmail-send-it))]
893 (customize-set-variable 'browse-url-browser-function 'browse-url-w3)
895 :selected (and (boundp 'browse-url-browser-function)
896 (eq browse-url-browser-function 'browse-url-w3))
897 :active (and (boundp 'browse-url-browser-function)
898 (fboundp 'browse-url-w3)
899 (fboundp 'w3-fetch))]
901 (customize-set-variable 'browse-url-browser-function
902 'browse-url-netscape)
904 :selected (and (boundp 'browse-url-browser-function)
905 (eq browse-url-browser-function 'browse-url-netscape))
906 :active (and (boundp 'browse-url-browser-function)
907 (fboundp 'browse-url-netscape))]
909 (customize-set-variable 'browse-url-browser-function
912 :selected (and (boundp 'browse-url-browser-function)
913 (eq browse-url-browser-function 'browse-url-mosaic))
914 :active (and (boundp 'browse-url-browser-function)
915 (fboundp 'browse-url-mosaic))]
917 (customize-set-variable 'browse-url-browser-function 'browse-url-cci)
919 :selected (and (boundp 'browse-url-browser-function)
920 (eq browse-url-browser-function 'browse-url-cci))
921 :active (and (boundp 'browse-url-browser-function)
922 (fboundp 'browse-url-cci))]
924 (customize-set-variable 'browse-url-browser-function
925 'browse-url-iximosaic)
927 :selected (and (boundp 'browse-url-browser-function)
928 (eq browse-url-browser-function 'browse-url-iximosaic))
929 :active (and (boundp 'browse-url-browser-function)
930 (fboundp 'browse-url-iximosaic))]
932 (customize-set-variable 'browse-url-browser-function
933 'browse-url-lynx-xterm)
935 :selected (and (boundp 'browse-url-browser-function)
936 (eq browse-url-browser-function 'browse-url-lynx-xterm))
937 :active (and (boundp 'browse-url-browser-function)
938 (fboundp 'browse-url-lynx-xterm))]
940 (customize-set-variable 'browse-url-browser-function
941 'browse-url-lynx-emacs)
943 :selected (and (boundp 'browse-url-browser-function)
944 (eq browse-url-browser-function 'browse-url-lynx-emacs))
945 :active (and (boundp 'browse-url-browser-function)
946 (fboundp 'browse-url-lynx-emacs))]
948 (customize-set-variable 'browse-url-browser-function
951 :selected (and (boundp 'browse-url-browser-function)
952 (eq browse-url-browser-function 'browse-url-grail))
953 :active (and (boundp 'browse-url-browser-function)
954 (fboundp 'browse-url-grail))]
956 (customize-set-variable 'browse-url-browser-function
959 :selected (and (boundp 'browse-url-browser-function)
960 (eq browse-url-browser-function 'browse-url-kfm))
961 :active (and (boundp 'browse-url-browser-function)
962 (fboundp 'browse-url-kfm))]
966 (customize-set-variable 'debug-on-error (not debug-on-error))
967 :style toggle :selected debug-on-error]
969 (customize-set-variable 'debug-on-quit (not debug-on-quit))
970 :style toggle :selected debug-on-quit]
972 (customize-set-variable 'debug-on-signal (not debug-on-signal))
973 :style toggle :selected debug-on-signal]
974 ["%_Stack Trace on Error"
975 (customize-set-variable 'stack-trace-on-error
976 (not stack-trace-on-error))
977 :style toggle :selected stack-trace-on-error]
978 ["Stack Trace on Si%_gnal"
979 (customize-set-variable 'stack-trace-on-signal
980 (not stack-trace-on-signal))
981 :style toggle :selected stack-trace-on-signal]
985 ,@(if (featurep 'scrollbar)
987 (customize-set-variable 'scrollbars-visible-p
988 (not scrollbars-visible-p))
990 :selected scrollbars-visible-p]))
992 (progn;; becomes buffer-local
993 (setq truncate-lines (not truncate-lines))
994 (customize-set-variable 'truncate-lines truncate-lines))
996 :selected (not truncate-lines)]
999 (customize-set-variable 'modeline-3d-p
1000 (not modeline-3d-p))
1002 :selected modeline-3d-p]
1003 ("Modeline %_Horizontal Scrolling"
1005 (customize-set-variable 'modeline-scrolling-method nil)
1007 :selected (not modeline-scrolling-method)]
1009 (customize-set-variable 'modeline-scrolling-method t)
1011 :selected (eq modeline-scrolling-method t)]
1013 (customize-set-variable 'modeline-scrolling-method 'scrollbar)
1015 :selected (eq modeline-scrolling-method 'scrollbar)]
1017 ,@(if (featurep 'toolbar)
1019 ["%_Toolbars Visible"
1020 (customize-set-variable 'toolbar-visible-p
1021 (not toolbar-visible-p))
1023 :selected toolbar-visible-p]
1024 ["Toolbars Ca%_ptioned"
1025 (customize-set-variable 'toolbar-captioned-p
1026 (not toolbar-captioned-p))
1028 :active toolbar-visible-p
1029 :selected toolbar-captioned-p]
1030 ("Default Toolba%_r Location"
1032 (customize-set-variable 'default-toolbar-position 'top)
1034 :active toolbar-visible-p
1035 :selected (eq default-toolbar-position 'top)]
1037 (customize-set-variable 'default-toolbar-position 'bottom)
1039 :active toolbar-visible-p
1040 :selected (eq default-toolbar-position 'bottom)]
1042 (customize-set-variable 'default-toolbar-position 'left)
1044 :active toolbar-visible-p
1045 :selected (eq default-toolbar-position 'left)]
1047 (customize-set-variable 'default-toolbar-position 'right)
1049 :active toolbar-visible-p
1050 :selected (eq default-toolbar-position 'right)]
1053 ,@(if (featurep 'gutter)
1055 ["B%_uffers Tab Visible"
1056 (customize-set-variable 'gutter-buffers-tab-visible-p
1057 (not gutter-buffers-tab-visible-p))
1059 :selected gutter-buffers-tab-visible-p]
1060 ("Default %_Gutter Location"
1062 (customize-set-variable 'default-gutter-position 'top)
1064 :selected (eq default-gutter-position 'top)]
1066 (customize-set-variable 'default-gutter-position 'bottom)
1068 :selected (eq default-gutter-position 'bottom)]
1070 (customize-set-variable 'default-gutter-position 'left)
1072 :selected (eq default-gutter-position 'left)]
1074 (customize-set-variable 'default-gutter-position 'right)
1076 :selected (eq default-gutter-position 'right)]
1080 ["%_Blinking Cursor"
1081 (customize-set-variable 'blink-cursor-mode (not blink-cursor-mode))
1083 :selected (and (boundp 'blink-cursor-mode) blink-cursor-mode)
1084 :active (boundp 'blink-cursor-mode)]
1087 (customize-set-variable 'bar-cursor nil)
1088 (force-cursor-redisplay))
1090 :selected (null bar-cursor)]
1091 ["Bar Cursor (%_1 Pixel)"
1093 (customize-set-variable 'bar-cursor t)
1094 (force-cursor-redisplay))
1096 :selected (eq bar-cursor t)]
1097 ["Bar Cursor (%_2 Pixels)"
1099 (customize-set-variable 'bar-cursor 2)
1100 (force-cursor-redisplay))
1102 :selected (and bar-cursor (not (eq bar-cursor t)))]
1104 ("Pa%_ren Highlighting"
1106 (customize-set-variable 'paren-mode nil)
1108 :selected (and (boundp 'paren-mode) (not paren-mode))
1109 :active (boundp 'paren-mode)]
1111 (customize-set-variable 'paren-mode 'blink-paren)
1113 :selected (and (boundp 'paren-mode) (eq paren-mode 'blink-paren))
1114 :active (boundp 'paren-mode)]
1116 (customize-set-variable 'paren-mode 'paren)
1118 :selected (and (boundp 'paren-mode) (eq paren-mode 'paren))
1119 :active (boundp 'paren-mode)]
1121 (customize-set-variable 'paren-mode 'sexp)
1123 :selected (and (boundp 'paren-mode) (eq paren-mode 'sexp))
1124 :active (boundp 'paren-mode)]
1125 ;; ["Nes%_ted Shading"
1126 ;; (customize-set-variable 'paren-mode 'nested)
1128 ;; :selected (and (boundp 'paren-mode) (eq paren-mode 'nested))
1129 ;; :active (boundp 'paren-mode)]
1134 (customize-set-variable 'line-number-mode (not line-number-mode))
1136 :style toggle :selected line-number-mode]
1139 (customize-set-variable 'column-number-mode
1140 (not column-number-mode))
1142 :style toggle :selected column-number-mode]
1144 ("\"Other %_Window\" Location"
1145 ["%_Always in Same Frame"
1146 (customize-set-variable
1147 'get-frame-for-buffer-default-instance-limit nil)
1149 :selected (null get-frame-for-buffer-default-instance-limit)]
1150 ["Other Frame (%_2 Frames Max)"
1151 (customize-set-variable 'get-frame-for-buffer-default-instance-limit
1154 :selected (eq 2 get-frame-for-buffer-default-instance-limit)]
1155 ["Other Frame (%_3 Frames Max)"
1156 (customize-set-variable 'get-frame-for-buffer-default-instance-limit
1159 :selected (eq 3 get-frame-for-buffer-default-instance-limit)]
1160 ["Other Frame (%_4 Frames Max)"
1161 (customize-set-variable 'get-frame-for-buffer-default-instance-limit
1164 :selected (eq 4 get-frame-for-buffer-default-instance-limit)]
1165 ["Other Frame (%_5 Frames Max)"
1166 (customize-set-variable 'get-frame-for-buffer-default-instance-limit
1169 :selected (eq 5 get-frame-for-buffer-default-instance-limit)]
1170 ["Always Create %_New Frame"
1171 (customize-set-variable 'get-frame-for-buffer-default-instance-limit
1174 :selected (eq 0 get-frame-for-buffer-default-instance-limit)]
1176 ["%_Temp Buffers Always in Same Frame"
1177 (customize-set-variable 'temp-buffer-show-function
1178 'show-temp-buffer-in-current-frame)
1180 :selected (eq temp-buffer-show-function
1181 'show-temp-buffer-in-current-frame)]
1182 ["Temp Buffers %_Like Other Buffers"
1183 (customize-set-variable 'temp-buffer-show-function nil)
1185 :selected (null temp-buffer-show-function)]
1187 ["%_Make Current Frame Gnuserv Target"
1188 (customize-set-variable 'gnuserv-frame (if (eq gnuserv-frame t) nil
1191 :selected (and (boundp 'gnuserv-frame) (eq gnuserv-frame t))
1192 :active (boundp 'gnuserv-frame)]
1196 ["%_Frame-Local Font Menu"
1197 (customize-set-variable 'font-menu-this-frame-only-p
1198 (not font-menu-this-frame-only-p))
1200 :selected (and (boundp 'font-menu-this-frame-only-p)
1201 font-menu-this-frame-only-p)]
1202 ["%_Alt/Meta Selects Menu Items"
1203 (if (eq menu-accelerator-enabled 'menu-force)
1204 (customize-set-variable 'menu-accelerator-enabled nil)
1205 (customize-set-variable 'menu-accelerator-enabled 'menu-force))
1207 :selected (eq menu-accelerator-enabled 'menu-force)]
1209 ["Buffers Menu %_Length..."
1210 (customize-set-variable
1211 'buffers-menu-max-size
1212 ;; would it be better to open a customization buffer ?
1215 "Enter number of buffers to display (or 0 for unlimited): ")))
1216 (if (eq val 0) nil val)))]
1217 ["%_Multi-Operation Buffers Sub-Menus"
1218 (customize-set-variable 'complex-buffers-menu-p
1219 (not complex-buffers-menu-p))
1221 :selected complex-buffers-menu-p]
1222 ["S%_ubmenus for Buffer Groups"
1223 (customize-set-variable 'buffers-menu-submenus-for-groups-p
1224 (not buffers-menu-submenus-for-groups-p))
1226 :selected buffers-menu-submenus-for-groups-p]
1227 ["%_Verbose Buffer Menu Entries"
1228 (if (eq buffers-menu-format-buffer-line-function
1229 'slow-format-buffers-menu-line)
1230 (customize-set-variable 'buffers-menu-format-buffer-line-function
1231 'format-buffers-menu-line)
1232 (customize-set-variable 'buffers-menu-format-buffer-line-function
1233 'slow-format-buffers-menu-line))
1235 :selected (eq buffers-menu-format-buffer-line-function
1236 'slow-format-buffers-menu-line)]
1237 ("Buffers Menu %_Sorting"
1238 ["%_Most Recently Used"
1240 (customize-set-variable 'buffers-menu-sort-function nil)
1241 (customize-set-variable 'buffers-menu-grouping-function nil))
1243 :selected (null buffers-menu-sort-function)]
1246 (customize-set-variable 'buffers-menu-sort-function
1247 'sort-buffers-menu-alphabetically)
1248 (customize-set-variable 'buffers-menu-grouping-function nil))
1250 :selected (eq 'sort-buffers-menu-alphabetically
1251 buffers-menu-sort-function)]
1252 ["%_By Major Mode, Then Alphabetically"
1254 (customize-set-variable
1255 'buffers-menu-sort-function
1256 'sort-buffers-menu-by-mode-then-alphabetically)
1257 (customize-set-variable
1258 'buffers-menu-grouping-function
1259 'group-buffers-menu-by-mode-then-alphabetically))
1261 :selected (eq 'sort-buffers-menu-by-mode-then-alphabetically
1262 buffers-menu-sort-function)])
1264 ["%_Ignore Scaled Fonts"
1265 (customize-set-variable 'font-menu-ignore-scaled-fonts
1266 (not font-menu-ignore-scaled-fonts))
1268 :selected (and (boundp 'font-menu-ignore-scaled-fonts)
1269 font-menu-ignore-scaled-fonts)]
1271 ("S%_yntax Highlighting"
1273 (progn;; becomes buffer local
1275 (customize-set-variable 'font-lock-mode font-lock-mode))
1277 :selected (and (boundp 'font-lock-mode) font-lock-mode)
1278 :active (boundp 'font-lock-mode)]
1280 (customize-set-variable 'font-lock-auto-fontify
1281 (not font-lock-auto-fontify))
1283 :selected (and (boundp 'font-lock-auto-fontify) font-lock-auto-fontify)
1284 :active (fboundp 'font-lock-mode)]
1286 ["Force %_Rehighlight in this Buffer"
1287 (customize-set-variable 'font-lock-auto-fontify
1288 (not font-lock-auto-fontify))
1290 :selected (and (boundp 'font-lock-auto-fontify) font-lock-auto-fontify)
1291 :active (fboundp 'font-lock-mode)]
1295 (require 'font-lock)
1296 (font-lock-use-default-fonts)
1297 (customize-set-variable 'font-lock-use-fonts t)
1298 (customize-set-variable 'font-lock-use-colors nil)
1301 :selected (and (boundp 'font-lock-use-fonts) font-lock-use-fonts)
1302 :active (fboundp 'font-lock-mode)]
1305 (require 'font-lock)
1306 (font-lock-use-default-colors)
1307 (customize-set-variable 'font-lock-use-colors t)
1308 (customize-set-variable 'font-lock-use-fonts nil)
1311 :selected (and (boundp 'font-lock-use-colors) font-lock-use-colors)
1312 :active (boundp 'font-lock-mode)]
1316 (require 'font-lock)
1317 (if (or (and (not (integerp font-lock-maximum-decoration))
1318 (not (eq t font-lock-maximum-decoration)))
1319 (and (integerp font-lock-maximum-decoration)
1320 (<= font-lock-maximum-decoration 0)))
1322 (customize-set-variable 'font-lock-maximum-decoration nil)
1323 (font-lock-recompute-variables)))
1325 :active (fboundp 'font-lock-mode)
1326 :selected (and (boundp 'font-lock-maximum-decoration)
1327 (or (and (not (integerp font-lock-maximum-decoration))
1328 (not (eq t font-lock-maximum-decoration)))
1329 (and (integerp font-lock-maximum-decoration)
1330 (<= font-lock-maximum-decoration 0))))]
1333 (require 'font-lock)
1334 (if (and (integerp font-lock-maximum-decoration)
1335 (= 1 font-lock-maximum-decoration))
1337 (customize-set-variable 'font-lock-maximum-decoration 1)
1338 (font-lock-recompute-variables)))
1340 :active (fboundp 'font-lock-mode)
1341 :selected (and (boundp 'font-lock-maximum-decoration)
1342 (integerp font-lock-maximum-decoration)
1343 (= 1 font-lock-maximum-decoration))]
1346 (require 'font-lock)
1347 (if (and (integerp font-lock-maximum-decoration)
1348 (= 2 font-lock-maximum-decoration))
1350 (customize-set-variable 'font-lock-maximum-decoration 2)
1351 (font-lock-recompute-variables)))
1353 :active (fboundp 'font-lock-mode)
1354 :selected (and (boundp 'font-lock-maximum-decoration)
1355 (integerp font-lock-maximum-decoration)
1356 (= 2 font-lock-maximum-decoration))]
1359 (require 'font-lock)
1360 (if (or (eq font-lock-maximum-decoration t)
1361 (and (integerp font-lock-maximum-decoration)
1362 (>= font-lock-maximum-decoration 3)))
1364 (customize-set-variable 'font-lock-maximum-decoration t)
1365 (font-lock-recompute-variables)))
1367 :active (fboundp 'font-lock-mode)
1368 :selected (and (boundp 'font-lock-maximum-decoration)
1369 (or (eq font-lock-maximum-decoration t)
1370 (and (integerp font-lock-maximum-decoration)
1371 (>= font-lock-maximum-decoration 3))))]
1374 (progn;; becomes buffer local
1376 (customize-set-variable 'lazy-lock-mode lazy-lock-mode)
1377 ;; this shouldn't be necessary so there has to
1378 ;; be a redisplay bug lurking somewhere (or
1379 ;; possibly another event handler bug)
1381 :active (and (boundp 'font-lock-mode) (boundp 'lazy-lock-mode)
1384 :selected (and (boundp 'lazy-lock-mode) lazy-lock-mode)]
1386 (progn;; becomes buffer local
1388 (customize-set-variable 'lazy-shot-mode lazy-shot-mode)
1389 ;; this shouldn't be necessary so there has to
1390 ;; be a redisplay bug lurking somewhere (or
1391 ;; possibly another event handler bug)
1393 :active (and (boundp 'font-lock-mode) (boundp 'lazy-shot-mode)
1396 :selected (and (boundp 'lazy-shot-mode) lazy-shot-mode)]
1398 (progn;; becomes buffer local
1400 (customize-set-variable 'fast-lock-mode fast-lock-mode)
1401 ;; this shouldn't be necessary so there has to
1402 ;; be a redisplay bug lurking somewhere (or
1403 ;; possibly another event handler bug)
1405 :active (and (boundp 'font-lock-mode) (boundp 'fast-lock-mode)
1408 :selected (and (boundp 'fast-lock-mode) fast-lock-mode)]
1410 ("%_Font" :filter font-menu-family-constructor)
1411 ("Font Si%_ze" :filter font-menu-size-constructor)
1412 ;; ("Font Weig%_ht" :filter font-menu-weight-constructor)
1413 ["Edit Fa%_ces..." (customize-face nil)]
1416 ;; #### there should be something that holds the name that the init
1417 ;; file should be created as, when it's not present.
1418 (progn (find-file (or user-init-file "~/.xemacs/init.el"))
1419 (or (eq major-mode 'emacs-lisp-mode)
1420 (emacs-lisp-mode)))]
1421 ["%_Save Options to Init File" customize-save-customized]
1425 :filter buffers-menu-filter
1426 ["Go To %_Previous Buffer" switch-to-other-buffer]
1427 ["Go To %_Buffer..." switch-to-buffer]
1429 ["%_List All Buffers" list-buffers]
1430 ["%_Delete Buffer" kill-this-buffer
1431 :suffix (if put-buffer-names-in-file-menu (buffer-name) "")]
1435 nil ; the partition: menus after this are flushright
1438 ["%_About XEmacs..." about-xemacs]
1440 ["What's %_New in XEmacs" view-emacs-news]
1441 ["%_Obtaining XEmacs" describe-distribution]
1443 ("%_Info (Online Docs)"
1444 ["%_Info Contents" info]
1445 ["Lookup %_Key Binding..." Info-goto-emacs-key-command-node]
1446 ["Lookup %_Command..." Info-goto-emacs-command-node]
1447 ["Lookup %_Function..." Info-elisp-ref]
1448 ["Lookup %_Topic..." Info-query])
1450 ["%_FAQ (local)" xemacs-local-faq]
1451 ["FAQ via %_WWW" xemacs-www-faq
1452 :active (fboundp 'browse-url)]
1453 ["%_Home Page" xemacs-www-page
1454 :active (fboundp 'browse-url)])
1456 :filter tutorials-menu-filter)
1459 (find-file (locate-data-file "sample.init.el"))
1460 :active (locate-data-file "sample.init.el")]
1462 (find-file (locate-data-file "sample.gtkrc"))
1463 :included (featurep 'gtk)
1464 :active (locate-data-file "sample.gtkrc")]
1465 ["Sample .%_Xdefaults"
1466 (find-file (locate-data-file "sample.Xdefaults"))
1467 :included (featurep 'x)
1468 :active (locate-data-file "sample.Xdefaults")]
1469 ["Sample %_enriched"
1470 (find-file (locate-data-file "enriched.doc"))
1471 :active (locate-data-file "enriched.doc")])
1472 ("%_Commands & Keys"
1473 ["%_Mode" describe-mode]
1474 ["%_Apropos..." hyper-apropos]
1475 ["Apropos %_Docs..." apropos-documentation]
1477 ["%_Key..." describe-key]
1478 ["%_Bindings" describe-bindings]
1479 ["%_Mouse Bindings" describe-pointer]
1480 ["%_Recent Keys" view-lossage]
1482 ["%_Function..." describe-function]
1483 ["%_Variable..." describe-variable]
1484 ["%_Locate Command..." where-is])
1486 ["%_Recent Messages" view-lossage]
1488 ["%_Current Installation Info" describe-installation
1489 :active (boundp 'Installation-string)]
1490 ["%_No Warranty" describe-no-warranty]
1491 ["XEmacs %_License" describe-copying]
1492 ["Find %_Packages" finder-by-keyword]
1493 ["View %_Splash Screen" xemacs-splash-buffer]
1494 ["%_Unix Manual..." manual-entry])
1495 ["Send %_Bug Report..." report-xemacs-bug
1496 :active (fboundp 'report-xemacs-bug)])))
1499 (defun maybe-add-init-button ()
1501 Adds `Load .emacs' button to menubar when starting up with -q."
1502 (when (and (not load-user-init-file-p)
1503 (file-exists-p (expand-file-name ".emacs" "~")))
1508 (mapc #'(lambda (buf)
1509 (with-current-buffer buf
1510 (delete-menu-item '("Load .emacs"))))
1512 (load-user-init-file))
1516 (add-hook 'before-init-hook 'maybe-add-init-button)
1521 (defvar put-buffer-names-in-file-menu t)
1524 ;;; The Bookmarks menu
1526 (defun bookmark-menu-filter (&rest ignore)
1527 (declare (special bookmark-alist))
1528 (let ((definedp (and (boundp 'bookmark-alist)
1532 '("%_Jump to Bookmark"
1533 :filter (lambda (&rest junk)
1534 (submenu-generate-accelerator-spec
1535 (mapcar #'(lambda (bmk)
1536 `[,bmk (bookmark-jump ',bmk)])
1537 (bookmark-all-names)))))
1538 ["%_Jump to Bookmark" nil nil])
1539 ["Set %_Bookmark" bookmark-set
1540 :active (fboundp 'bookmark-set)]
1542 ["Insert %_Contents" bookmark-menu-insert
1543 :active (fboundp 'bookmark-menu-insert)]
1544 ["Insert L%_ocation" bookmark-menu-locate
1545 :active (fboundp 'bookmark-menu-locate)]
1547 ["%_Rename Bookmark" bookmark-menu-rename
1548 :active (fboundp 'bookmark-menu-rename)]
1550 '("%_Delete Bookmark"
1551 :filter (lambda (&rest junk)
1552 (submenu-generate-accelerator-spec
1553 (mapcar #'(lambda (bmk)
1554 `[,bmk (bookmark-delete ',bmk)])
1555 (bookmark-all-names)))))
1556 ["%_Delete Bookmark" nil nil])
1557 ["%_Edit Bookmark List" bookmark-bmenu-list ,definedp]
1559 ["%_Save Bookmarks" bookmark-save ,definedp]
1560 ["Save Bookmarks %_As..." bookmark-write ,definedp]
1561 ["%_Load a Bookmark File" bookmark-load
1562 :active (fboundp 'bookmark-load)])))
1564 ;;; The Buffers menu
1566 (defgroup buffers-menu nil
1567 "Customization of `Buffers' menu."
1570 (defvar buffers-menu-omit-chars-list '(?b ?p ?l ?d))
1572 (defcustom buffers-menu-max-size 25
1573 "*Maximum number of entries which may appear on the \"Buffers\" menu.
1574 If this is 10, then only the ten most-recently-selected buffers will be
1575 shown. If this is nil, then all buffers will be shown. Setting this to
1576 a large number or nil will slow down menu responsiveness."
1577 :type '(choice (const :tag "Show all" nil)
1579 :group 'buffers-menu)
1581 (defcustom complex-buffers-menu-p nil
1582 "*If non-nil, the buffers menu will contain several commands.
1583 Commands will be presented as submenus of each buffer line. If this
1584 is false, then there will be only one command: select that buffer."
1586 :group 'buffers-menu)
1588 (defcustom buffers-menu-submenus-for-groups-p nil
1589 "*If non-nil, the buffers menu will contain one submenu per group of buffers.
1590 The grouping function is specified in `buffers-menu-grouping-function'.
1591 If this is an integer, do not build submenus if the number of buffers
1592 is not larger than this value."
1593 :type '(choice (const :tag "No Subgroups" nil)
1594 (integer :tag "Max. submenus" 10)
1595 (sexp :format "%t\n" :tag "Allow Subgroups" :value t))
1596 :group 'buffers-menu)
1598 (defcustom buffers-menu-switch-to-buffer-function 'switch-to-buffer
1599 "*The function to call to select a buffer from the buffers menu.
1600 `switch-to-buffer' is a good choice, as is `pop-to-buffer'."
1601 :type '(radio (function-item switch-to-buffer)
1602 (function-item pop-to-buffer)
1603 (function :tag "Other"))
1604 :group 'buffers-menu)
1606 (defcustom buffers-menu-omit-function 'buffers-menu-omit-invisible-buffers
1607 "*If non-nil, a function specifying the buffers to omit from the buffers menu.
1608 This is passed a buffer and should return non-nil if the buffer should be
1609 omitted. The default value `buffers-menu-omit-invisible-buffers' omits
1610 buffers that are normally considered \"invisible\" (those whose name
1611 begins with a space)."
1612 :type '(choice (const :tag "None" nil)
1614 :group 'buffers-menu)
1616 (defcustom buffers-menu-format-buffer-line-function 'format-buffers-menu-line
1617 "*The function to call to return a string to represent a buffer in
1618 the buffers menu. The function is passed a buffer and a number
1619 (starting with 1) indicating which buffer line in the menu is being
1620 processed and should return a string containing an accelerator
1621 spec. (Check out `menu-item-generate-accelerator-spec' as a convenient
1622 way of generating the accelerator specs.) The default value
1623 `format-buffers-menu-line' just returns the name of the buffer and
1624 uses the number as the accelerator. Also check out
1625 `slow-format-buffers-menu-line' which returns a whole bunch of info
1628 Note: Gross Compatibility Hack: Older versions of this function prototype
1629 only expected one argument, not two. We deal gracefully with such
1630 functions by simply calling them with one argument and leaving out the
1631 line number. However, this may go away at any time, so make sure to
1632 update all of your functions of this type."
1634 :group 'buffers-menu)
1636 (defcustom buffers-menu-sort-function
1637 'sort-buffers-menu-by-mode-then-alphabetically
1638 "*If non-nil, a function to sort the list of buffers in the buffers menu.
1639 It will be passed two arguments (two buffers to compare) and should return
1640 t if the first is \"less\" than the second. One possible value is
1641 `sort-buffers-menu-alphabetically'; another is
1642 `sort-buffers-menu-by-mode-then-alphabetically'."
1643 :type '(choice (const :tag "None" nil)
1645 :group 'buffers-menu)
1647 (defcustom buffers-menu-grouping-function
1648 'group-buffers-menu-by-mode-then-alphabetically
1649 "*If non-nil, a function to group buffers in the buffers menu together.
1650 It will be passed two arguments, successive members of the sorted buffers
1651 list after being passed through `buffers-menu-sort-function'. It should
1652 return non-nil if the second buffer begins a new group. The return value
1653 should be the name of the old group, which may be used in hierarchical
1654 buffers menus. The last invocation of the function contains nil as the
1655 second argument, so that the name of the last group can be determined.
1657 The sensible values of this function are dependent on the value specified
1658 for `buffers-menu-sort-function'."
1659 :type '(choice (const :tag "None" nil)
1661 :group 'buffers-menu)
1663 (defun sort-buffers-menu-alphabetically (buf1 buf2)
1664 "For use as a value of `buffers-menu-sort-function'.
1665 Sorts the buffers in alphabetical order by name, but puts buffers beginning
1666 with a star at the end of the list."
1667 (let* ((nam1 (buffer-name buf1))
1668 (nam2 (buffer-name buf2))
1669 (inv1p (not (null (string-match "\\` " nam1))))
1670 (inv2p (not (null (string-match "\\` " nam2))))
1671 (star1p (not (null (string-match "\\`*" nam1))))
1672 (star2p (not (null (string-match "\\`*" nam2)))))
1673 (cond ((not (eq inv1p inv2p))
1675 ((not (eq star1p star2p))
1678 (string-lessp nam1 nam2)))))
1680 (defun sort-buffers-menu-by-mode-then-alphabetically (buf1 buf2)
1681 "For use as a value of `buffers-menu-sort-function'.
1682 Sorts first by major mode and then alphabetically by name, but puts buffers
1683 beginning with a star at the end of the list."
1684 (let* ((nam1 (buffer-name buf1))
1685 (nam2 (buffer-name buf2))
1686 (inv1p (not (null (string-match "\\` " nam1))))
1687 (inv2p (not (null (string-match "\\` " nam2))))
1688 (star1p (not (null (string-match "\\`*" nam1))))
1689 (star2p (not (null (string-match "\\`*" nam2))))
1690 (mode1 (symbol-value-in-buffer 'major-mode buf1))
1691 (mode2 (symbol-value-in-buffer 'major-mode buf2)))
1692 (cond ((not (eq inv1p inv2p))
1694 ((not (eq star1p star2p))
1696 ((and star1p star2p (string-lessp nam1 nam2)))
1697 ((string-lessp mode1 mode2)
1699 ((string-lessp mode2 mode1)
1702 (string-lessp nam1 nam2)))))
1704 ;; this version is too slow on some machines.
1705 ;; (vintage 1990, that is)
1706 (defun slow-format-buffers-menu-line (buffer n)
1707 "For use as a value of `buffers-menu-format-buffer-line-function'.
1708 This returns a string containing a bunch of info about the buffer."
1709 (concat (menu-item-generate-accelerator-spec n buffers-menu-omit-chars-list)
1710 (format "%s%s %-19s %6s %-15s %s"
1711 (if (buffer-modified-p buffer) "*" " ")
1712 (if (symbol-value-in-buffer 'buffer-read-only buffer)
1714 (buffer-name buffer)
1715 (buffer-size buffer)
1716 (symbol-value-in-buffer 'mode-name buffer)
1717 (or (buffer-file-name buffer) ""))))
1719 (defun format-buffers-menu-line (buffer n)
1720 "For use as a value of `buffers-menu-format-buffer-line-function'.
1721 This just returns the buffer's name."
1722 (concat (menu-item-generate-accelerator-spec n buffers-menu-omit-chars-list)
1723 (buffer-name buffer)))
1725 (defun group-buffers-menu-by-mode-then-alphabetically (buf1 buf2)
1726 "For use as a value of `buffers-menu-grouping-function'.
1727 This groups buffers by major mode. It only really makes sense if
1728 `buffers-menu-sorting-function' is
1729 `sort-buffers-menu-by-mode-then-alphabetically'."
1730 (cond ((string-match "\\`*" (buffer-name buf1))
1731 (and (null buf2) "*Misc*"))
1733 (string-match "\\`*" (buffer-name buf2))
1734 (not (eq (symbol-value-in-buffer 'major-mode buf1)
1735 (symbol-value-in-buffer 'major-mode buf2))))
1736 (symbol-value-in-buffer 'mode-name buf1))
1739 (defun buffer-menu-save-buffer (buffer)
1744 (defun buffer-menu-write-file (buffer)
1747 (write-file (read-file-name
1748 (format "Write %s to file: "
1749 (buffer-name (current-buffer)))))))
1751 (defsubst build-buffers-menu-internal (buffers)
1752 (let (name line (n 0))
1759 ; #### a truly Kyle-friendly hack.
1760 (let ((fn buffers-menu-format-buffer-line-function))
1761 (if (= (function-max-args fn) 1)
1763 (funcall fn buffer n))))
1764 (if complex-buffers-menu-p
1767 (vector "S%_witch to Buffer"
1768 (list buffers-menu-switch-to-buffer-function
1769 (setq name (buffer-name buffer)))
1771 (if (eq buffers-menu-switch-to-buffer-function
1773 (vector "Switch to Buffer, Other %_Frame"
1774 (list 'switch-to-buffer-other-frame
1775 (setq name (buffer-name buffer)))
1778 (if (and (buffer-modified-p buffer)
1779 (buffer-file-name buffer))
1780 (vector "%_Save Buffer"
1781 (list 'buffer-menu-save-buffer name) t)
1782 ["%_Save Buffer" nil nil]
1784 (vector "Save %_As..."
1785 (list 'buffer-menu-write-file name) t)
1786 (vector "%_Delete Buffer" (list 'kill-buffer name)
1788 ;; #### We don't want buffer names to be translated,
1789 ;; #### so we put the buffer name in the suffix.
1790 ;; #### Also, avoid losing with non-ASCII buffer names.
1791 ;; #### We still lose, however, if complex-buffers-menu-p. --mrb
1793 (list buffers-menu-switch-to-buffer-function
1794 (buffer-name buffer))
1798 (defun buffers-menu-filter (menu)
1799 "This is the menu filter for the top-level buffers \"Buffers\" menu.
1800 It dynamically creates a list of buffers to use as the contents of the menu.
1801 Only the most-recently-used few buffers will be listed on the menu, for
1802 efficiency reasons. You can control how many buffers will be shown by
1803 setting `buffers-menu-max-size'. You can control the text of the menu
1804 items by redefining the function `format-buffers-menu-line'."
1805 (let ((buffers (delete-if buffers-menu-omit-function (buffer-list))))
1806 (and (integerp buffers-menu-max-size)
1807 (> buffers-menu-max-size 1)
1808 (> (length buffers) buffers-menu-max-size)
1809 ;; shorten list of buffers (not with submenus!)
1810 (not (and buffers-menu-grouping-function
1811 buffers-menu-submenus-for-groups-p))
1812 (setcdr (nthcdr buffers-menu-max-size buffers) nil))
1813 (if buffers-menu-sort-function
1814 (setq buffers (sort buffers buffers-menu-sort-function)))
1815 (if (and buffers-menu-grouping-function
1816 buffers-menu-submenus-for-groups-p
1817 (or (not (integerp buffers-menu-submenus-for-groups-p))
1818 (> (length buffers) buffers-menu-submenus-for-groups-p)))
1819 (let (groups groupnames current-group)
1822 (let ((groupname (funcall buffers-menu-grouping-function
1823 (car sublist) (cadr sublist))))
1824 (setq current-group (cons (car sublist) current-group))
1827 (setq groups (cons (nreverse current-group)
1829 (setq groupnames (cons groupname groupnames))
1830 (setq current-group nil)))))
1834 #'(lambda (groupname group)
1835 (cons groupname (build-buffers-menu-internal group)))
1836 (nreverse groupnames)
1837 (nreverse groups))))
1838 (if buffers-menu-grouping-function
1843 (cond ((funcall buffers-menu-grouping-function
1844 (car sublist) (cadr sublist))
1845 (list (car sublist) t))
1846 (t (list (car sublist)))))
1848 ;; remove a trailing separator.
1849 (and (>= (length buffers) 2)
1850 (let ((lastcdr (nthcdr (- (length buffers) 2) buffers)))
1851 (if (eq t (cadr lastcdr))
1852 (setcdr lastcdr nil))))))
1853 (setq buffers (build-buffers-menu-internal buffers)))
1854 (append menu buffers)
1857 (defun language-environment-menu-filter (menu)
1858 "This is the menu filter for the \"Language Environment\" submenu."
1859 (declare (special language-environment-list))
1861 (mapcar (lambda (env-sym)
1863 `[ ,(concat (menu-item-generate-accelerator-spec n)
1864 (capitalize (symbol-name env-sym)))
1865 (set-language-environment ',env-sym)])
1866 language-environment-list)))
1869 ;;; The Options menu
1871 ;; We'll keep those variables here for a while, in order to provide a
1872 ;; function for porting the old options file that a user may own to Custom.
1874 (defvar options-save-faces nil
1875 "*Non-nil value means save-options will save information about faces.
1876 A nil value means save-options will not save face information.
1877 Set this non-nil only if you use M-x edit-faces to change face
1878 settings. If you use M-x customize-face or the \"Browse Faces...\"
1879 menu entry, you will see a button in the Customize Face buffer that you
1880 can use to permanently save your face changes.
1882 M-x edit-faces is deprecated. Support for it and this variable will
1883 be discontinued in a future release.")
1885 (defvar save-options-init-file nil
1886 "File into which to save forms to load the options file (nil for .emacs).
1887 Normally this is nil, which means save into your .emacs file (the value
1888 of `user-init-file'.")
1890 (defvar save-options-file ".xemacs-options"
1891 "File to save options into.
1892 This file is loaded from your .emacs file.
1893 If this is a relative filename, it is put into the same directory as your
1900 (defun tutorials-menu-filter (menu-items)
1901 (declare (special language-info-alist
1902 current-language-environment
1903 tutorial-supported-languages))
1905 (if (featurep 'mule)
1907 (assoc current-language-environment language-info-alist))
1908 `([,(concat "%_Default (" current-language-environment ")")
1909 help-with-tutorial]))
1910 '(["%_English" help-with-tutorial]))
1911 (submenu-generate-accelerator-spec
1912 (if (featurep 'mule)
1914 (mapcan #'(lambda (lang)
1915 (let ((tut (assq 'tutorial lang)))
1917 (not (string= (car lang) "ASCII"))
1918 ;; skip current language, since we already
1919 ;; included it first
1920 (not (string= (car lang)
1921 current-language-environment))
1923 (help-with-tutorial nil ,(cdr tut))]))))
1924 language-info-alist)
1925 ;; Non mule tutorials.
1926 (mapcar #'(lambda (lang)
1928 (help-with-tutorial ,(format "TUTORIAL.%s"
1930 tutorial-supported-languages)))))
1932 (set-menubar default-menubar)
1937 (defconst default-popup-menu
1939 ["%_Undo" advertised-undo
1940 :active (and (not (eq buffer-undo-list t))
1941 (or buffer-undo-list pending-undo-list))
1942 :suffix (if (or (eq last-command 'undo)
1943 (eq last-command 'advertised-undo))
1945 ["Cu%_t" kill-primary-selection
1946 :active (selection-owner-p)]
1947 ["%_Copy" copy-primary-selection
1948 :active (selection-owner-p)]
1949 ["%_Paste" yank-clipboard-selection
1950 :active (selection-exists-p 'CLIPBOARD)]
1951 ["%_Delete" delete-primary-selection
1952 :active (selection-owner-p)]
1954 ["Select %_Block" mark-paragraph]
1955 ["Sp%_lit Window" split-window-vertically]
1956 ["U%_nsplit Window" delete-other-windows]
1959 ;; In an effort to avoid massive menu clutter, this mostly worthless menu is
1960 ;; superseded by any local popup menu...
1961 (setq-default mode-popup-menu default-popup-menu)
1966 (defun xemacs-splash-buffer ()
1967 "Redisplay XEmacs splash screen in a buffer."
1969 (let ((buffer (get-buffer-create "*Splash*"))
1972 (setq buffer-read-only t)
1973 (erase-buffer buffer)
1974 (setq tmout (display-splash-frame))
1976 (make-local-hook 'kill-buffer-hook)
1977 (add-hook 'kill-buffer-hook
1979 (disable-timeout ,tmout))
1981 (pop-to-buffer buffer)
1982 (delete-other-windows)))
1985 ;;; backwards compatibility
1986 (provide 'x-menubar)
1987 (provide 'menubar-items)
1989 ;;; menubar-items.el ends here.