From 8ab9589dfca1cbe6e32e9608ef8cfa875c28c4a2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20Dj=C3=A4rv?= Date: Sat, 1 Mar 2003 15:55:04 +0000 Subject: [PATCH] * startup.el (command-line): Call menu-bar-mode with 1 instead of t. * menu-bar.el (menu-bar-mode): Change to define-minor-mode and initialize as for tool-bar-mode. --- lisp/ChangeLog | 7 +++++ lisp/menu-bar.el | 81 +++++++++++++++++++----------------------------- lisp/startup.el | 2 +- 3 files changed, 40 insertions(+), 50 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 71e9b030ffc..3ef08a44105 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,10 @@ +2003-03-01 Jan Dj,Ad(Brv + + * startup.el (command-line): Call menu-bar-mode with 1 instead of t. + + * menu-bar.el (menu-bar-mode): Change to define-minor-mode + and initialize as for tool-bar-mode. + 2003-02-28 Kai Gro,A_(Bjohann * lisp/net/tramp.el: Version 2.0.30 released. diff --git a/lisp/menu-bar.el b/lisp/menu-bar.el index 2c0dbd6e253..596241c08b6 100644 --- a/lisp/menu-bar.el +++ b/lisp/menu-bar.el @@ -1611,61 +1611,44 @@ Buffers menu is regenerated." (list 'menu-item "Enter" 'exit-minibuffer :help "Terminate input and exit minibuffer"))) -(defcustom menu-bar-mode t - "Toggle display of a menu bar on each frame. -Setting this variable directly does not take effect; -use either \\[customize] or the function `menu-bar-mode'." - :set (lambda (symbol value) - (menu-bar-mode (or value 0))) - :initialize 'custom-initialize-default - :type 'boolean - :group 'frames) - -(defun menu-bar-mode (&optional flag) +;;;###autoload +;; This comment is taken from toolbar/tool-bar.el near +;; (put 'tool-bar-mode ...) +;; We want to pretend the menu bar by standard is on, as this will make +;; customize consider disabling the menu bar a customization, and save +;; that. We could do this for real by setting :init-value below, but +;; that would overwrite disabling the tool bar from X resources. +(put 'menu-bar-mode 'standard-value '(t)) + +;;;###autoload +(define-minor-mode menu-bar-mode "Toggle display of a menu bar on each frame. This command applies to all frames that exist and frames to be created in the future. With a numeric argument, if the argument is positive, turn on menu bars; otherwise, turn off menu bars." - (interactive "P") - + :init-value nil + :global t + :group 'frames ;; Make menu-bar-mode and default-frame-alist consistent. - (let ((default (assq 'menu-bar-lines default-frame-alist))) - (if default - (setq menu-bar-mode (not (eq (cdr default) 0))) - (setq default-frame-alist - (cons (cons 'menu-bar-lines (if menu-bar-mode 1 0)) - default-frame-alist)))) - - ;; Toggle or set the mode, according to FLAG. - (setq menu-bar-mode (if (null flag) (not menu-bar-mode) - (> (prefix-numeric-value flag) 0))) - - ;; Apply it to default-frame-alist. - (let ((parameter (assq 'menu-bar-lines default-frame-alist))) - (if (consp parameter) - (setcdr parameter (if menu-bar-mode 1 0)) - (setq default-frame-alist - (cons (cons 'menu-bar-lines (if menu-bar-mode 1 0)) - default-frame-alist)))) - - ;; Apply it to existing frames. - (let ((frames (frame-list))) - (while frames - (let ((height (cdr (assq 'height (frame-parameters (car frames)))))) - (modify-frame-parameters (car frames) - (list (cons 'menu-bar-lines - (if menu-bar-mode 1 0)))) - (modify-frame-parameters (car frames) - (list (cons 'height height)))) - (setq frames (cdr frames)))) - - (when (interactive-p) - (if menu-bar-mode - (message "Menu-bar mode enabled.") - (message "Menu-bar mode disabled. Use M-x menu-bar-mode to make the menu bar appear.")) - (customize-mark-as-set 'menu-bar-mode)) - + (let ((lines (if menu-bar-mode 1 0))) + ;; Alter existing frames... + (mapc (lambda (frame) + (modify-frame-parameters frame + (list (cons 'menu-bar-lines lines)))) + (frame-list)) + ;; ...and future ones. + (let ((elt (assq 'menu-bar-lines default-frame-alist))) + (if elt + (setcdr elt lines) + (add-to-list 'default-frame-alist (cons 'menu-bar-lines lines))))) + + ;; Make the message appear when Emacs is idle. We can not call message + ;; directly. The minor-mode message "Menu-bar mode disabled" comes + ;; after this function returns, overwriting any message we do here. + (when (and (interactive-p) (not menu-bar-mode)) + (run-with-idle-timer 0 nil 'message + "Menu-bar mode disabled. Use M-x menu-bar-mode to make the menu bar appear.")) menu-bar-mode) (provide 'menu-bar) diff --git a/lisp/startup.el b/lisp/startup.el index e4310533647..095ef413b38 100644 --- a/lisp/startup.el +++ b/lisp/startup.el @@ -807,7 +807,7 @@ or `CVS', and any subdirectory that contains a file named `.nosearch'." (unless (or noninteractive (and (memq window-system '(x w32)) (<= (frame-parameter nil 'menu-bar-lines) 0))) - (menu-bar-mode t)) + (menu-bar-mode 1)) ;; If frame was created with a tool bar, switch tool-bar-mode on. (unless (or noninteractive -- 2.39.2