Commit 7b7d6615 authored by Richard M. Stallman's avatar Richard M. Stallman
Browse files

(menu-bar-mode): Make this a global variable.

(menu-bar-mode): Make variable menu-bar-mode and default-frame-alist
consistent.
parent 37b2bef6
...@@ -398,6 +398,8 @@ A large number or nil slows down menu responsiveness.") ...@@ -398,6 +398,8 @@ A large number or nil slows down menu responsiveness.")
;;; mode-name ;;; mode-name
;;; (or (buffer-file-name) "")))))) ;;; (or (buffer-file-name) ""))))))
(defvar menu-bar-mode nil)
(defun menu-bar-mode (flag) (defun menu-bar-mode (flag)
"Toggle display of a menu bar on each frame. "Toggle display of a menu bar on each frame.
This command applies to all frames that exist and frames to be 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, ...@@ -406,33 +408,36 @@ With a numeric argument, if the argument is negative,
turn off menu bars; otherwise, turn on menu bars." turn off menu bars; otherwise, turn on menu bars."
(interactive "P") (interactive "P")
;; Obtain the current setting by looking at default-frame-alist. ;; Make menu-bar-mode and default-frame-alist consistent.
(let ((menu-bar-mode (let ((default (assq 'menu-bar-lines default-frame-alist)))
(not (zerop (let ((assq (assq 'menu-bar-lines default-frame-alist))) (if default
(if assq (cdr assq) 0)))))) (setq menu-bar-mode (not (eq (cdr default) 0)))
(setq default-frame-alist
;; Tweedle it according to the argument. (cons (cons 'menu-bar-lines (if menu-bar-mode 1 0))
(setq menu-bar-mode (if (null flag) (not menu-bar-mode) default-frame-alist))))
(> (prefix-numeric-value flag) 0)))
;; Toggle or set the mode, according to FLAG.
;; Apply it to default-frame-alist. (setq menu-bar-mode (if (null flag) (not menu-bar-mode)
(let ((parameter (assq 'menu-bar-lines default-frame-alist))) (> (prefix-numeric-value flag) 0)))
(if (consp parameter)
(setcdr parameter (if menu-bar-mode 1 0)) ;; Apply it to default-frame-alist.
(setq default-frame-alist (let ((parameter (assq 'menu-bar-lines default-frame-alist)))
(cons (cons 'menu-bar-lines (if menu-bar-mode 1 0)) (if (consp parameter)
default-frame-alist)))) (setcdr parameter (if menu-bar-mode 1 0))
(setq default-frame-alist
;; Apply it to existing frames. (cons (cons 'menu-bar-lines (if menu-bar-mode 1 0))
(let ((frames (frame-list))) default-frame-alist))))
(while frames
(let ((height (cdr (assq 'height (frame-parameters (car frames)))))) ;; Apply it to existing frames.
(modify-frame-parameters (car frames) (let ((frames (frame-list)))
(list (cons 'menu-bar-lines (while frames
(if menu-bar-mode 1 0)))) (let ((height (cdr (assq 'height (frame-parameters (car frames))))))
(modify-frame-parameters (car frames) (modify-frame-parameters (car frames)
(list (cons 'height height)))) (list (cons 'menu-bar-lines
(setq frames (cdr frames)))))) (if menu-bar-mode 1 0))))
(modify-frame-parameters (car frames)
(list (cons 'height height))))
(setq frames (cdr frames)))))
(provide 'menu-bar) (provide 'menu-bar)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment