aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/menu-bar.el109
1 files changed, 51 insertions, 58 deletions
diff --git a/lisp/menu-bar.el b/lisp/menu-bar.el
index 14794651fdb..19be9893634 100644
--- a/lisp/menu-bar.el
+++ b/lisp/menu-bar.el
@@ -551,6 +551,18 @@ Do the same for the keys of the same name."
551 551
552;(defvar menu-bar-preferences-menu (make-sparse-keymap "Preferences")) 552;(defvar menu-bar-preferences-menu (make-sparse-keymap "Preferences"))
553 553
554(defmacro menu-bar-make-mm-toggle (fname doc help &optional props)
555 "Make a menu-item for a global minor mode toggle.
556FNAME is the minor mode's name (variable and function).
557DOC is the text to use the menu entry.
558HELP is the text to use for the tooltip.
559PROPS are additional properties."
560 `'(menu-item ,doc ',fname
561 ,@(if props props)
562 :help ,help
563 :button (:toggle . (and (default-boundp ',fname)
564 (default-value ',fname)))))
565
554(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 &optional props &rest body)
555 `(progn 567 `(progn
556 (defun ,name () 568 (defun ,name ()
@@ -775,30 +787,13 @@ Do the same for the keys of the same name."
775 :visible `(display-graphic-p) 787 :visible `(display-graphic-p)
776 :help "Select scroll-bar mode")) 788 :help "Select scroll-bar mode"))
777 789
778(defun showhide-menu-bar () 790(define-key menu-bar-showhide-menu [menu-bar-mode]
779 "Toggle whether to turn menu-bar on/off." 791 '(menu-item "Menu-bar" menu-bar-mode
780 (interactive)
781 (menu-bar-mode)
782 (if menu-bar-mode
783 (message "Menu-bar mode enabled.")
784 (message "Menu-bar mode disabled. Use M-x menu-bar-mode to make the menu bar appear."))
785 (customize-mark-as-set 'menu-bar-mode))
786
787(define-key menu-bar-showhide-menu [showhide-menu-bar]
788 '(menu-item "Menu-bar" showhide-menu-bar
789 :help "Toggle menu-bar on/off" 792 :help "Toggle menu-bar on/off"
790 :button (:toggle . menu-bar-mode))) 793 :button (:toggle . menu-bar-mode)))
791 794
792(defun showhide-toolbar ()
793 "Toggle whether to turn tool-bar on/off."
794 (interactive)
795 (if (tool-bar-mode)
796 (message "Tool-bar mode enabled.")
797 (message "Tool-bar mode disabled."))
798 (customize-mark-as-set 'tool-bar-mode))
799
800(define-key menu-bar-showhide-menu [showhide-tool-bar] 795(define-key menu-bar-showhide-menu [showhide-tool-bar]
801 (list 'menu-item "Tool-bar" 'showhide-toolbar 796 (list 'menu-item "Tool-bar" 'tool-bar-mode
802 :help "Turn tool-bar on/off" 797 :help "Turn tool-bar on/off"
803 :visible `(display-graphic-p) 798 :visible `(display-graphic-p)
804 :button `(:toggle . tool-bar-mode))) 799 :button `(:toggle . tool-bar-mode)))
@@ -839,19 +834,11 @@ Do the same for the keys of the same name."
839 '("--")) 834 '("--"))
840(define-key menu-bar-options-menu [toggle-auto-compression] 835(define-key menu-bar-options-menu [toggle-auto-compression]
841 '(menu-item "Automatic File De/compression" 836 '(menu-item "Automatic File De/compression"
842 menu-bar-toggle-auto-compression-mode 837 auto-compression-mode
843 :help "Transparently decompress compressed files" 838 :help "Transparently decompress compressed files"
844 :button (:toggle . (rassq 'jka-compr-handler 839 :button (:toggle . (rassq 'jka-compr-handler
845 file-name-handler-alist)))) 840 file-name-handler-alist))))
846 841
847(defun menu-bar-toggle-auto-compression ()
848 "Toggle automatic file compression and uncompression.
849With prefix argument ARG, turn auto compression on if positive, else off.
850Returns the new status of auto compression (non-nil means on)."
851 (interactive)
852 (auto-compression-mode)
853 (customize-mark-as-set 'auto-compression-mode))
854
855(define-key menu-bar-options-menu [save-place] 842(define-key menu-bar-options-menu [save-place]
856 (menu-bar-make-toggle toggle-save-place-globally save-place 843 (menu-bar-make-toggle toggle-save-place-globally save-place
857 "Save Place in Files between Sessions" 844 "Save Place in Files between Sessions"
@@ -919,9 +906,8 @@ paste (in addition to the normal Emacs bindings)."
919(define-key menu-bar-options-menu [highlight-separator] 906(define-key menu-bar-options-menu [highlight-separator]
920 '("--")) 907 '("--"))
921(define-key menu-bar-options-menu [highlight-paren-mode] 908(define-key menu-bar-options-menu [highlight-paren-mode]
922 (menu-bar-make-toggle toggle-highlight-paren-mode show-paren-mode 909 (menu-bar-make-mm-toggle show-paren-mode
923 "Paren Match Highlighting" 910 "Paren Match Highlighting"
924 "Show Paren mode %s"
925 "Highlight matching/mismatched parentheses at cursor (Show Paren mode)")) 911 "Highlight matching/mismatched parentheses at cursor (Show Paren mode)"))
926(define-key menu-bar-options-menu [transient-mark-mode] 912(define-key menu-bar-options-menu [transient-mark-mode]
927 (menu-bar-make-toggle toggle-transient-mark-mode transient-mark-mode 913 (menu-bar-make-toggle toggle-transient-mark-mode transient-mark-mode
@@ -930,10 +916,9 @@ paste (in addition to the normal Emacs bindings)."
930 "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)"
931 (:enable (not cua-mode)))) 917 (:enable (not cua-mode))))
932(define-key menu-bar-options-menu [toggle-global-lazy-font-lock-mode] 918(define-key menu-bar-options-menu [toggle-global-lazy-font-lock-mode]
933 (menu-bar-make-toggle toggle-global-lazy-font-lock-mode global-font-lock-mode 919 (menu-bar-make-mm-toggle global-font-lock-mode
934 "Syntax Highlighting" 920 "Syntax Highlighting"
935 "Global Font Lock mode %s" 921 "Colorize text based on language syntax (Global Font Lock mode)"))
936 "Colorize text based on language syntax (Global Font Lock mode)"))
937 922
938 923
939;; The "Tools" menu items 924;; The "Tools" menu items
@@ -1615,7 +1600,7 @@ This command applies to all frames that exist and frames to be
1615created in the future. 1600created in the future.
1616With a numeric argument, if the argument is positive, 1601With a numeric argument, if the argument is positive,
1617turn on menu bars; otherwise, turn off menu bars." 1602turn on menu bars; otherwise, turn off menu bars."
1618 (interactive "P") 1603 (interactive "P")
1619 1604
1620 ;; Make menu-bar-mode and default-frame-alist consistent. 1605 ;; Make menu-bar-mode and default-frame-alist consistent.
1621 (let ((default (assq 'menu-bar-lines default-frame-alist))) 1606 (let ((default (assq 'menu-bar-lines default-frame-alist)))
@@ -1626,27 +1611,35 @@ turn on menu bars; otherwise, turn off menu bars."
1626 default-frame-alist)))) 1611 default-frame-alist))))
1627 1612
1628 ;; Toggle or set the mode, according to FLAG. 1613 ;; Toggle or set the mode, according to FLAG.
1629 (setq menu-bar-mode (if (null flag) (not menu-bar-mode) 1614 (setq menu-bar-mode (if (null flag) (not menu-bar-mode)
1630 (> (prefix-numeric-value flag) 0))) 1615 (> (prefix-numeric-value flag) 0)))
1631 1616
1632 ;; Apply it to default-frame-alist. 1617 ;; Apply it to default-frame-alist.
1633 (let ((parameter (assq 'menu-bar-lines default-frame-alist))) 1618 (let ((parameter (assq 'menu-bar-lines default-frame-alist)))
1634 (if (consp parameter) 1619 (if (consp parameter)
1635 (setcdr parameter (if menu-bar-mode 1 0)) 1620 (setcdr parameter (if menu-bar-mode 1 0))
1636 (setq default-frame-alist 1621 (setq default-frame-alist
1637 (cons (cons 'menu-bar-lines (if menu-bar-mode 1 0)) 1622 (cons (cons 'menu-bar-lines (if menu-bar-mode 1 0))
1638 default-frame-alist)))) 1623 default-frame-alist))))
1639 1624
1640 ;; Apply it to existing frames. 1625 ;; Apply it to existing frames.
1641 (let ((frames (frame-list))) 1626 (let ((frames (frame-list)))
1642 (while frames 1627 (while frames
1643 (let ((height (cdr (assq 'height (frame-parameters (car frames)))))) 1628 (let ((height (cdr (assq 'height (frame-parameters (car frames))))))
1644 (modify-frame-parameters (car frames) 1629 (modify-frame-parameters (car frames)
1645 (list (cons 'menu-bar-lines 1630 (list (cons 'menu-bar-lines
1646 (if menu-bar-mode 1 0)))) 1631 (if menu-bar-mode 1 0))))
1647 (modify-frame-parameters (car frames) 1632 (modify-frame-parameters (car frames)
1648 (list (cons 'height height)))) 1633 (list (cons 'height height))))
1649 (setq frames (cdr frames))))) 1634 (setq frames (cdr frames))))
1635
1636 (when (interactive-p)
1637 (if menu-bar-mode
1638 (message "Menu-bar mode enabled.")
1639 (message "Menu-bar mode disabled. Use M-x menu-bar-mode to make the menu bar appear."))
1640 (customize-mark-as-set 'menu-bar-mode))
1641
1642 menu-bar-mode)
1650 1643
1651(provide 'menu-bar) 1644(provide 'menu-bar)
1652 1645