Subject: Re: bug#9982: Theme faces wrongly applied after background changes.

From: Chong Yidong <[email-masked]>
Date: Sun, 29 Jan 2012 22:14:57 +0800

I've committed a patch to trunk that should fix the immediate problem.
The reason this bug triggered under XFCE is that XFCE sends Emacs a
`font-render' config event, and a font-setting-change-default-font bug
caused the default face to be modified even with font-use-system-font
nil.

This patch doesn't address the broader problem, noted in my previous
message: when font-use-system-font is non-nil, the way
font-setting-change-default-font uses custom-push-theme will likely
interefere with the user's own Custom settings and/or Custom themes.

I think that instead of using custom-push-theme,
font-setting-change-default-font should set a `font' frame parameter in
window-system-default-frame-alist.  Something like the following (needs
testing---I don't have Gconf libs installed at the moment).

Jan, WDYT?

=== modified file 'lisp/dynamic-setting.el'
*** lisp/dynamic-setting.el	2012-01-29 13:55:09 +0000
--- lisp/dynamic-setting.el	2012-01-29 14:09:40 +0000
***************
*** 75,86 ****
  
        ;; Set for future frames.
        (when set-font
! 	;; FIXME: this is not going to play well with Custom themes.
! 	(set-face-attribute 'default t :font new-font)
! 	(let ((spec (list (list t (face-attr-construct 'default)))))
! 	  (put 'default 'customized-face spec)
! 	  (custom-push-theme 'theme-face 'default 'user 'set spec)
! 	  (put 'default 'face-modified nil))))))
  
  (defun dynamic-setting-handle-config-changed-event (event)
    "Handle config-changed-event on the display in EVENT.
--- 75,88 ----
  
        ;; Set for future frames.
        (when set-font
! 	(let* ((ws (window-system))
! 	       (alist (assq ws window-system-default-frame-alist)))
! 	  (setq window-system-default-frame-alist
! 		(delq alist window-system-default-frame-alist))
! 	  (setq alist (cdr alist))
! 	  (setq alist (cons (cons 'font new-font)
! 			    (delq 'font alist)))
! 	  (push (cons ws alist) window-system-default-frame-alist))))))
  
  (defun dynamic-setting-handle-config-changed-event (event)
    "Handle config-changed-event on the display in EVENT.