emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Detecting changes between dark and light mode on Mac OS


From: Matt Armstrong
Subject: Re: Detecting changes between dark and light mode on Mac OS
Date: Tue, 23 Mar 2021 10:49:12 -0700

Lars Ingebrigtsen <larsi@gnus.org> writes:

> And we should definitely have a feature in Emacs to respond to dark-mode
> changes across the board.  I seem to recall there being some discussion
> about this in the past, but I can't find it now.  Does anybody remember
> where that went?

Lars, were you thinking of this thread?

    Stefan Monnier <monnier@iro.umontreal.ca> (November 20)
    Subject: night-mode?
    To: emacs-devel@gnu.org
    Date: Fri, 20 Nov 2020 16:25:35 -0500

    https://lists.gnu.org/archive/html/emacs-devel/2020-11/msg00912.html

It looks like Stefan stopped working on it, but it looked promising to
me.  He didn't hook it into the system theme change mechanism I point
out below, but that isn't too much of a leap.

It seems to me that this feature isn't a really about "light vs. dark",
but instead it is more about dynamically responding to changes in the
system theme.  Preferably, any change.

I notice that Emacs does have a Lisp level hook for theme changes today,
currently used by GTK.  See
`dynamic-setting-handle-config-changed-event' in dynamic-setting.el, and
the corresponding call to 'kbd_buffer_store_event' in 'style-changed' in
gtkutil.c.  Today, it seems like GTK responds to the system theme in two
ways:

 - changing the GTK Mono font changes Emacs' default font (not in any
   current frames, but in newly created ones)
 - changing the GTK theme changes the faces used for regions (the
   'region' face, etc., by way of 'gtk_selection_bg_color' and
   'gtk_selection_fg_color' colors).

Daphne, I would suggest hooking into dynamic-setting.el, which implement
the above.  That seems much better than adding something that is similar
but different than what is already in place for GTK.

Today, the dynamic-setting.el stuff invalidates font caches on theme
change but doesn't mess with frames at all.  That is all it needs to do
to support the features I list above.  Responding to theme changes more
dynamically, e.g. by changing the whole Emacs theme, is closer to the
things discussed in Stefan's thread linked above.  It should be about as
easy to design this in a way that works the same across GUI toolkits as
it is to do it for ns only.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]