summaryrefslogtreecommitdiff
path: root/lisp/menu-bar.el
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1994-06-25 18:20:30 +0000
committerRichard M. Stallman <rms@gnu.org>1994-06-25 18:20:30 +0000
commit7b7d6615835cfc88447376412384b1adeb1e4571 (patch)
treecacc55335808e5b464b52ddb14224622432b1810 /lisp/menu-bar.el
parent37b2bef6699c39e81f4172f0396bb5d6c60dd528 (diff)
downloademacs-7b7d6615835cfc88447376412384b1adeb1e4571.tar.gz
(menu-bar-mode): Make this a global variable.
(menu-bar-mode): Make variable menu-bar-mode and default-frame-alist consistent.
Diffstat (limited to 'lisp/menu-bar.el')
-rw-r--r--lisp/menu-bar.el59
1 files changed, 32 insertions, 27 deletions
diff --git a/lisp/menu-bar.el b/lisp/menu-bar.el
index 34bf8e7e0cf..923c776dfac 100644
--- a/lisp/menu-bar.el
+++ b/lisp/menu-bar.el
@@ -398,6 +398,8 @@ A large number or nil slows down menu responsiveness.")
;;; mode-name
;;; (or (buffer-file-name) ""))))))
+(defvar menu-bar-mode nil)
+
(defun menu-bar-mode (flag)
"Toggle display of a menu bar on each frame.
This command applies to all frames that exist and frames to be
@@ -406,33 +408,36 @@ With a numeric argument, if the argument is negative,
turn off menu bars; otherwise, turn on menu bars."
(interactive "P")
- ;; Obtain the current setting by looking at default-frame-alist.
- (let ((menu-bar-mode
- (not (zerop (let ((assq (assq 'menu-bar-lines default-frame-alist)))
- (if assq (cdr assq) 0))))))
-
- ;; Tweedle it according to the argument.
- (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))))))
+ ;; 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)))))
(provide 'menu-bar)