Re: Automatic face re-application with frame-set-background-mode

Antonio Romano <[email protected]>
Newsgroups gmane.emacs.help
Message-ID <[email protected]>
Good morning,

Eli Zaretskii <[email protected]> writes:
> That still signals an error about an unknown theme 'mve'.

Ouch. The summer heat may have got me.

--8<---------------cut here---------------start------------->8---
(custom-theme-set-faces
 'mve ; <--- here, instead of 'mve-theme
 ...
--8<---------------cut here---------------end--------------->8---

Not handy with the theming facilities syntax. But anyway, that's not
relevant anymore. See below.

>
> I think the intended usage is that the background mode is set _before_
> the theme's faces are applied.
>
>> «...»
>
> Again, you have it backwards: AFAIU, the background mode should be
> known _before_ the default faces are determined.
>

I see.  Upon closer inspection of `frame-background-mode':

  The brightness of the background.
  _Set this to the symbol ‘dark’ if your background color is dark, ‘light’ if your background is light,_ ...

So it is intended to be set according to the background _already_ is, not
the desired background. I thought otherwise, and the fact that
`frame-background-mode' had a setter function made me believe that even
more.

>
> It's the other way around, actually: the background color is the
> source for determining the background mode.
>

I was quite confused to your mentioning "background color" until i
figured out it is an actual frame parameter (that is actually also
superseded by the `default' face's background)

>> >> >Are there plans or best practices for making theme faces reactive to
>> >> >background-mode changes without manually reapplying the theme?
>> >
>> > I don't understand the question, please elaborate.
>> 
>> Implying that `frame-background-mode` is a user option (which is
>> debatable), how should one make a theme that accounts for such
>> specification? With what I've seen above, this acts in inconsistent
>> ways, or maybe I'm just abusing or misusing it.
>
> Load the theme after the background mode is set.  Does that behave as
> expected?

Yes, it does, but that seemed to me quite hacky a-la "have you tried
turning the PC off and on"? Also, what about faces that are customized
through M-x customize-face? You can't reload them as easily.

So, once I've defined the light and dark specific faces, when changing
the background mode on an existing frame I must also reload the theme,
right?

But then, what about `frame-set-background-mode` 's docstring?

    _Set up display-dependent faces_ on FRAME.
    Display-dependent faces are those which have different definitions
    according to the ‘background-mode’ and ‘display-type’ frame parameters.

    If optional arg KEEP-FACE-SPECS is non-nil, _don’t recalculate
    face specs_ for the new background mode.


It says it does recalculate faces, but that's not always the case as
we've just said that reloading the theme is needed.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.