changeset 111528:611ab8607dce

Fix background-color setting in initial frame (Bug#7373). * lisp/frame.el (frame-notice-user-settings): Don't clobber other user-set parameters when calling face-set-after-frame-default in response to background-color parameter (Bug#7373).
author Chong Yidong <cyd@stupidchicken.com>
date Sat, 13 Nov 2010 13:34:02 -0500
parents e48ae521359f
children 589830c3f4cb
files lisp/ChangeLog lisp/frame.el
diffstat 2 files changed, 34 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Sat Nov 13 15:35:44 2010 +0200
+++ b/lisp/ChangeLog	Sat Nov 13 13:34:02 2010 -0500
@@ -1,3 +1,9 @@
+2010-11-13  Chong Yidong  <cyd@stupidchicken.com>
+
+	* frame.el (frame-notice-user-settings): Don't clobber other
+	user-set parameters when calling face-set-after-frame-default in
+	response to background-color parameter (Bug#7373).
+
 2010-11-13  Eli Zaretskii  <eliz@gnu.org>
 
 	* international/characters.el (glyphless-char-display-control):
--- a/lisp/frame.el	Sat Nov 13 15:35:44 2010 +0200
+++ b/lisp/frame.el	Sat Nov 13 13:34:02 2010 -0500
@@ -296,22 +296,19 @@
 	       (null frame-initial-frame))
       ;; This case happens when we don't have a window system, and
       ;; also for MS-DOS frames.
-      (let ((parms (frame-parameters frame-initial-frame)))
+      (let ((parms (frame-parameters)))
 	;; Don't change the frame names.
 	(setq parms (delq (assq 'name parms) parms))
 	;; Can't modify the minibuffer parameter, so don't try.
 	(setq parms (delq (assq 'minibuffer parms) parms))
-	(modify-frame-parameters nil
-				 (if (null initial-window-system)
-				     (append initial-frame-alist
-					     window-system-frame-alist
-					     default-frame-alist
-					     parms
-					     nil)
-				   ;; initial-frame-alist and
-				   ;; default-frame-alist were already
-				   ;; applied in pc-win.el.
-				   parms))
+	(modify-frame-parameters
+	 nil
+	 (if initial-window-system
+	     parms
+	   ;; initial-frame-alist and default-frame-alist were already
+	   ;; applied in pc-win.el.
+	   (append initial-frame-alist window-system-frame-alist
+		   default-frame-alist parms nil)))
 	(if (null initial-window-system) ;; MS-DOS does this differently in pc-win.el
 	    (let ((newparms (frame-parameters))
 		  (frame (selected-frame)))
@@ -512,25 +509,28 @@
 	  ;; it is undesirable to specify the parm again
           ;; once the user has seen the frame and been able to alter it
 	  ;; manually.
-	  (while tail
-	    (let (newval oldval)
-	      (setq oldval (assq (car (car tail))
-				 frame-initial-frame-alist))
-	      (setq newval (cdr (assq (car (car tail)) allparms)))
+	  (let (newval oldval)
+	    (dolist (entry tail)
+	      (setq oldval (assq (car entry) frame-initial-frame-alist))
+	      (setq newval (cdr (assq (car entry) allparms)))
 	      (or (and oldval (eq (cdr oldval) newval))
 		  (setq newparms
-			(cons (cons (car (car tail)) newval) newparms))))
-	    (setq tail (cdr tail)))
+			(cons (cons (car entry) newval) newparms)))))
 	  (setq newparms (nreverse newparms))
-	  (modify-frame-parameters frame-initial-frame
-				   newparms)
-	  ;; If we changed the background color,
-	  ;; we need to update the background-mode parameter
-	  ;; and maybe some faces too.
-	  (when (assq 'background-color newparms)
-	    (unless (assq 'background-mode newparms)
-	      (frame-set-background-mode frame-initial-frame))
-	    (face-set-after-frame-default frame-initial-frame)))))
+
+	  (let ((new-bg (assq 'background-color newparms)))
+	    ;; If the `background-color' parameter is changed, apply
+	    ;; it first, then make sure that the `background-mode'
+	    ;; parameter and other faces are updated, before applying
+	    ;; the other parameters.
+	    (when new-bg
+	      (modify-frame-parameters frame-initial-frame
+				       (list new-bg))
+	      (unless (assq 'background-mode newparms)
+		(frame-set-background-mode frame-initial-frame))
+	      (face-set-after-frame-default frame-initial-frame)
+	      (setq newparms (delq new-bg newparms)))
+	    (modify-frame-parameters frame-initial-frame newparms)))))
 
     ;; Restore the original buffer.
     (set-buffer old-buffer)