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 ["%_Print" generic-print-buffer
145 :active (or (valid-specifier-tag-p 'msprinter)
146 (and (not (eq system-type 'windows-nt))
147 (fboundp 'lpr-buffer)))
148 :suffix (if put-buffer-names-in-file-menu (concat (buffer-name) "...")
150 ["Prett%_y-Print" ps-print-buffer-with-faces
151 :active (fboundp 'ps-print-buffer-with-faces)
152 :suffix (if put-buffer-names-in-file-menu (buffer-name) "")]
154 ["%_Revert Buffer" revert-buffer
155 :active (or buffer-file-name revert-buffer-function)
156 :suffix (if put-buffer-names-in-file-menu (buffer-name) "")]
157 ["Re%_cover File..." recover-file]
158 ["Recover S%_ession..." recover-session]
160 ["E%_xit XEmacs" save-buffers-kill-emacs]
164 ["%_Undo" advertised-undo
165 :active (and (not (eq buffer-undo-list t))
166 (or buffer-undo-list pending-undo-list))
167 :suffix (if (or (eq last-command 'undo)
168 (eq last-command 'advertised-undo))
171 :included (fboundp 'redo)
172 :active (not (or (eq buffer-undo-list t)
173 (eq last-buffer-undo-list nil)
174 (not (or (eq last-buffer-undo-list buffer-undo-list)
175 (and (null (car-safe buffer-undo-list))
176 (eq last-buffer-undo-list
177 (cdr-safe buffer-undo-list)))))
178 (or (eq buffer-undo-list pending-undo-list)
179 (eq (cdr buffer-undo-list) pending-undo-list))))
180 :suffix (if (eq last-command 'redo) "More" "")]
182 ["Cu%_t" kill-primary-selection
183 :active (selection-owner-p)]
184 ["%_Copy" copy-primary-selection
185 :active (selection-owner-p)]
186 ["%_Paste" yank-clipboard-selection
187 :active (selection-exists-p 'CLIPBOARD)]
188 ["%_Delete" delete-primary-selection
189 :active (selection-owner-p)]
191 ["Select %_All" mark-whole-buffer]
192 ["Select Pa%_ge" mark-page]
194 ["%_Find..." make-search-dialog]
195 ["R%_eplace..." query-replace]
196 ["Replace (Rege%_xp)..." query-replace-regexp]
197 ["%_List Matching Lines..." list-matching-lines]
198 ,@(when (featurep 'mule)
200 ("%_Multilingual (\"Mule\")"
201 ("%_Describe Language Support")
202 ("%_Set Language Environment")
204 ["T%_oggle Input Method" toggle-input-method]
205 ["Select %_Input Method" set-input-method]
206 ["D%_escribe Input Method" describe-input-method]
208 ["Describe Current %_Coding Systems"
209 describe-current-coding-system]
210 ["Set Coding System of %_Buffer File..."
211 set-buffer-file-coding-system]
212 ;; not implemented yet
213 ["Set Coding System of %_Terminal..."
214 set-terminal-coding-system :active nil]
215 ;; not implemented yet
216 ["Set Coding System of %_Keyboard..."
217 set-keyboard-coding-system :active nil]
218 ["Set Coding System of %_Process..."
219 set-buffer-process-coding-system
220 :active (get-buffer-process (current-buffer))]
222 ["Show Cha%_racter Table" view-charset-by-menu]
223 ;; not implemented yet
224 ["Show Dia%_gnosis for MULE" mule-diag :active nil]
225 ["Show \"%_hello\" in Many Languages" view-hello-file]))
230 ["%_New Frame" make-frame]
231 ["Frame on Other Displa%_y..." make-frame-on-display
232 :active (fboundp 'make-frame-on-display)]
233 ["%_Delete Frame" delete-frame
234 :active (not (eq (next-frame (selected-frame) 'nomini 'window-system)
237 ["%_Split Window" split-window-vertically]
238 ["S%_plit Window (Side by Side)" split-window-horizontally]
239 ["%_Un-Split (Keep This)" delete-other-windows
240 :active (not (one-window-p t))]
241 ["Un-Split (Keep %_Others)" delete-window
242 :active (not (one-window-p t))]
245 ["%_Narrow to Region" narrow-to-region :active (region-exists-p)]
246 ["Narrow to %_Page" narrow-to-page]
247 ["Narrow to %_Defun" narrow-to-defun]
249 ["%_Widen" widen :active (or (/= (point-min) 1)
250 (/= (point-max) (1+ (buffer-size))))]
253 ["Show Message %_Log" show-message-log]
255 ["%_Goto Line..." goto-line]
256 ["%_What Line" what-line]
258 :filter bookmark-menu-filter)
260 ["%_Jump to Previous Mark" (set-mark-command t)
265 ["Repeat %_Last Complex Command..." repeat-complex-command]
266 ["E%_valuate Lisp Expression..." eval-expression]
267 ["Execute %_Named Command..." execute-extended-command]
269 ["Start %_Macro Recording" start-kbd-macro
270 :included (not defining-kbd-macro)]
271 ["End %_Macro Recording" end-kbd-macro
272 :included defining-kbd-macro]
273 ["E%_xecute Last Macro" call-last-kbd-macro
274 :active last-kbd-macro]
276 ["%_Append to Last Macro" (start-kbd-macro t)
277 :active (and (not defining-kbd-macro) last-kbd-macro)]
278 ["%_Query User During Macro" kbd-macro-query
279 :active defining-kbd-macro]
280 ["Enter %_Recursive Edit During Macro" (kbd-macro-query t)
281 :active defining-kbd-macro]
283 ["E%_xecute Last Macro on Region Lines"
284 :active (and last-kbd-macro (region-exists-p))]
286 ["%_Name Last Macro..." name-last-kbd-macro
287 :active last-kbd-macro]
288 ["Assign Last Macro to %_Key..." assign-last-kbd-macro-to-key
289 :active (and last-kbd-macro
290 (fboundp 'assign-last-kbd-macro-to-key))]
292 ["%_Edit Macro..." edit-kbd-macro]
293 ["Edit %_Last Macro" edit-last-kbd-macro
294 :active last-kbd-macro]
296 ["%_Insert Named Macro into Buffer..." insert-kbd-macro]
297 ["Read Macro from Re%_gion" read-kbd-macro
298 :active (region-exists-p)]
302 ["D%_ynamic Abbrev Expand" dabbrev-expand]
303 ["Dynamic Abbrev %_Complete" dabbrev-completion]
304 ["Dynamic Abbrev Complete in %_All Buffers" (dabbrev-completion 16)]
307 ["%_Define Global Abbrev for " add-global-abbrev
308 :suffix (abbrev-string-to-be-defined nil)
310 ["Define %_Mode-Specific Abbrev for " add-mode-abbrev
311 :suffix (abbrev-string-to-be-defined nil)
313 ["Define Global Ex%_pansion for " inverse-add-global-abbrev
314 :suffix (inverse-abbrev-string-to-be-defined 1)
316 ["Define Mode-Specific Expa%_nsion for " inverse-add-mode-abbrev
317 :suffix (inverse-abbrev-string-to-be-defined 1)
320 ["E%_xpand Abbrev" expand-abbrev]
321 ["Expand Abbrevs in Re%_gion" expand-region-abbrevs
322 :active (region-exists-p)]
323 ["%_Unexpand Last Abbrev" unexpand-abbrev
324 :active (and (stringp last-abbrev-text)
325 (> last-abbrev-location 0))]
327 ["%_Kill All Abbrevs" kill-all-abbrevs]
328 ["%_Insert All Abbrevs into Buffer" insert-abbrevs]
329 ["%_List Abbrevs" list-abbrevs]
331 ["%_Edit Abbrevs" edit-abbrevs]
332 ["%_Redefine Abbrevs from Buffer" edit-abbrevs-redefine
333 :active (eq major-mode 'edit-abbrevs-mode)]
335 ["%_Save Abbrevs As..." write-abbrev-file]
336 ["L%_oad Abbrevs..." read-abbrev-file]
339 ["%_Copy to Register..." copy-to-register :active (region-exists-p)]
340 ["%_Paste Register..." insert-register]
342 ["%_Save Point to Register" point-to-register]
343 ["%_Jump to Register" register-to-point]
346 ["%_Kill Rectangle" kill-rectangle]
347 ["%_Yank Rectangle" yank-rectangle]
348 ["Rectangle %_to Register" copy-rectangle-to-register]
349 ["Rectangle %_from Register" insert-register]
350 ["%_Clear Rectangle" clear-rectangle]
351 ["%_Open Rectangle" open-rectangle]
352 ["%_Prefix Rectangle..." string-rectangle]
353 ["Rectangle %_Mousing"
354 (customize-set-variable 'mouse-track-rectangle-p
355 (not mouse-track-rectangle-p))
356 :style toggle :selected mouse-track-rectangle-p]
359 ["%_Lines in Region" sort-lines :active (region-exists-p)]
360 ["%_Paragraphs in Region" sort-paragraphs :active (region-exists-p)]
361 ["P%_ages in Region" sort-pages :active (region-exists-p)]
362 ["%_Columns in Region" sort-columns :active (region-exists-p)]
363 ["%_Regexp..." sort-regexp-fields :active (region-exists-p)]
366 ["%_Upcase Region" upcase-region :active (region-exists-p)]
367 ["%_Downcase Region" downcase-region :active (region-exists-p)]
368 ["%_Capitalize Region" capitalize-region :active (region-exists-p)]
369 ["%_Title-Case Region" capitalize-region-as-title
370 :active (region-exists-p)]
373 ["%_Line" center-line]
374 ["%_Paragraph" center-paragraph]
375 ["%_Region" center-region :active (region-exists-p)]
378 ["%_As Previous Line" indent-relative]
379 ["%_To Column..." indent-to-column]
381 ["%_Region" indent-region :active (region-exists-p)]
382 ["%_Balanced Expression" indent-sexp]
383 ["%_C Expression" indent-c-exp]
386 ["%_Buffer" ispell-buffer
387 :active (fboundp 'ispell-buffer)]
389 ["%_Word" ispell-word]
390 ["%_Complete Word" ispell-complete-word]
391 ["%_Region" ispell-region]
397 ("%_Add Download Site"
398 :filter (lambda (&rest junk)
399 (submenu-generate-accelerator-spec
400 (package-get-download-menu))))
401 ["%_Update Package Index" package-get-update-base]
402 ["%_List and Install" pui-list-packages]
403 ["U%_pdate Installed Packages" package-get-update-all]
404 ;; hack-o-matic, we can't force a load of package-base here
405 ;; since it triggers dialog box interactions which we can't
406 ;; deal with while using a menu
408 :filter (lambda (&rest junk)
410 (submenu-generate-accelerator-spec
411 (cdr (custom-menu-create 'packages)))
412 '("Please load Package Index"))))
414 ["%_Help" (Info-goto-node "(xemacs)Packages")])
416 ["Read Mail %_1 (VM)..." vm
417 :active (fboundp 'vm)]
418 ["Read Mail %_2 (MH)..." (mh-rmail t)
419 :active (fboundp 'mh-rmail)]
420 ["Send %_Mail..." compose-mail
421 :active (fboundp 'compose-mail)]
422 ["Usenet %_News" gnus
423 :active (fboundp 'gnus)]
424 ["Browse the %_Web" w3
425 :active (fboundp 'w3)])
430 (if (or (not (boundp 'grep-history)) (null grep-history))
433 (submenu-generate-accelerator-spec
434 (mapcar #'(lambda (string)
436 (list 'grep string)))
437 (Menubar-items-truncate-list grep-history 10)))))
438 (append menu '("---") items))))
439 ["%_Grep..." grep :active (fboundp 'grep)]
440 ["%_Kill Grep" kill-compilation
441 :active (and (fboundp 'kill-compilation)
442 (fboundp 'compilation-find-buffer)
443 (let ((buffer (condition-case nil
444 (compilation-find-buffer)
446 (and buffer (get-buffer-process buffer))))]
448 ["Grep %_All Files in Current Directory..."
452 (cons (concat grep-command " *")
453 (length grep-command))))
454 (call-interactively 'grep)))
455 :active (fboundp 'grep)]
456 ["Grep %_C and C Header Files in Current Directory..."
460 (cons (concat grep-command " *.[chCH]"
461 ; i wanted to also use *.cc and *.hh.
462 ; see long comment below under Perl.
464 (length grep-command))))
465 (call-interactively 'grep)))
466 :active (fboundp 'grep)]
467 ["Grep C Hea%_der Files in Current Directory..."
471 (cons (concat grep-command " *.[hH]"
472 ; i wanted to also use *.hh.
473 ; see long comment below under Perl.
475 (length grep-command))))
476 (call-interactively 'grep)))
477 :active (fboundp 'grep)]
478 ["Grep %_E-Lisp Files in Current Directory..."
482 (cons (concat grep-command " *.el")
483 (length grep-command))))
484 (call-interactively 'grep)))
485 :active (fboundp 'grep)]
486 ["Grep %_Perl Files in Current Directory..."
490 (cons (concat grep-command " *.pl"
491 ; i wanted to use this:
493 ; but grep complains if it can't
494 ; match anything in a glob, and
495 ; that screws other things up.
496 ; perhaps we need to first scan
497 ; each separate glob in the directory
498 ; to see if there are any files in
499 ; that glob, and if not, omit it.
501 (length grep-command))))
502 (call-interactively 'grep)))
503 :active (fboundp 'grep)]
504 ["Grep %_HTML Files in Current Directory..."
508 (cons (concat grep-command " *.*htm*")
509 (length grep-command))))
510 (call-interactively 'grep)))
511 :active (fboundp 'grep)]
513 ["%_Next Match" next-error
514 :active (and (fboundp 'compilation-errors-exist-p)
515 (compilation-errors-exist-p))]
516 ["Pre%_vious Match" previous-error
517 :active (and (fboundp 'compilation-errors-exist-p)
518 (compilation-errors-exist-p))]
519 ["%_First Match" first-error
520 :active (and (fboundp 'compilation-errors-exist-p)
521 (compilation-errors-exist-p))]
522 ["G%_oto Match" compile-goto-error
523 :active (and (fboundp 'compilation-errors-exist-p)
524 (compilation-errors-exist-p))]
526 ["%_Set Grep Command..."
529 (customize-set-variable
531 (read-shell-command "Default Grep Command: " grep-command)))
532 :active (fboundp 'grep)
538 (if (or (not (boundp 'compile-history)) (null compile-history))
541 (submenu-generate-accelerator-spec
542 (mapcar #'(lambda (string)
544 (list 'compile string)))
545 (Menubar-items-truncate-list compile-history 10)))))
546 (append menu '("---") items))))
547 ["%_Compile..." compile :active (fboundp 'compile)]
548 ["%_Repeat Compilation" recompile :active (fboundp 'recompile)]
549 ["%_Kill Compilation" kill-compilation
550 :active (and (fboundp 'kill-compilation)
551 (fboundp 'compilation-find-buffer)
552 (let ((buffer (condition-case nil
553 (compilation-find-buffer)
555 (and buffer (get-buffer-process buffer))))]
557 ["%_Next Error" next-error
558 :active (and (fboundp 'compilation-errors-exist-p)
559 (compilation-errors-exist-p))]
560 ["Pre%_vious Error" previous-error
561 :active (and (fboundp 'compilation-errors-exist-p)
562 (compilation-errors-exist-p))]
563 ["%_First Error" first-error
564 :active (and (fboundp 'compilation-errors-exist-p)
565 (compilation-errors-exist-p))]
566 ["G%_oto Error" compile-goto-error
567 :active (and (fboundp 'compilation-errors-exist-p)
568 (compilation-errors-exist-p))]
572 :active (fboundp 'gdb)]
574 :active (fboundp 'dbx)])
577 :active (fboundp 'shell)]
578 ["S%_hell Command..." shell-command
579 :active (fboundp 'shell-command)]
580 ["Shell Command on %_Region..." shell-command-on-region
581 :active (and (fboundp 'shell-command-on-region) (region-exists-p))])
584 ["%_Find Tag..." find-tag]
585 ["Find %_Other Window..." find-tag-other-window]
586 ["%_Next Tag..." (find-tag nil)]
587 ["N%_ext Other Window..." (find-tag-other-window nil)]
588 ["Next %_File" next-file]
590 ["Tags %_Search..." tags-search]
591 ["Tags %_Replace..." tags-query-replace]
592 ["%_Continue Search/Replace" tags-loop-continue]
594 ["%_Pop stack" pop-tag-mark]
595 ["%_Apropos..." tags-apropos]
597 ["%_Set Tags Table File..." visit-tags-table]
603 ["%_3-Month Calendar" calendar
604 :active (fboundp 'calendar)]
606 :active (fboundp 'diary)]
607 ["%_Holidays" holidays
608 :active (fboundp 'holidays)]
609 ;; we're all pagans at heart ...
610 ["%_Phases of the Moon" phases-of-moon
611 :active (fboundp 'phases-of-moon)]
612 ["%_Sunrise/Sunset" sunrise-sunset
613 :active (fboundp 'sunrise-sunset)])
617 :active (fboundp 'xmine)]
619 :active (fboundp 'tetris)]
621 :active (fboundp 'sokoban)]
622 ["Quote from %_Zippy" yow
623 :active (fboundp 'yow)]
624 ["%_Psychoanalyst" doctor
625 :active (fboundp 'doctor)]
626 ["Ps%_ychoanalyze Zippy!" psychoanalyze-pinhead
627 :active (fboundp 'psychoanalyze-pinhead)]
628 ["%_Random Flames" flame
629 :active (fboundp 'flame)]
630 ["%_Dunnet (Adventure)" dunnet
631 :active (fboundp 'dunnet)]
632 ["Towers of %_Hanoi" hanoi
633 :active (fboundp 'hanoi)]
634 ["Game of %_Life" life
635 :active (fboundp 'life)]
636 ["M%_ultiplication Puzzle" mpuz
637 :active (fboundp 'mpuz)])
643 ("%_Advanced (Customize)"
644 ("%_Emacs" :filter (lambda (&rest junk)
645 (cdr (custom-menu-create 'emacs))))
646 ["%_Group..." customize-group]
647 ["%_Variable..." customize-variable]
648 ["%_Face..." customize-face]
649 ["%_Saved..." customize-saved]
650 ["Se%_t..." customize-customized]
651 ["%_Apropos..." customize-apropos]
652 ["%_Browse..." customize-browse])
655 ["This Buffer %_Read Only" (toggle-read-only)
656 :style toggle :selected buffer-read-only]
657 ["%_Yank/Kill Interact With Clipboard"
658 (if (eq interprogram-cut-function 'own-clipboard)
660 (customize-set-variable 'interprogram-cut-function nil)
661 (customize-set-variable 'interprogram-paste-function nil))
662 (customize-set-variable 'interprogram-cut-function 'own-clipboard)
663 (customize-set-variable 'interprogram-paste-function 'get-clipboard))
665 :selected (eq interprogram-cut-function 'own-clipboard)]
668 (setq overwrite-mode (if overwrite-mode nil 'overwrite-mode-textual))
669 (customize-set-variable 'overwrite-mode overwrite-mode))
670 :style toggle :selected overwrite-mode]
672 (customize-set-variable 'abbrev-mode
673 (not (default-value 'abbrev-mode)))
675 :selected (default-value 'abbrev-mode)]
677 (customize-set-variable 'zmacs-regions (not zmacs-regions))
678 :style toggle :selected zmacs-regions]
680 ["%_Case Sensitive Search"
681 (customize-set-variable 'case-fold-search
682 (setq case-fold-search (not case-fold-search)))
683 :style toggle :selected (not case-fold-search)]
684 ["Case %_Matching Replace"
685 (customize-set-variable 'case-replace (not case-replace))
686 :style toggle :selected case-replace]
688 ("%_Newline at End of File..."
690 (customize-set-variable 'require-final-newline nil)
691 :style radio :selected (not require-final-newline)]
693 (customize-set-variable 'require-final-newline t)
694 :style radio :selected (eq require-final-newline t)]
696 (customize-set-variable 'require-final-newline 'ask)
697 :style radio :selected (and require-final-newline
698 (not (eq require-final-newline t)))])
699 ["Add Newline When Moving Past %_End"
700 (customize-set-variable 'next-line-add-newlines
701 (not next-line-add-newlines))
702 :style toggle :selected next-line-add-newlines])
703 ("%_Keyboard and Mouse"
704 ["%_Delete Key Deletes Selection"
705 (customize-set-variable 'pending-delete-mode (not pending-delete-mode))
707 :selected (and (boundp 'pending-delete-mode) pending-delete-mode)
708 :active (boundp 'pending-delete-mode)]
709 ["`%_kill-line' Kills Whole Line at %_Beg"
710 (customize-set-variable 'kill-whole-line (not kill-whole-line))
712 :selected kill-whole-line]
713 ["Size for %_Block-Movement Commands..."
714 (customize-set-variable 'block-movement-size
715 (read-number "Block Movement Size: "
716 t block-movement-size))]
720 (customize-set-variable 'viper-mode viper-mode))
721 :style toggle :selected (and (boundp 'viper-mode) viper-mode)
722 :active (fboundp 'toggle-viper-mode)]
724 ["S%_hifted Motion Keys Select Region"
725 (customize-set-variable 'shifted-motion-keys-select-region
726 (not shifted-motion-keys-select-region))
728 :selected shifted-motion-keys-select-region]
729 ["%_After Shifted Motion, Unshifted Motion Keys Deselect"
730 (customize-set-variable 'unshifted-motion-keys-deselect-region
731 (not unshifted-motion-keys-deselect-region))
733 :selected unshifted-motion-keys-deselect-region]
735 ["%_Set Key..." global-set-key]
736 ["%_Unset Key..." global-unset-key]
738 ["%_Mouse Paste at Text Cursor (not Clicked Location)"
739 (customize-set-variable 'mouse-yank-at-point (not mouse-yank-at-point))
740 :style toggle :selected mouse-yank-at-point]
742 ["%_Teach Extended Commands"
743 (customize-set-variable 'teach-extended-commands-p
744 (not teach-extended-commands-p))
745 :style toggle :selected teach-extended-commands-p]
748 ["Set Printer %_Name for Generic Print Support..."
749 (customize-set-variable
751 (read-string "Set printer name: " printer-name))]
753 ["Command-Line %_Switches for `lpr'/`lp'..."
754 ;; better to directly open a customization buffer, since the value
755 ;; must be a list of strings, which is somewhat complex to prompt for.
756 (customize-variable 'lpr-switches)
757 (boundp 'lpr-switches)]
758 ("%_Pretty-Print Paper Size"
760 (customize-set-variable 'ps-paper-type 'letter)
762 :selected (and (boundp 'ps-paper-type) (eq ps-paper-type 'letter))
763 :active (boundp 'ps-paper-type)]
765 (customize-set-variable 'ps-paper-type 'letter-small)
767 :selected (and (boundp 'ps-paper-type)
768 (eq ps-paper-type 'letter-small))
769 :active (boundp 'ps-paper-type)]
771 (customize-set-variable 'ps-paper-type 'legal)
773 :selected (and (boundp 'ps-paper-type) (eq ps-paper-type 'legal))
774 :active (boundp 'ps-paper-type)]
776 (customize-set-variable 'ps-paper-type 'statement)
778 :selected (and (boundp 'ps-paper-type) (eq ps-paper-type 'statement))
779 :active (boundp 'ps-paper-type)]
781 (customize-set-variable 'ps-paper-type 'executive)
783 :selected (and (boundp 'ps-paper-type) (eq ps-paper-type 'executive))
784 :active (boundp 'ps-paper-type)]
786 (customize-set-variable 'ps-paper-type 'tabloid)
788 :selected (and (boundp 'ps-paper-type) (eq ps-paper-type 'tabloid))
789 :active (boundp 'ps-paper-type)]
791 (customize-set-variable 'ps-paper-type 'ledger)
793 :selected (and (boundp 'ps-paper-type) (eq ps-paper-type 'ledger))
794 :active (boundp 'ps-paper-type)]
796 (customize-set-variable 'ps-paper-type 'a3)
798 :selected (and (boundp 'ps-paper-type) (eq ps-paper-type 'a3))
799 :active (boundp 'ps-paper-type)]
801 (customize-set-variable 'ps-paper-type 'a4)
803 :selected (and (boundp 'ps-paper-type) (eq ps-paper-type 'a4))
804 :active (boundp 'ps-paper-type)]
806 (customize-set-variable 'ps-paper-type 'a4small)
808 :selected (and (boundp 'ps-paper-type) (eq ps-paper-type 'a4small))
809 :active (boundp 'ps-paper-type)]
811 (customize-set-variable 'ps-paper-type 'b4)
813 :selected (and (boundp 'ps-paper-type) (eq ps-paper-type 'b4))
814 :active (boundp 'ps-paper-type)]
816 (customize-set-variable 'ps-paper-type 'b5)
818 :selected (and (boundp 'ps-paper-type) (eq ps-paper-type 'b5))
819 :active (boundp 'ps-paper-type)]
822 (cond (ps-print-color-p
823 (customize-set-variable 'ps-print-color-p nil)
824 ;; I'm wondering whether all this muck is useful.
825 (and (boundp 'original-face-background)
826 original-face-background
827 (set-face-background 'default original-face-background)))
829 (customize-set-variable 'ps-print-color-p t)
830 (setq original-face-background
831 (face-background-instance 'default))
832 (set-face-background 'default "white")))
834 :selected (and (boundp 'ps-print-color-p) ps-print-color-p)
835 :active (boundp 'ps-print-color-p)])
837 ("%_Compose Mail With"
838 ["Default Emacs Mailer"
839 (customize-set-variable 'mail-user-agent 'sendmail-user-agent)
841 :selected (eq mail-user-agent 'sendmail-user-agent)]
843 (customize-set-variable 'mail-user-agent 'mh-e-user-agent)
845 :selected (eq mail-user-agent 'mh-e-user-agent)
846 :active (get 'mh-e-user-agent 'composefunc)]
848 (customize-set-variable 'mail-user-agent 'message-user-agent)
850 :selected (eq mail-user-agent 'message-user-agent)
851 :active (get 'message-user-agent 'composefunc)]
853 ["Set My %_Email Address..."
854 (customize-set-variable
856 (read-string "Set email address: " user-mail-address))]
857 ["Set %_Machine Email Name..."
858 (customize-set-variable
860 (read-string "Set machine email name: " mail-host-address))]
861 ["Set %_SMTP Server..."
864 (customize-set-variable
865 'smtpmail-smtp-server
866 (read-string "Set SMTP server: " smtpmail-smtp-server)))
867 :active (and (boundp 'send-mail-function)
868 (eq send-mail-function 'smtpmail-send-it))]
872 (customize-set-variable 'smtpmail-debug-info
873 (not smtpmail-debug-info)))
875 :selected (and (boundp 'smtpmail-debug-info) smtpmail-debug-info)
876 :active (and (boundp 'send-mail-function)
877 (eq send-mail-function 'smtpmail-send-it))]
881 (customize-set-variable 'browse-url-browser-function 'browse-url-w3)
883 :selected (and (boundp 'browse-url-browser-function)
884 (eq browse-url-browser-function 'browse-url-w3))
885 :active (and (boundp 'browse-url-browser-function)
886 (fboundp 'browse-url-w3)
887 (fboundp 'w3-fetch))]
889 (customize-set-variable 'browse-url-browser-function
890 'browse-url-netscape)
892 :selected (and (boundp 'browse-url-browser-function)
893 (eq browse-url-browser-function 'browse-url-netscape))
894 :active (and (boundp 'browse-url-browser-function)
895 (fboundp 'browse-url-netscape))]
897 (customize-set-variable 'browse-url-browser-function
900 :selected (and (boundp 'browse-url-browser-function)
901 (eq browse-url-browser-function 'browse-url-mosaic))
902 :active (and (boundp 'browse-url-browser-function)
903 (fboundp 'browse-url-mosaic))]
905 (customize-set-variable 'browse-url-browser-function 'browse-url-cci)
907 :selected (and (boundp 'browse-url-browser-function)
908 (eq browse-url-browser-function 'browse-url-cci))
909 :active (and (boundp 'browse-url-browser-function)
910 (fboundp 'browse-url-cci))]
912 (customize-set-variable 'browse-url-browser-function
913 'browse-url-iximosaic)
915 :selected (and (boundp 'browse-url-browser-function)
916 (eq browse-url-browser-function 'browse-url-iximosaic))
917 :active (and (boundp 'browse-url-browser-function)
918 (fboundp 'browse-url-iximosaic))]
920 (customize-set-variable 'browse-url-browser-function
921 'browse-url-lynx-xterm)
923 :selected (and (boundp 'browse-url-browser-function)
924 (eq browse-url-browser-function 'browse-url-lynx-xterm))
925 :active (and (boundp 'browse-url-browser-function)
926 (fboundp 'browse-url-lynx-xterm))]
928 (customize-set-variable 'browse-url-browser-function
929 'browse-url-lynx-emacs)
931 :selected (and (boundp 'browse-url-browser-function)
932 (eq browse-url-browser-function 'browse-url-lynx-emacs))
933 :active (and (boundp 'browse-url-browser-function)
934 (fboundp 'browse-url-lynx-emacs))]
936 (customize-set-variable 'browse-url-browser-function
939 :selected (and (boundp 'browse-url-browser-function)
940 (eq browse-url-browser-function 'browse-url-grail))
941 :active (and (boundp 'browse-url-browser-function)
942 (fboundp 'browse-url-grail))]
944 (customize-set-variable 'browse-url-browser-function
947 :selected (and (boundp 'browse-url-browser-function)
948 (eq browse-url-browser-function 'browse-url-kfm))
949 :active (and (boundp 'browse-url-browser-function)
950 (fboundp 'browse-url-kfm))]
954 (customize-set-variable 'debug-on-error (not debug-on-error))
955 :style toggle :selected debug-on-error]
957 (customize-set-variable 'debug-on-quit (not debug-on-quit))
958 :style toggle :selected debug-on-quit]
960 (customize-set-variable 'debug-on-signal (not debug-on-signal))
961 :style toggle :selected debug-on-signal]
962 ["%_Stack Trace on Error"
963 (customize-set-variable 'stack-trace-on-error
964 (not stack-trace-on-error))
965 :style toggle :selected stack-trace-on-error]
966 ["Stack Trace on Si%_gnal"
967 (customize-set-variable 'stack-trace-on-signal
968 (not stack-trace-on-signal))
969 :style toggle :selected stack-trace-on-signal]
973 ,@(if (featurep 'scrollbar)
975 (customize-set-variable 'scrollbars-visible-p
976 (not scrollbars-visible-p))
978 :selected scrollbars-visible-p]))
980 (progn;; becomes buffer-local
981 (setq truncate-lines (not truncate-lines))
982 (customize-set-variable 'truncate-lines truncate-lines))
984 :selected (not truncate-lines)]
987 (customize-set-variable 'modeline-3d-p
990 :selected modeline-3d-p]
991 ("Modeline %_Horizontal Scrolling"
993 (customize-set-variable 'modeline-scrolling-method nil)
995 :selected (not modeline-scrolling-method)]
997 (customize-set-variable 'modeline-scrolling-method t)
999 :selected (eq modeline-scrolling-method t)]
1001 (customize-set-variable 'modeline-scrolling-method 'scrollbar)
1003 :selected (eq modeline-scrolling-method 'scrollbar)]
1005 ,@(if (featurep 'toolbar)
1007 ["%_Toolbars Visible"
1008 (customize-set-variable 'toolbar-visible-p
1009 (not toolbar-visible-p))
1011 :selected toolbar-visible-p]
1012 ["Toolbars Ca%_ptioned"
1013 (customize-set-variable 'toolbar-captioned-p
1014 (not toolbar-captioned-p))
1016 :active toolbar-visible-p
1017 :selected toolbar-captioned-p]
1018 ("Default Toolba%_r Location"
1020 (customize-set-variable 'default-toolbar-position 'top)
1022 :active toolbar-visible-p
1023 :selected (eq default-toolbar-position 'top)]
1025 (customize-set-variable 'default-toolbar-position 'bottom)
1027 :active toolbar-visible-p
1028 :selected (eq default-toolbar-position 'bottom)]
1030 (customize-set-variable 'default-toolbar-position 'left)
1032 :active toolbar-visible-p
1033 :selected (eq default-toolbar-position 'left)]
1035 (customize-set-variable 'default-toolbar-position 'right)
1037 :active toolbar-visible-p
1038 :selected (eq default-toolbar-position 'right)]
1041 ,@(if (featurep 'gutter)
1043 ["B%_uffers Tab Visible"
1044 (customize-set-variable 'gutter-buffers-tab-visible-p
1045 (not gutter-buffers-tab-visible-p))
1047 :selected gutter-buffers-tab-visible-p]
1048 ("Default %_Gutter Location"
1050 (customize-set-variable 'default-gutter-position 'top)
1052 :selected (eq default-gutter-position 'top)]
1054 (customize-set-variable 'default-gutter-position 'bottom)
1056 :selected (eq default-gutter-position 'bottom)]
1058 (customize-set-variable 'default-gutter-position 'left)
1060 :selected (eq default-gutter-position 'left)]
1062 (customize-set-variable 'default-gutter-position 'right)
1064 :selected (eq default-gutter-position 'right)]
1068 ["%_Blinking Cursor"
1069 (customize-set-variable 'blink-cursor-mode (not blink-cursor-mode))
1071 :selected (and (boundp 'blink-cursor-mode) blink-cursor-mode)
1072 :active (boundp 'blink-cursor-mode)]
1075 (customize-set-variable 'bar-cursor nil)
1076 (force-cursor-redisplay))
1078 :selected (null bar-cursor)]
1079 ["Bar Cursor (%_1 Pixel)"
1081 (customize-set-variable 'bar-cursor t)
1082 (force-cursor-redisplay))
1084 :selected (eq bar-cursor t)]
1085 ["Bar Cursor (%_2 Pixels)"
1087 (customize-set-variable 'bar-cursor 2)
1088 (force-cursor-redisplay))
1090 :selected (and bar-cursor (not (eq bar-cursor t)))]
1092 ("Pa%_ren Highlighting"
1094 (customize-set-variable 'paren-mode nil)
1096 :selected (and (boundp 'paren-mode) (not paren-mode))
1097 :active (boundp 'paren-mode)]
1099 (customize-set-variable 'paren-mode 'blink-paren)
1101 :selected (and (boundp 'paren-mode) (eq paren-mode 'blink-paren))
1102 :active (boundp 'paren-mode)]
1104 (customize-set-variable 'paren-mode 'paren)
1106 :selected (and (boundp 'paren-mode) (eq paren-mode 'paren))
1107 :active (boundp 'paren-mode)]
1109 (customize-set-variable 'paren-mode 'sexp)
1111 :selected (and (boundp 'paren-mode) (eq paren-mode 'sexp))
1112 :active (boundp 'paren-mode)]
1113 ;; ["Nes%_ted Shading"
1114 ;; (customize-set-variable 'paren-mode 'nested)
1116 ;; :selected (and (boundp 'paren-mode) (eq paren-mode 'nested))
1117 ;; :active (boundp 'paren-mode)]
1122 (customize-set-variable 'line-number-mode (not line-number-mode))
1124 :style toggle :selected line-number-mode]
1127 (customize-set-variable 'column-number-mode
1128 (not column-number-mode))
1130 :style toggle :selected column-number-mode]
1132 ("\"Other %_Window\" Location"
1133 ["%_Always in Same Frame"
1134 (customize-set-variable
1135 'get-frame-for-buffer-default-instance-limit nil)
1137 :selected (null get-frame-for-buffer-default-instance-limit)]
1138 ["Other Frame (%_2 Frames Max)"
1139 (customize-set-variable 'get-frame-for-buffer-default-instance-limit
1142 :selected (eq 2 get-frame-for-buffer-default-instance-limit)]
1143 ["Other Frame (%_3 Frames Max)"
1144 (customize-set-variable 'get-frame-for-buffer-default-instance-limit
1147 :selected (eq 3 get-frame-for-buffer-default-instance-limit)]
1148 ["Other Frame (%_4 Frames Max)"
1149 (customize-set-variable 'get-frame-for-buffer-default-instance-limit
1152 :selected (eq 4 get-frame-for-buffer-default-instance-limit)]
1153 ["Other Frame (%_5 Frames Max)"
1154 (customize-set-variable 'get-frame-for-buffer-default-instance-limit
1157 :selected (eq 5 get-frame-for-buffer-default-instance-limit)]
1158 ["Always Create %_New Frame"
1159 (customize-set-variable 'get-frame-for-buffer-default-instance-limit
1162 :selected (eq 0 get-frame-for-buffer-default-instance-limit)]
1164 ["%_Temp Buffers Always in Same Frame"
1165 (customize-set-variable 'temp-buffer-show-function
1166 'show-temp-buffer-in-current-frame)
1168 :selected (eq temp-buffer-show-function
1169 'show-temp-buffer-in-current-frame)]
1170 ["Temp Buffers %_Like Other Buffers"
1171 (customize-set-variable 'temp-buffer-show-function nil)
1173 :selected (null temp-buffer-show-function)]
1175 ["%_Make Current Frame Gnuserv Target"
1176 (customize-set-variable 'gnuserv-frame (if (eq gnuserv-frame t) nil
1179 :selected (and (boundp 'gnuserv-frame) (eq gnuserv-frame t))
1180 :active (boundp 'gnuserv-frame)]
1184 ["%_Frame-Local Font Menu"
1185 (customize-set-variable 'font-menu-this-frame-only-p
1186 (not font-menu-this-frame-only-p))
1188 :selected (and (boundp 'font-menu-this-frame-only-p)
1189 font-menu-this-frame-only-p)]
1190 ["%_Alt/Meta Selects Menu Items"
1191 (if (eq menu-accelerator-enabled 'menu-force)
1192 (customize-set-variable 'menu-accelerator-enabled nil)
1193 (customize-set-variable 'menu-accelerator-enabled 'menu-force))
1195 :selected (eq menu-accelerator-enabled 'menu-force)]
1197 ["Buffers Menu %_Length..."
1198 (customize-set-variable
1199 'buffers-menu-max-size
1200 ;; would it be better to open a customization buffer ?
1203 "Enter number of buffers to display (or 0 for unlimited): ")))
1204 (if (eq val 0) nil val)))]
1205 ["%_Multi-Operation Buffers Sub-Menus"
1206 (customize-set-variable 'complex-buffers-menu-p
1207 (not complex-buffers-menu-p))
1209 :selected complex-buffers-menu-p]
1210 ["S%_ubmenus for Buffer Groups"
1211 (customize-set-variable 'buffers-menu-submenus-for-groups-p
1212 (not buffers-menu-submenus-for-groups-p))
1214 :selected buffers-menu-submenus-for-groups-p]
1215 ["%_Verbose Buffer Menu Entries"
1216 (if (eq buffers-menu-format-buffer-line-function
1217 'slow-format-buffers-menu-line)
1218 (customize-set-variable 'buffers-menu-format-buffer-line-function
1219 'format-buffers-menu-line)
1220 (customize-set-variable 'buffers-menu-format-buffer-line-function
1221 'slow-format-buffers-menu-line))
1223 :selected (eq buffers-menu-format-buffer-line-function
1224 'slow-format-buffers-menu-line)]
1225 ("Buffers Menu %_Sorting"
1226 ["%_Most Recently Used"
1228 (customize-set-variable 'buffers-menu-sort-function nil)
1229 (customize-set-variable 'buffers-menu-grouping-function nil))
1231 :selected (null buffers-menu-sort-function)]
1234 (customize-set-variable 'buffers-menu-sort-function
1235 'sort-buffers-menu-alphabetically)
1236 (customize-set-variable 'buffers-menu-grouping-function nil))
1238 :selected (eq 'sort-buffers-menu-alphabetically
1239 buffers-menu-sort-function)]
1240 ["%_By Major Mode, Then Alphabetically"
1242 (customize-set-variable
1243 'buffers-menu-sort-function
1244 'sort-buffers-menu-by-mode-then-alphabetically)
1245 (customize-set-variable
1246 'buffers-menu-grouping-function
1247 'group-buffers-menu-by-mode-then-alphabetically))
1249 :selected (eq 'sort-buffers-menu-by-mode-then-alphabetically
1250 buffers-menu-sort-function)])
1252 ["%_Ignore Scaled Fonts"
1253 (customize-set-variable 'font-menu-ignore-scaled-fonts
1254 (not font-menu-ignore-scaled-fonts))
1256 :selected (and (boundp 'font-menu-ignore-scaled-fonts)
1257 font-menu-ignore-scaled-fonts)]
1259 ("S%_yntax Highlighting"
1261 (progn;; becomes buffer local
1263 (customize-set-variable 'font-lock-mode font-lock-mode))
1265 :selected (and (boundp 'font-lock-mode) font-lock-mode)
1266 :active (boundp 'font-lock-mode)]
1268 (customize-set-variable 'font-lock-auto-fontify
1269 (not font-lock-auto-fontify))
1271 :selected (and (boundp 'font-lock-auto-fontify) font-lock-auto-fontify)
1272 :active (fboundp 'font-lock-mode)]
1274 ["Force %_Rehighlight in this Buffer"
1275 (customize-set-variable 'font-lock-auto-fontify
1276 (not font-lock-auto-fontify))
1278 :selected (and (boundp 'font-lock-auto-fontify) font-lock-auto-fontify)
1279 :active (fboundp 'font-lock-mode)]
1283 (require 'font-lock)
1284 (font-lock-use-default-fonts)
1285 (customize-set-variable 'font-lock-use-fonts t)
1286 (customize-set-variable 'font-lock-use-colors nil)
1289 :selected (and (boundp 'font-lock-use-fonts) font-lock-use-fonts)
1290 :active (fboundp 'font-lock-mode)]
1293 (require 'font-lock)
1294 (font-lock-use-default-colors)
1295 (customize-set-variable 'font-lock-use-colors t)
1296 (customize-set-variable 'font-lock-use-fonts nil)
1299 :selected (and (boundp 'font-lock-use-colors) font-lock-use-colors)
1300 :active (boundp 'font-lock-mode)]
1304 (require 'font-lock)
1305 (if (or (and (not (integerp font-lock-maximum-decoration))
1306 (not (eq t font-lock-maximum-decoration)))
1307 (and (integerp font-lock-maximum-decoration)
1308 (<= font-lock-maximum-decoration 0)))
1310 (customize-set-variable 'font-lock-maximum-decoration nil)
1311 (font-lock-recompute-variables)))
1313 :active (fboundp 'font-lock-mode)
1314 :selected (and (boundp 'font-lock-maximum-decoration)
1315 (or (and (not (integerp font-lock-maximum-decoration))
1316 (not (eq t font-lock-maximum-decoration)))
1317 (and (integerp font-lock-maximum-decoration)
1318 (<= font-lock-maximum-decoration 0))))]
1321 (require 'font-lock)
1322 (if (and (integerp font-lock-maximum-decoration)
1323 (= 1 font-lock-maximum-decoration))
1325 (customize-set-variable 'font-lock-maximum-decoration 1)
1326 (font-lock-recompute-variables)))
1328 :active (fboundp 'font-lock-mode)
1329 :selected (and (boundp 'font-lock-maximum-decoration)
1330 (integerp font-lock-maximum-decoration)
1331 (= 1 font-lock-maximum-decoration))]
1334 (require 'font-lock)
1335 (if (and (integerp font-lock-maximum-decoration)
1336 (= 2 font-lock-maximum-decoration))
1338 (customize-set-variable 'font-lock-maximum-decoration 2)
1339 (font-lock-recompute-variables)))
1341 :active (fboundp 'font-lock-mode)
1342 :selected (and (boundp 'font-lock-maximum-decoration)
1343 (integerp font-lock-maximum-decoration)
1344 (= 2 font-lock-maximum-decoration))]
1347 (require 'font-lock)
1348 (if (or (eq font-lock-maximum-decoration t)
1349 (and (integerp font-lock-maximum-decoration)
1350 (>= font-lock-maximum-decoration 3)))
1352 (customize-set-variable 'font-lock-maximum-decoration t)
1353 (font-lock-recompute-variables)))
1355 :active (fboundp 'font-lock-mode)
1356 :selected (and (boundp 'font-lock-maximum-decoration)
1357 (or (eq font-lock-maximum-decoration t)
1358 (and (integerp font-lock-maximum-decoration)
1359 (>= font-lock-maximum-decoration 3))))]
1362 (progn;; becomes buffer local
1364 (customize-set-variable 'lazy-lock-mode lazy-lock-mode)
1365 ;; this shouldn't be necessary so there has to
1366 ;; be a redisplay bug lurking somewhere (or
1367 ;; possibly another event handler bug)
1369 :active (and (boundp 'font-lock-mode) (boundp 'lazy-lock-mode)
1372 :selected (and (boundp 'lazy-lock-mode) lazy-lock-mode)]
1374 (progn;; becomes buffer local
1376 (customize-set-variable 'lazy-shot-mode lazy-shot-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-shot-mode)
1384 :selected (and (boundp 'lazy-shot-mode) lazy-shot-mode)]
1386 (progn;; becomes buffer local
1388 (customize-set-variable 'fast-lock-mode fast-lock-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 'fast-lock-mode)
1396 :selected (and (boundp 'fast-lock-mode) fast-lock-mode)]
1398 ("%_Font" :filter font-menu-family-constructor)
1399 ("Font Si%_ze" :filter font-menu-size-constructor)
1400 ;; ("Font Weig%_ht" :filter font-menu-weight-constructor)
1401 ["Edit Fa%_ces..." (customize-face nil)]
1404 ;; #### there should be something that holds the name that the init
1405 ;; file should be created as, when it's not present.
1406 (progn (find-file (or user-init-file "~/.xemacs/init.el"))
1407 (or (eq major-mode 'emacs-lisp-mode)
1408 (emacs-lisp-mode)))]
1409 ["%_Save Options to Init File" customize-save-customized]
1413 :filter buffers-menu-filter
1414 ["Go To %_Previous Buffer" switch-to-other-buffer]
1415 ["Go To %_Buffer..." switch-to-buffer]
1417 ["%_List All Buffers" list-buffers]
1418 ["%_Delete Buffer" kill-this-buffer
1419 :suffix (if put-buffer-names-in-file-menu (buffer-name) "")]
1423 nil ; the partition: menus after this are flushright
1426 ["%_About XEmacs..." about-xemacs]
1428 ["What's %_New in XEmacs" view-emacs-news]
1429 ["%_Obtaining XEmacs" describe-distribution]
1431 ("%_Info (Online Docs)"
1432 ["%_Info Contents" info]
1433 ["Lookup %_Key Binding..." Info-goto-emacs-key-command-node]
1434 ["Lookup %_Command..." Info-goto-emacs-command-node]
1435 ["Lookup %_Function..." Info-elisp-ref]
1436 ["Lookup %_Topic..." Info-query])
1438 ["%_FAQ (local)" xemacs-local-faq]
1439 ["FAQ via %_WWW" xemacs-www-faq
1440 :active (fboundp 'browse-url)]
1441 ["%_Home Page" xemacs-www-page
1442 :active (fboundp 'browse-url)])
1444 :filter tutorials-menu-filter)
1447 (find-file (locate-data-file "sample.init.el"))
1448 :active (locate-data-file "sample.init.el")]
1450 (find-file (locate-data-file "sample.gtkrc"))
1451 :included (featurep 'gtk)
1452 :active (locate-data-file "sample.gtkrc")]
1453 ["Sample .%_Xdefaults"
1454 (find-file (locate-data-file "sample.Xdefaults"))
1455 :included (featurep 'x)
1456 :active (locate-data-file "sample.Xdefaults")]
1457 ["Sample %_enriched"
1458 (find-file (locate-data-file "enriched.doc"))
1459 :active (locate-data-file "enriched.doc")])
1460 ("%_Commands & Keys"
1461 ["%_Mode" describe-mode]
1462 ["%_Apropos..." hyper-apropos]
1463 ["Apropos %_Docs..." apropos-documentation]
1465 ["%_Key..." describe-key]
1466 ["%_Bindings" describe-bindings]
1467 ["%_Mouse Bindings" describe-pointer]
1468 ["%_Recent Keys" view-lossage]
1470 ["%_Function..." describe-function]
1471 ["%_Variable..." describe-variable]
1472 ["%_Locate Command..." where-is])
1474 ["%_Recent Messages" view-lossage]
1476 ["%_Current Installation Info" describe-installation
1477 :active (boundp 'Installation-string)]
1478 ["%_No Warranty" describe-no-warranty]
1479 ["XEmacs %_License" describe-copying]
1480 ["Find %_Packages" finder-by-keyword]
1481 ["View %_Splash Screen" xemacs-splash-buffer]
1482 ["%_Unix Manual..." manual-entry])
1483 ["Send %_Bug Report..." report-emacs-bug
1484 :active (fboundp 'report-emacs-bug)])))
1487 (defun maybe-add-init-button ()
1489 Adds `Load .emacs' button to menubar when starting up with -q."
1490 (when (and (not load-user-init-file-p)
1491 (file-exists-p (expand-file-name ".emacs" "~")))
1496 (mapc #'(lambda (buf)
1497 (with-current-buffer buf
1498 (delete-menu-item '("Load .emacs"))))
1500 (load-user-init-file))
1504 (add-hook 'before-init-hook 'maybe-add-init-button)
1509 (defvar put-buffer-names-in-file-menu t)
1512 ;;; The Bookmarks menu
1514 (defun bookmark-menu-filter (&rest ignore)
1515 (declare (special bookmark-alist))
1516 (let ((definedp (and (boundp 'bookmark-alist)
1520 '("%_Jump to Bookmark"
1521 :filter (lambda (&rest junk)
1522 (submenu-generate-accelerator-spec
1523 (mapcar #'(lambda (bmk)
1524 `[,bmk (bookmark-jump ',bmk)])
1525 (bookmark-all-names)))))
1526 ["%_Jump to Bookmark" nil nil])
1527 ["Set %_Bookmark" bookmark-set
1528 :active (fboundp 'bookmark-set)]
1530 ["Insert %_Contents" bookmark-menu-insert
1531 :active (fboundp 'bookmark-menu-insert)]
1532 ["Insert L%_ocation" bookmark-menu-locate
1533 :active (fboundp 'bookmark-menu-locate)]
1535 ["%_Rename Bookmark" bookmark-menu-rename
1536 :active (fboundp 'bookmark-menu-rename)]
1538 '("%_Delete Bookmark"
1539 :filter (lambda (&rest junk)
1540 (submenu-generate-accelerator-spec
1541 (mapcar #'(lambda (bmk)
1542 `[,bmk (bookmark-delete ',bmk)])
1543 (bookmark-all-names)))))
1544 ["%_Delete Bookmark" nil nil])
1545 ["%_Edit Bookmark List" bookmark-bmenu-list ,definedp]
1547 ["%_Save Bookmarks" bookmark-save ,definedp]
1548 ["Save Bookmarks %_As..." bookmark-write ,definedp]
1549 ["%_Load a Bookmark File" bookmark-load
1550 :active (fboundp 'bookmark-load)])))
1552 ;;; The Buffers menu
1554 (defgroup buffers-menu nil
1555 "Customization of `Buffers' menu."
1558 (defvar buffers-menu-omit-chars-list '(?b ?p ?l ?d))
1560 (defcustom buffers-menu-max-size 25
1561 "*Maximum number of entries which may appear on the \"Buffers\" menu.
1562 If this is 10, then only the ten most-recently-selected buffers will be
1563 shown. If this is nil, then all buffers will be shown. Setting this to
1564 a large number or nil will slow down menu responsiveness."
1565 :type '(choice (const :tag "Show all" nil)
1567 :group 'buffers-menu)
1569 (defcustom complex-buffers-menu-p nil
1570 "*If non-nil, the buffers menu will contain several commands.
1571 Commands will be presented as submenus of each buffer line. If this
1572 is false, then there will be only one command: select that buffer."
1574 :group 'buffers-menu)
1576 (defcustom buffers-menu-submenus-for-groups-p nil
1577 "*If non-nil, the buffers menu will contain one submenu per group of buffers.
1578 The grouping function is specified in `buffers-menu-grouping-function'.
1579 If this is an integer, do not build submenus if the number of buffers
1580 is not larger than this value."
1581 :type '(choice (const :tag "No Subgroups" nil)
1582 (integer :tag "Max. submenus" 10)
1583 (sexp :format "%t\n" :tag "Allow Subgroups" :value t))
1584 :group 'buffers-menu)
1586 (defcustom buffers-menu-switch-to-buffer-function 'switch-to-buffer
1587 "*The function to call to select a buffer from the buffers menu.
1588 `switch-to-buffer' is a good choice, as is `pop-to-buffer'."
1589 :type '(radio (function-item switch-to-buffer)
1590 (function-item pop-to-buffer)
1591 (function :tag "Other"))
1592 :group 'buffers-menu)
1594 (defcustom buffers-menu-omit-function 'buffers-menu-omit-invisible-buffers
1595 "*If non-nil, a function specifying the buffers to omit from the buffers menu.
1596 This is passed a buffer and should return non-nil if the buffer should be
1597 omitted. The default value `buffers-menu-omit-invisible-buffers' omits
1598 buffers that are normally considered \"invisible\" (those whose name
1599 begins with a space)."
1600 :type '(choice (const :tag "None" nil)
1602 :group 'buffers-menu)
1604 (defcustom buffers-menu-format-buffer-line-function 'format-buffers-menu-line
1605 "*The function to call to return a string to represent a buffer in
1606 the buffers menu. The function is passed a buffer and a number
1607 (starting with 1) indicating which buffer line in the menu is being
1608 processed and should return a string containing an accelerator
1609 spec. (Check out `menu-item-generate-accelerator-spec' as a convenient
1610 way of generating the accelerator specs.) The default value
1611 `format-buffers-menu-line' just returns the name of the buffer and
1612 uses the number as the accelerator. Also check out
1613 `slow-format-buffers-menu-line' which returns a whole bunch of info
1616 Note: Gross Compatibility Hack: Older versions of this function prototype
1617 only expected one argument, not two. We deal gracefully with such
1618 functions by simply calling them with one argument and leaving out the
1619 line number. However, this may go away at any time, so make sure to
1620 update all of your functions of this type."
1622 :group 'buffers-menu)
1624 (defcustom buffers-menu-sort-function
1625 'sort-buffers-menu-by-mode-then-alphabetically
1626 "*If non-nil, a function to sort the list of buffers in the buffers menu.
1627 It will be passed two arguments (two buffers to compare) and should return
1628 t if the first is \"less\" than the second. One possible value is
1629 `sort-buffers-menu-alphabetically'; another is
1630 `sort-buffers-menu-by-mode-then-alphabetically'."
1631 :type '(choice (const :tag "None" nil)
1633 :group 'buffers-menu)
1635 (defcustom buffers-menu-grouping-function
1636 'group-buffers-menu-by-mode-then-alphabetically
1637 "*If non-nil, a function to group buffers in the buffers menu together.
1638 It will be passed two arguments, successive members of the sorted buffers
1639 list after being passed through `buffers-menu-sort-function'. It should
1640 return non-nil if the second buffer begins a new group. The return value
1641 should be the name of the old group, which may be used in hierarchical
1642 buffers menus. The last invocation of the function contains nil as the
1643 second argument, so that the name of the last group can be determined.
1645 The sensible values of this function are dependent on the value specified
1646 for `buffers-menu-sort-function'."
1647 :type '(choice (const :tag "None" nil)
1649 :group 'buffers-menu)
1651 (defun sort-buffers-menu-alphabetically (buf1 buf2)
1652 "For use as a value of `buffers-menu-sort-function'.
1653 Sorts the buffers in alphabetical order by name, but puts buffers beginning
1654 with a star at the end of the list."
1655 (let* ((nam1 (buffer-name buf1))
1656 (nam2 (buffer-name buf2))
1657 (inv1p (not (null (string-match "\\` " nam1))))
1658 (inv2p (not (null (string-match "\\` " nam2))))
1659 (star1p (not (null (string-match "\\`*" nam1))))
1660 (star2p (not (null (string-match "\\`*" nam2)))))
1661 (cond ((not (eq inv1p inv2p))
1663 ((not (eq star1p star2p))
1666 (string-lessp nam1 nam2)))))
1668 (defun sort-buffers-menu-by-mode-then-alphabetically (buf1 buf2)
1669 "For use as a value of `buffers-menu-sort-function'.
1670 Sorts first by major mode and then alphabetically by name, but puts buffers
1671 beginning with a star at the end of the list."
1672 (let* ((nam1 (buffer-name buf1))
1673 (nam2 (buffer-name buf2))
1674 (inv1p (not (null (string-match "\\` " nam1))))
1675 (inv2p (not (null (string-match "\\` " nam2))))
1676 (star1p (not (null (string-match "\\`*" nam1))))
1677 (star2p (not (null (string-match "\\`*" nam2))))
1678 (mode1 (symbol-value-in-buffer 'major-mode buf1))
1679 (mode2 (symbol-value-in-buffer 'major-mode buf2)))
1680 (cond ((not (eq inv1p inv2p))
1682 ((not (eq star1p star2p))
1684 ((and star1p star2p (string-lessp nam1 nam2)))
1685 ((string-lessp mode1 mode2)
1687 ((string-lessp mode2 mode1)
1690 (string-lessp nam1 nam2)))))
1692 ;; this version is too slow on some machines.
1693 ;; (vintage 1990, that is)
1694 (defun slow-format-buffers-menu-line (buffer n)
1695 "For use as a value of `buffers-menu-format-buffer-line-function'.
1696 This returns a string containing a bunch of info about the buffer."
1697 (concat (menu-item-generate-accelerator-spec n buffers-menu-omit-chars-list)
1698 (format "%s%s %-19s %6s %-15s %s"
1699 (if (buffer-modified-p buffer) "*" " ")
1700 (if (symbol-value-in-buffer 'buffer-read-only buffer)
1702 (buffer-name buffer)
1703 (buffer-size buffer)
1704 (symbol-value-in-buffer 'mode-name buffer)
1705 (or (buffer-file-name buffer) ""))))
1707 (defun format-buffers-menu-line (buffer n)
1708 "For use as a value of `buffers-menu-format-buffer-line-function'.
1709 This just returns the buffer's name."
1710 (concat (menu-item-generate-accelerator-spec n buffers-menu-omit-chars-list)
1711 (buffer-name buffer)))
1713 (defun group-buffers-menu-by-mode-then-alphabetically (buf1 buf2)
1714 "For use as a value of `buffers-menu-grouping-function'.
1715 This groups buffers by major mode. It only really makes sense if
1716 `buffers-menu-sorting-function' is
1717 `sort-buffers-menu-by-mode-then-alphabetically'."
1718 (cond ((string-match "\\`*" (buffer-name buf1))
1719 (and (null buf2) "*Misc*"))
1721 (string-match "\\`*" (buffer-name buf2))
1722 (not (eq (symbol-value-in-buffer 'major-mode buf1)
1723 (symbol-value-in-buffer 'major-mode buf2))))
1724 (symbol-value-in-buffer 'mode-name buf1))
1727 (defun buffer-menu-save-buffer (buffer)
1732 (defun buffer-menu-write-file (buffer)
1735 (write-file (read-file-name
1736 (format "Write %s to file: "
1737 (buffer-name (current-buffer)))))))
1739 (defsubst build-buffers-menu-internal (buffers)
1740 (let (name line (n 0))
1747 ; #### a truly Kyle-friendly hack.
1748 (let ((fn buffers-menu-format-buffer-line-function))
1749 (if (= (function-max-args fn) 1)
1751 (funcall fn buffer n))))
1752 (if complex-buffers-menu-p
1755 (vector "S%_witch to Buffer"
1756 (list buffers-menu-switch-to-buffer-function
1757 (setq name (buffer-name buffer)))
1759 (if (eq buffers-menu-switch-to-buffer-function
1761 (vector "Switch to Buffer, Other %_Frame"
1762 (list 'switch-to-buffer-other-frame
1763 (setq name (buffer-name buffer)))
1766 (if (and (buffer-modified-p buffer)
1767 (buffer-file-name buffer))
1768 (vector "%_Save Buffer"
1769 (list 'buffer-menu-save-buffer name) t)
1770 ["%_Save Buffer" nil nil]
1772 (vector "Save %_As..."
1773 (list 'buffer-menu-write-file name) t)
1774 (vector "%_Delete Buffer" (list 'kill-buffer name)
1776 ;; #### We don't want buffer names to be translated,
1777 ;; #### so we put the buffer name in the suffix.
1778 ;; #### Also, avoid losing with non-ASCII buffer names.
1779 ;; #### We still lose, however, if complex-buffers-menu-p. --mrb
1781 (list buffers-menu-switch-to-buffer-function
1782 (buffer-name buffer))
1786 (defun buffers-menu-filter (menu)
1787 "This is the menu filter for the top-level buffers \"Buffers\" menu.
1788 It dynamically creates a list of buffers to use as the contents of the menu.
1789 Only the most-recently-used few buffers will be listed on the menu, for
1790 efficiency reasons. You can control how many buffers will be shown by
1791 setting `buffers-menu-max-size'. You can control the text of the menu
1792 items by redefining the function `format-buffers-menu-line'."
1793 (let ((buffers (delete-if buffers-menu-omit-function (buffer-list))))
1794 (and (integerp buffers-menu-max-size)
1795 (> buffers-menu-max-size 1)
1796 (> (length buffers) buffers-menu-max-size)
1797 ;; shorten list of buffers (not with submenus!)
1798 (not (and buffers-menu-grouping-function
1799 buffers-menu-submenus-for-groups-p))
1800 (setcdr (nthcdr buffers-menu-max-size buffers) nil))
1801 (if buffers-menu-sort-function
1802 (setq buffers (sort buffers buffers-menu-sort-function)))
1803 (if (and buffers-menu-grouping-function
1804 buffers-menu-submenus-for-groups-p
1805 (or (not (integerp buffers-menu-submenus-for-groups-p))
1806 (> (length buffers) buffers-menu-submenus-for-groups-p)))
1807 (let (groups groupnames current-group)
1810 (let ((groupname (funcall buffers-menu-grouping-function
1811 (car sublist) (cadr sublist))))
1812 (setq current-group (cons (car sublist) current-group))
1815 (setq groups (cons (nreverse current-group)
1817 (setq groupnames (cons groupname groupnames))
1818 (setq current-group nil)))))
1822 #'(lambda (groupname group)
1823 (cons groupname (build-buffers-menu-internal group)))
1824 (nreverse groupnames)
1825 (nreverse groups))))
1826 (if buffers-menu-grouping-function
1831 (cond ((funcall buffers-menu-grouping-function
1832 (car sublist) (cadr sublist))
1833 (list (car sublist) t))
1834 (t (list (car sublist)))))
1836 ;; remove a trailing separator.
1837 (and (>= (length buffers) 2)
1838 (let ((lastcdr (nthcdr (- (length buffers) 2) buffers)))
1839 (if (eq t (cadr lastcdr))
1840 (setcdr lastcdr nil))))))
1841 (setq buffers (build-buffers-menu-internal buffers)))
1842 (append menu buffers)
1845 (defun language-environment-menu-filter (menu)
1846 "This is the menu filter for the \"Language Environment\" submenu."
1847 (declare (special language-environment-list))
1849 (mapcar (lambda (env-sym)
1851 `[ ,(concat (menu-item-generate-accelerator-spec n)
1852 (capitalize (symbol-name env-sym)))
1853 (set-language-environment ',env-sym)])
1854 language-environment-list)))
1857 ;;; The Options menu
1859 ;; We'll keep those variables here for a while, in order to provide a
1860 ;; function for porting the old options file that a user may own to Custom.
1862 (defvar options-save-faces nil
1863 "*Non-nil value means save-options will save information about faces.
1864 A nil value means save-options will not save face information.
1865 Set this non-nil only if you use M-x edit-faces to change face
1866 settings. If you use M-x customize-face or the \"Browse Faces...\"
1867 menu entry, you will see a button in the Customize Face buffer that you
1868 can use to permanently save your face changes.
1870 M-x edit-faces is deprecated. Support for it and this variable will
1871 be discontinued in a future release.")
1873 (defvar save-options-init-file nil
1874 "File into which to save forms to load the options file (nil for .emacs).
1875 Normally this is nil, which means save into your .emacs file (the value
1876 of `user-init-file'.")
1878 (defvar save-options-file ".xemacs-options"
1879 "File to save options into.
1880 This file is loaded from your .emacs file.
1881 If this is a relative filename, it is put into the same directory as your
1888 (defun tutorials-menu-filter (menu-items)
1889 (declare (special language-info-alist
1890 current-language-environment
1891 tutorial-supported-languages))
1893 (if (featurep 'mule)
1895 (assoc current-language-environment language-info-alist))
1896 `([,(concat "%_Default (" current-language-environment ")")
1897 help-with-tutorial]))
1898 '(["%_English" help-with-tutorial]))
1899 (submenu-generate-accelerator-spec
1900 (if (featurep 'mule)
1902 (mapcan #'(lambda (lang)
1903 (let ((tut (assq 'tutorial lang)))
1905 (not (string= (car lang) "ASCII"))
1906 ;; skip current language, since we already
1907 ;; included it first
1908 (not (string= (car lang)
1909 current-language-environment))
1911 (help-with-tutorial nil ,(cdr tut))]))))
1912 language-info-alist)
1913 ;; Non mule tutorials.
1914 (mapcar #'(lambda (lang)
1916 (help-with-tutorial ,(format "TUTORIAL.%s"
1918 tutorial-supported-languages)))))
1920 (set-menubar default-menubar)
1925 (defconst default-popup-menu
1927 ["%_Undo" advertised-undo
1928 :active (and (not (eq buffer-undo-list t))
1929 (or buffer-undo-list pending-undo-list))
1930 :suffix (if (or (eq last-command 'undo)
1931 (eq last-command 'advertised-undo))
1933 ["Cu%_t" kill-primary-selection
1934 :active (selection-owner-p)]
1935 ["%_Copy" copy-primary-selection
1936 :active (selection-owner-p)]
1937 ["%_Paste" yank-clipboard-selection
1938 :active (selection-exists-p 'CLIPBOARD)]
1939 ["%_Delete" delete-primary-selection
1940 :active (selection-owner-p)]
1942 ["Select %_Block" mark-paragraph]
1943 ["Sp%_lit Window" split-window-vertically]
1944 ["U%_nsplit Window" delete-other-windows]
1947 ;; In an effort to avoid massive menu clutter, this mostly worthless menu is
1948 ;; superseded by any local popup menu...
1949 (setq-default mode-popup-menu default-popup-menu)
1954 (defun xemacs-splash-buffer ()
1955 "Redisplay XEmacs splash screen in a buffer."
1957 (let ((buffer (get-buffer-create "*Splash*"))
1960 (setq buffer-read-only t)
1961 (erase-buffer buffer)
1962 (setq tmout (display-splash-frame))
1964 (make-local-hook 'kill-buffer-hook)
1965 (add-hook 'kill-buffer-hook
1967 (disable-timeout ,tmout))
1969 (pop-to-buffer buffer)
1970 (delete-other-windows)))
1973 ;;; backwards compatibility
1974 (provide 'x-menubar)
1975 (provide 'menubar-items)
1977 ;;; menubar-items.el ends here.