comparison lisp/menu-bar.el @ 47421:055681adf287

(line-number-mode, column-number-mode) (transient-mark-mode): Use minor mode directly. (menu-bar-make-toggle): Remove `props' arg. Move customize-mark-as-set directly into the toggle function.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Wed, 11 Sep 2002 21:56:50 +0000
parents 8d11b5360234
children af1e3a228034
comparison
equal deleted inserted replaced
47420:b7a8fec8113c 47421:055681adf287
561 ,@(if props props) 561 ,@(if props props)
562 :help ,help 562 :help ,help
563 :button (:toggle . (and (default-boundp ',fname) 563 :button (:toggle . (and (default-boundp ',fname)
564 (default-value ',fname))))) 564 (default-value ',fname)))))
565 565
566 (defmacro menu-bar-make-toggle (name variable doc message help &optional props &rest body) 566 (defmacro menu-bar-make-toggle (name variable doc message help &rest body)
567 `(progn 567 `(progn
568 (defun ,name () 568 (defun ,name ()
569 ,(concat "Toggle whether to " (downcase (substring help 0 1)) 569 ,(concat "Toggle whether to " (downcase (substring help 0 1))
570 (substring help 1) ".") 570 (substring help 1) ".")
571 (interactive) 571 (interactive)
574 (custom-load-symbol ',variable) 574 (custom-load-symbol ',variable)
575 (let ((set (or (get ',variable 'custom-set) 'set-default)) 575 (let ((set (or (get ',variable 'custom-set) 'set-default))
576 (get (or (get ',variable 'custom-get) 'default-value))) 576 (get (or (get ',variable 'custom-get) 'default-value)))
577 (funcall set ',variable (not (funcall get ',variable)))))) 577 (funcall set ',variable (not (funcall get ',variable))))))
578 (message ,message "enabled") 578 (message ,message "enabled")
579 (message ,message "disabled"))) 579 (message ,message "disabled"))
580 ;; The function `customize-mark-as-set' must only be called when 580 ;; The function `customize-mark-as-set' must only be called when
581 ;; a variable is set interactively, as the purpose is to mark it 581 ;; a variable is set interactively, as the purpose is to mark it as
582 ;; as a candidate for "Save Options", and we do not want to save 582 ;; a candidate for "Save Options", and we do not want to save options
583 ;; options the user have already set explicitly in his init 583 ;; the user have already set explicitly in his init file.
584 ;; file. Unfortunately, he could very likely call the function 584 (if (interactive-p) (customize-mark-as-set ',variable)))
585 ;; defined above there. So we put `customize-mark-as-set' in a 585 '(menu-item ,doc ,name
586 ;; lambda expression.
587 ;; -- Per Abrahamsen <abraham@dina.kvl.dk> 2002-02-11.
588 '(menu-item ,doc (lambda ()
589 (interactive)
590 (,name)
591 (customize-mark-as-set ',variable))
592 ,@(if props props)
593 :help ,help 586 :help ,help
594 :button (:toggle . (and (default-boundp ',variable) 587 :button (:toggle . (and (default-boundp ',variable)
595 (default-value ',variable)))))) 588 (default-value ',variable))))))
596 589
597 ;;; Assemble all the top-level items of the "Options" menu 590 ;;; Assemble all the top-level items of the "Options" menu
635 ;; The "Show/Hide" submenu of menu "Options" 628 ;; The "Show/Hide" submenu of menu "Options"
636 629
637 (defvar menu-bar-showhide-menu (make-sparse-keymap "Show/Hide")) 630 (defvar menu-bar-showhide-menu (make-sparse-keymap "Show/Hide"))
638 631
639 (define-key menu-bar-showhide-menu [column-number-mode] 632 (define-key menu-bar-showhide-menu [column-number-mode]
640 (menu-bar-make-toggle toggle-column-number-mode column-number-mode 633 (menu-bar-make-mm-toggle column-number-mode
641 "Show Column Numbers" "Column number mode %s" 634 "Show Column Numbers"
642 "Show the current column number in the mode line")) 635 "Show the current column number in the mode line"))
643 636
644 (define-key menu-bar-showhide-menu [line-number-mode] 637 (define-key menu-bar-showhide-menu [line-number-mode]
645 (menu-bar-make-toggle toggle-line-number-mode line-number-mode 638 (menu-bar-make-mm-toggle line-number-mode
646 "Show Line Numbers" "Line number mode %s" 639 "Show Line Numbers"
647 "Show the current line number in the mode line")) 640 "Show the current line number in the mode line"))
648 641
649 (define-key menu-bar-showhide-menu [linecolumn-separator] 642 (define-key menu-bar-showhide-menu [linecolumn-separator]
650 '("--")) 643 '("--"))
651 644
652 (defun showhide-date-time () 645 (defun showhide-date-time ()
848 (define-key menu-bar-options-menu [uniquify] 841 (define-key menu-bar-options-menu [uniquify]
849 (menu-bar-make-toggle toggle-uniquify-buffer-names uniquify-buffer-name-style 842 (menu-bar-make-toggle toggle-uniquify-buffer-names uniquify-buffer-name-style
850 "Use Directory Names in Buffer Names" 843 "Use Directory Names in Buffer Names"
851 "Directory name in buffer names (uniquify) %s" 844 "Directory name in buffer names (uniquify) %s"
852 "Uniquify buffer names by adding parent directory names" 845 "Uniquify buffer names by adding parent directory names"
853 () ; no props
854 (require 'uniquify) 846 (require 'uniquify)
855 (setq uniquify-buffer-name-style 847 (setq uniquify-buffer-name-style
856 (if (not uniquify-buffer-name-style) 848 (if (not uniquify-buffer-name-style)
857 'forward)))) 849 'forward))))
858 850
906 (define-key menu-bar-options-menu [highlight-separator] 898 (define-key menu-bar-options-menu [highlight-separator]
907 '("--")) 899 '("--"))
908 (define-key menu-bar-options-menu [highlight-paren-mode] 900 (define-key menu-bar-options-menu [highlight-paren-mode]
909 (menu-bar-make-mm-toggle show-paren-mode 901 (menu-bar-make-mm-toggle show-paren-mode
910 "Paren Match Highlighting" 902 "Paren Match Highlighting"
911 "Highlight matching/mismatched parentheses at cursor (Show Paren mode)")) 903 "Highlight matching/mismatched parentheses at cursor (Show Paren mode)"))
912 (define-key menu-bar-options-menu [transient-mark-mode] 904 (define-key menu-bar-options-menu [transient-mark-mode]
913 (menu-bar-make-toggle toggle-transient-mark-mode transient-mark-mode 905 (menu-bar-make-mm-toggle transient-mark-mode
914 "Active Region Highlighting" 906 "Active Region Highlighting"
915 "Transient Mark mode %s" 907 "Make text in active region stand out in color (Transient Mark mode)"
916 "Make text in active region stand out in color (Transient Mark mode)" 908 (:enable (not cua-mode))))
917 (:enable (not cua-mode))))
918 (define-key menu-bar-options-menu [toggle-global-lazy-font-lock-mode] 909 (define-key menu-bar-options-menu [toggle-global-lazy-font-lock-mode]
919 (menu-bar-make-mm-toggle global-font-lock-mode 910 (menu-bar-make-mm-toggle global-font-lock-mode
920 "Syntax Highlighting" 911 "Syntax Highlighting"
921 "Colorize text based on language syntax (Global Font Lock mode)")) 912 "Colorize text based on language syntax (Global Font Lock mode)"))
922 913
1538 (add-hook 'menu-bar-update-hook 'menu-bar-update-buffers) 1529 (add-hook 'menu-bar-update-hook 'menu-bar-update-buffers)
1539 1530
1540 (menu-bar-update-buffers) 1531 (menu-bar-update-buffers)
1541 1532
1542 ;; this version is too slow 1533 ;; this version is too slow
1543 ;;;(defun format-buffers-menu-line (buffer) 1534 ;;(defun format-buffers-menu-line (buffer)
1544 ;;; "Returns a string to represent the given buffer in the Buffer menu. 1535 ;; "Returns a string to represent the given buffer in the Buffer menu.
1545 ;;;nil means the buffer shouldn't be listed. You can redefine this." 1536 ;;nil means the buffer shouldn't be listed. You can redefine this."
1546 ;;; (if (string-match "\\` " (buffer-name buffer)) 1537 ;; (if (string-match "\\` " (buffer-name buffer))
1547 ;;; nil 1538 ;; nil
1548 ;;; (save-excursion 1539 ;; (save-excursion
1549 ;;; (set-buffer buffer) 1540 ;; (set-buffer buffer)
1550 ;;; (let ((size (buffer-size))) 1541 ;; (let ((size (buffer-size)))
1551 ;;; (format "%s%s %-19s %6s %-15s %s" 1542 ;; (format "%s%s %-19s %6s %-15s %s"
1552 ;;; (if (buffer-modified-p) "*" " ") 1543 ;; (if (buffer-modified-p) "*" " ")
1553 ;;; (if buffer-read-only "%" " ") 1544 ;; (if buffer-read-only "%" " ")
1554 ;;; (buffer-name) 1545 ;; (buffer-name)
1555 ;;; size 1546 ;; size
1556 ;;; mode-name 1547 ;; mode-name
1557 ;;; (or (buffer-file-name) "")))))) 1548 ;; (or (buffer-file-name) ""))))))
1558 1549
1559 ;;; Set up a menu bar menu for the minibuffer. 1550 ;;; Set up a menu bar menu for the minibuffer.
1560 1551
1561 (dolist (map (list minibuffer-local-map 1552 (dolist (map (list minibuffer-local-map
1562 ;; This shouldn't be necessary, but there's a funny 1553 ;; This shouldn't be necessary, but there's a funny