From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.help Subject: Re: Getting `load-theme` to work in `-batch` mode? Date: Wed, 14 Feb 2024 17:34:24 +0200 Message-ID: <86a5o3xdof.fsf@gnu.org> References: <86le7nxfb4.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21073"; mail-complaints-to="usenet@ciao.gmane.io" Cc: help-gnu-emacs@gnu.org To: Konstantin Kharlamov Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Wed Feb 14 16:35:04 2024 Return-path: Envelope-to: geh-help-gnu-emacs@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 1raHHo-0005As-Df for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 14 Feb 2024 16:35:00 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raHHJ-000561-M2; Wed, 14 Feb 2024 10:34:29 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raHHH-00051s-V8 for help-gnu-emacs@gnu.org; Wed, 14 Feb 2024 10:34:27 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raHHH-0004PP-In; Wed, 14 Feb 2024 10:34:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=aVnaIeuDgpFMe44GLfmy/1KNNuFrjryYDvBTvwUrxck=; b=ELMpleL1z0rELg/Nw10w 6wqNyhlne1M8ECzmKGnghyBrlZXB9htcVVfxnazs0nk/0OccuJtIKnXhTSNP/Y0cgZUANkGmapPjh vWNFmKhBKTt/hn1ssBTjB4IJrAkDjjJGycRpgQUv7DXoSDLMRYEKY3B4XRejhpDsb4uMkr2Z9oQOO 5YGisCpgtPHyXWZwMLII0px1OPqhBlrwoGDnQtncJtjMmfmbLeG4ihS7G0ydt7xYIqiVfRq5ACsot noN37m5xbrFAi1oKRvKrkonkuNIeN8K4kemd0dI0yAztC6QGd75WzXPb1kXT4wMr2kK7SFJ/0dq9o OOEVbOYzsVdk0g==; In-Reply-To: (message from Konstantin Kharlamov on Wed, 14 Feb 2024 18:14:05 +0300) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:145945 Archived-At: > From: Konstantin Kharlamov > Date: Wed, 14 Feb 2024 18:14:05 +0300 > > On Wed, 2024-02-14 at 16:59 +0200, Eli Zaretskii wrote: > > > From: Konstantin Kharlamov > > > Date: Tue, 13 Feb 2024 18:06:43 +0300 > > > > > > I'm writing tests for color-identifiers-mode, and as part of the > > > testing I need to check it reacts correctly to theme being changed. > > > > > > There are already tests that work fine so far, but it turns out > > > `load- > > > theme` doesn't work as is. More specifically, even though `(load- > > > theme > > > 'adwait)` works fine, but background/foreground have no color: > > > > > >    emacs -batch --eval "(progn (load-theme 'adwaita) (print (face- > > >    attribute 'default :foreground)) (print (face-attribute 'default > > >    :background)))" > > >    > > >    "unspecified-fg" > > >    > > >    "unspecified-bg" > > > > Those are the default colors of a text-mode frame. > > > > > I asked on Emacs stackexchange¹ and I was hinted that it's because > > > batch-mode doesn't initialize a windowing system. > > > > That's right. > > > > > But is there no function I can call to make `load-theme` assign > > > colors > > > as in non-batch mode? > > > > What do you mean by that?  The GUI colors are not necessarily > > supported by text-mode frames.  So what do you expect from the above? > > > > Btw, if you look at adwaita-theme.el, you will see that it doesn't > > bother supporting frames which support less than 89 colors, and the > > default frame used by batch sessions certainly doesn't support such a > > large number of colors. > > Sorry, I just don't know details about frames and themes > implementation, so it's hard for me to judge for myself… > > Anyway, my usecase is: `color-identifiers-mode` chooses colors by > taking into account the background and foreground colors (to make sure > colors have good visibility). And it have an "advice" for `change- > theme` that regenerates the colors if theme is changed. > > I just wanted to add a test to CI that makes sure that after `change- > theme` is called (via `load-theme` in this case) the colors are > regenerated as expected. But such test wouldn't work if calling `load- > theme` doesn't influence fg/bg colors (i.e. because colors remain > "unspecified"). > > So what's the correct course of action do you think here? Run your test not in batch mode? Tests that involve display can only be run in batch mode if you are very lucky.