Subject: bug#8454: deftheme, :inherit & overriding existing values

From: Dirk-Jan C. Binnema <[email-masked]>
Date: Fri, 13 May 2011 07:50:05 +0300

Hi,

>>>>> On Mon, 09 May 2011 21:18:25 -0600, Christoph Scholtes ("CS") wrote:

  CS> On 5/8/2011 2:14 PM, Chong Yidong wrote:
  >> OK, I found a bug in the case where defface is called after loading a
  >> theme with settings for that face.  The defface settings were not being
  >> applied; I've checked a fix into the trunk.  However, I'm not sure this
  >> is the issue you are talking about, since this bug was not specific to
  >> the :inherit property.  Could you check if your problem is fixed?
  >> 
  >> One possible source of confusion, which may apply to Dirk-Jan's report,
  >> is that :inherit only tells Emacs to consult the parent face if a face
  >> attribute is unspecified.  If the attribute is specified, it overrides
  >> the inheritance.  So if your Custom theme want to "cancel out", say, any
  >> existing foreground attribute setting, you need something like
  >> 
  >> '(froob ((t (:foreground unspecified :inherit parent-face))))

  CS> This did not fix it for me.

  CS> I think Dirk-Jan and I have the same issue, though, which is the
  CS> behavior of :inherit.

Yes -- in fact, before this change, the theme would look as expected if I
loaded it before - say - Wanderlust. However, with this change, that does not
work either anymore.
  
  CS> One example from my custom theme:

  CS>  '(erc-default-face ((t (:inherit default))))

  CS> This is supposed to inherit from

  CS>  '(default ((t (:background "#3f3f3f" :foreground "#dcdccc"))))

  CS> but it does not work.

  CS> This is probably related to what you describe above, but I don't
  CS> really understand it. foregound in erc-default-face is unspecified,
  CS> right? Should the inherit get the attributes from default or not?

  CS> I figured out a way to make my custom theme work, though. Loading it
  CS> through customize does not work, but if I open the theme file and eval
  CS> the buffer, it works and erc shows the my custom faces. Maybe this
  CS> helps to troubleshoot the problem?

Yes, indeed, that is what I do too now:
  
(defun zenburn()
  (interactive)
  (load-theme 'zenburn)
  (load-library "~/.emacs.d/elisp/themes/zenburn-theme.el"))

In general, it might make sense to first go back to 'factory settings' before
changing the theme, as it's quite unlikely that theme2 always overrides
everything from theme1 -- e.g. zenburn redefines hundreds of faces.
  
Best wishes,
Dirk.

-- 
Dirk-Jan C. Binnema                  Helsinki, Finland
e:[email-masked]           w:www.djcbsoftware.nl
pgp: D09C E664 897D 7D39 5047 A178 E96A C7A1 017D DA3C