From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Matt Armstrong Newsgroups: gmane.emacs.devel Subject: Re: Detecting changes between dark and light mode on Mac OS Date: Tue, 23 Mar 2021 10:49:12 -0700 Message-ID: <87eeg5hiav.fsf@rfc20.org> References: <345983B0-C75E-46FF-870C-5FBD3D7381B9@nonceword.org> <87h7l5j8hg.fsf@gnus.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="6687"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Lars Ingebrigtsen , Daphne Preston-Kendal , Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Mar 23 19:42:46 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lOlzK-0001eA-B9 for ged-emacs-devel@m.gmane-mx.org; Tue, 23 Mar 2021 19:42:46 +0100 Original-Received: from localhost ([::1]:56146 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOlzJ-0006AD-BU for ged-emacs-devel@m.gmane-mx.org; Tue, 23 Mar 2021 14:42:45 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44886) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOl9j-0002n4-BF for emacs-devel@gnu.org; Tue, 23 Mar 2021 13:49:30 -0400 Original-Received: from relay6-d.mail.gandi.net ([217.70.183.198]:58199) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOl9g-0007Z9-17 for emacs-devel@gnu.org; Tue, 23 Mar 2021 13:49:27 -0400 X-Originating-IP: 24.113.169.116 Original-Received: from mdeb (24-113-169-116.wavecable.com [24.113.169.116]) (Authenticated sender: matt@rfc20.org) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id 27503C000A; Tue, 23 Mar 2021 17:49:16 +0000 (UTC) Original-Received: from matt by mdeb with local (Exim 4.94) (envelope-from ) id 1lOl9U-000HfG-P0; Tue, 23 Mar 2021 10:49:12 -0700 In-Reply-To: <87h7l5j8hg.fsf@gnus.org> Received-SPF: pass client-ip=217.70.183.198; envelope-from=matt@rfc20.org; helo=relay6-d.mail.gandi.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:266885 Archived-At: Lars Ingebrigtsen 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 (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.