changeset 109147:783986775ee8

Set default-frame-alist, if necessary, in menu/tool-bar-mode. * menu-bar.el (menu-bar-mode): * tool-bar.el (tool-bar-mode): Replace default-frame-alist element if it has been set.
author Chong Yidong <cyd@stupidchicken.com>
date Mon, 05 Jul 2010 13:54:13 -0400
parents 6b22e0739484
children 7347cd00da53 773dc1704474
files lisp/ChangeLog lisp/menu-bar.el lisp/tool-bar.el
diffstat 3 files changed, 24 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Mon Jul 05 12:42:50 2010 -0400
+++ b/lisp/ChangeLog	Mon Jul 05 13:54:13 2010 -0400
@@ -1,5 +1,9 @@
 2010-07-05  Chong Yidong  <cyd@stupidchicken.com>
 
+	* menu-bar.el (menu-bar-mode):
+	* tool-bar.el (tool-bar-mode): Replace default-frame-alist element
+	if it has been set.
+
 	* mouse.el (mouse-drag-track): Call mouse-start-end to handle
 	word/line selection (Bug#6565).
 
--- a/lisp/menu-bar.el	Mon Jul 05 12:42:50 2010 -0400
+++ b/lisp/menu-bar.el	Mon Jul 05 13:54:13 2010 -0400
@@ -1937,15 +1937,20 @@
   ;; Turn the menu-bars on all frames on or off.
   (let ((val (if menu-bar-mode 1 0)))
     (dolist (frame (frame-list))
-      (set-frame-parameter frame 'menu-bar-lines val)))
-
+      (set-frame-parameter frame 'menu-bar-lines val))
+    ;; If the user has given `default-frame-alist' a `menu-bar-lines'
+    ;; parameter, replace it.
+    (if (assq 'menu-bar-lines default-frame-alist)
+	(setq default-frame-alist
+	      (cons (cons 'menu-bar-lines val)
+		    (assq-delete-all 'menu-bar-lines
+				     default-frame-alist)))))
   ;; 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 (called-interactively-p 'interactive) (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)
+			 "Menu-bar mode disabled.  Use M-x menu-bar-mode to make the menu bar appear.")))
 
 (defun toggle-menu-bar-mode-from-frame (&optional arg)
   "Toggle menu bar on or off, based on the status of the current frame.
--- a/lisp/tool-bar.el	Mon Jul 05 12:42:50 2010 -0400
+++ b/lisp/tool-bar.el	Mon Jul 05 13:54:13 2010 -0400
@@ -52,13 +52,19 @@
   :global t
   :group 'mouse
   :group 'frames
-  ;; Make tool-bar even if terminal is non-graphical (Bug#1754).
   (let ((val (if tool-bar-mode 1 0)))
     (dolist (frame (frame-list))
-      (set-frame-parameter frame 'tool-bar-lines val)))
-  (when tool-bar-mode
-    (if (= 1 (length (default-value 'tool-bar-map))) ; not yet setup
-	(tool-bar-setup))))
+      (set-frame-parameter frame 'tool-bar-lines val))
+    ;; If the user has given `default-frame-alist' a `tool-bar-lines'
+    ;; parameter, replace it.
+    (if (assq 'tool-bar-lines default-frame-alist)
+	(setq default-frame-alist
+	      (cons (cons 'tool-bar-lines val)
+		    (assq-delete-all 'tool-bar-lines
+				     default-frame-alist)))))
+  (and tool-bar-mode
+       (= 1 (length (default-value 'tool-bar-map))) ; not yet setup
+       (tool-bar-setup)))
 
 ;;;###autoload
 ;; Used in the Show/Hide menu, to have the toggle reflect the current frame.