GNU bug report logs - #80135
[PATCH 1/1] Add minimal dark and light theme

Previous Next

Package: emacs;

Reported by: Philip Kaludercic <philipk <at> posteo.net>

Date: Mon, 5 Jan 2026 14:41:02 UTC

Severity: normal

Tags: patch

To reply to this bug, email your comments to 80135 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#80135; Package emacs. (Mon, 05 Jan 2026 14:41:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Philip Kaludercic <philipk <at> posteo.net>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 05 Jan 2026 14:41:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Philip Kaludercic <philipk <at> posteo.net>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH 1/1] Add minimal dark and light theme
Date: Mon, 05 Jan 2026 14:39:59 +0000
[Message part 1 (text/plain, inline)]
I have had a hack in my init.el to invert the default appearance if I
needed a dark theme.  The patch I propose below adds two minimal themes,
one a "pseudo" theme standing in for the default appearance and the
other that just inverts the foreground and background color of the
default face.  The reason I added both themes is so that it is easy to
switch between the two with 'theme-choose-variant':

[0001-Add-minimal-dark-and-light-theme.patch (text/x-diff, attachment)]
[Message part 3 (text/plain, inline)]
For the dark theme to work, I had to extend a few default faces with
finer specifications to respect the background.

Some points of discussion:

1. In 'dark-theme', would it be preferable to replace the :foreground
and :background attributes with a single :inverse?

2. Instead of adding the "pseudo" light theme, should we hard-code
'theme-choose-variant' to switch to 'dark' if no themes are enabled?
Alternatively, we can also add a user option for the command to fall
back on, which would default to the 'dark' theme?

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#80135; Package emacs. (Mon, 05 Jan 2026 18:49:04 GMT) Full text and rfc822 format available.

Message #8 received at 80135 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Philip Kaludercic <philipk <at> posteo.net>
Cc: 80135 <at> debbugs.gnu.org
Subject: Re: bug#80135: [PATCH 1/1] Add minimal dark and light theme
Date: Mon, 05 Jan 2026 20:47:54 +0200
> I have had a hack in my init.el to invert the default appearance if I
> needed a dark theme.  The patch I propose below adds two minimal themes,
> one a "pseudo" theme standing in for the default appearance and the
> other that just inverts the foreground and background color of the
> default face.  The reason I added both themes is so that it is easy to
> switch between the two with 'theme-choose-variant':

Good idea.  Only white on grey20 is hardly legible.
Also the logic is reversed: in light mode the current tab is lighter,
and other tabs are darker.  However, in dark mode the active/inactive mode line
color logic remains the same, but for tabs it's the opposite.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#80135; Package emacs. (Mon, 05 Jan 2026 21:11:02 GMT) Full text and rfc822 format available.

Message #11 received at 80135 <at> debbugs.gnu.org (full text, mbox):

From: Philip Kaludercic <philipk <at> posteo.net>
To: Juri Linkov <juri <at> linkov.net>
Cc: 80135 <at> debbugs.gnu.org
Subject: Re: bug#80135: [PATCH 1/1] Add minimal dark and light theme
Date: Mon, 05 Jan 2026 21:09:55 +0000
Juri Linkov <juri <at> linkov.net> writes:

>> I have had a hack in my init.el to invert the default appearance if I
>> needed a dark theme.  The patch I propose below adds two minimal themes,
>> one a "pseudo" theme standing in for the default appearance and the
>> other that just inverts the foreground and background color of the
>> default face.  The reason I added both themes is so that it is easy to
>> switch between the two with 'theme-choose-variant':
>
> Good idea.  Only white on grey20 is hardly legible.

Really?  It seems perfectly readable in my case.

> Also the logic is reversed: in light mode the current tab is lighter,
> and other tabs are darker.  However, in dark mode the active/inactive mode line
> color logic remains the same, but for tabs it's the opposite.

Oh you are right, I think I matched the header-line and tab-line colors,
but that is not the case in "light mode".  Will fix.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#80135; Package emacs. (Tue, 06 Jan 2026 07:27:02 GMT) Full text and rfc822 format available.

Message #14 received at 80135 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Philip Kaludercic <philipk <at> posteo.net>
Cc: 80135 <at> debbugs.gnu.org
Subject: Re: bug#80135: [PATCH 1/1] Add minimal dark and light theme
Date: Tue, 06 Jan 2026 09:25:27 +0200
[Message part 1 (text/plain, inline)]
>> Good idea.  Only white on grey20 is hardly legible.
>
> Really?  It seems perfectly readable in my case.

Here is the screenshot:

[dark.png (image/png, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#80135; Package emacs. (Wed, 07 Jan 2026 22:24:02 GMT) Full text and rfc822 format available.

Message #17 received at 80135 <at> debbugs.gnu.org (full text, mbox):

From: Sean Whitton <spwhitton <at> spwhitton.name>
To: Philip Kaludercic <philipk <at> posteo.net>
Cc: 80135 <at> debbugs.gnu.org, Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#80135: [PATCH 1/1] Add minimal dark and light theme
Date: Wed, 07 Jan 2026 22:23:34 +0000
Hello,

Philip Kaludercic [05/Jan  2:39pm GMT] wrote:
> I have had a hack in my init.el to invert the default appearance if I
> needed a dark theme.  The patch I propose below adds two minimal themes,
> one a "pseudo" theme standing in for the default appearance and the
> other that just inverts the foreground and background color of the
> default face.  The reason I added both themes is so that it is easy to
> switch between the two with 'theme-choose-variant':
>
>
>
> For the dark theme to work, I had to extend a few default faces with
> finer specifications to respect the background.
>
> Some points of discussion:
>
> 1. In 'dark-theme', would it be preferable to replace the :foreground
> and :background attributes with a single :inverse?
>
> 2. Instead of adding the "pseudo" light theme, should we hard-code
> 'theme-choose-variant' to switch to 'dark' if no themes are enabled?
> Alternatively, we can also add a user option for the command to fall
> back on, which would default to the 'dark' theme?

I'm not an expert on themes, but this does not seem right, to me.

We already have

- a system that tries to decide whether a text frame is on a light or a
  dark background;
  see frame-set-background-mode and frame--current-background-mode

- a way for faces to vary how they appear in different frames, depending
  on whether those frames have dark or light backgrounds.

These mechanisms are already tightly integrated with each other and with
the rest of Emacs.  By contrast, your new pseudo-themes would not be
integrated with either of these things.  I am a bit suspicious that it
is right to add a third, unrelated mechanism connected with frame
backgrounds.

Could you perhaps explain the concrete problem you want to solve?  Is it
about having a way to forcefully toggle the current frame between Emacs
considering it to have a dark or a light background?  Maybe we should
just have a command to do that?

-- 
Sean Whitton




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#80135; Package emacs. (Thu, 08 Jan 2026 18:44:02 GMT) Full text and rfc822 format available.

Message #20 received at 80135 <at> debbugs.gnu.org (full text, mbox):

From: Philip Kaludercic <philipk <at> posteo.net>
To: Sean Whitton <spwhitton <at> spwhitton.name>
Cc: 80135 <at> debbugs.gnu.org, Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#80135: [PATCH 1/1] Add minimal dark and light theme
Date: Thu, 08 Jan 2026 18:42:52 +0000
Sean Whitton <spwhitton <at> spwhitton.name> writes:

> Hello,
>
> Philip Kaludercic [05/Jan  2:39pm GMT] wrote:
>> I have had a hack in my init.el to invert the default appearance if I
>> needed a dark theme.  The patch I propose below adds two minimal themes,
>> one a "pseudo" theme standing in for the default appearance and the
>> other that just inverts the foreground and background color of the
>> default face.  The reason I added both themes is so that it is easy to
>> switch between the two with 'theme-choose-variant':
>>
>>
>>
>> For the dark theme to work, I had to extend a few default faces with
>> finer specifications to respect the background.
>>
>> Some points of discussion:
>>
>> 1. In 'dark-theme', would it be preferable to replace the :foreground
>> and :background attributes with a single :inverse?
>>
>> 2. Instead of adding the "pseudo" light theme, should we hard-code
>> 'theme-choose-variant' to switch to 'dark' if no themes are enabled?
>> Alternatively, we can also add a user option for the command to fall
>> back on, which would default to the 'dark' theme?
>
> I'm not an expert on themes, but this does not seem right, to me.
>
> We already have
>
> - a system that tries to decide whether a text frame is on a light or a
>   dark background;
>   see frame-set-background-mode and frame--current-background-mode
>
> - a way for faces to vary how they appear in different frames, depending
>   on whether those frames have dark or light backgrounds.

I was not familiar with `frame-set-background-mode', but I also do not
see how this helps directly?  Do you know how to use it to replicate the
effect of "dark-theme.el"?

> These mechanisms are already tightly integrated with each other and with
> the rest of Emacs.  By contrast, your new pseudo-themes would not be
> integrated with either of these things.  I am a bit suspicious that it
> is right to add a third, unrelated mechanism connected with frame
> backgrounds.
>
> Could you perhaps explain the concrete problem you want to solve?  Is it
> about having a way to forcefully toggle the current frame between Emacs
> considering it to have a dark or a light background?  Maybe we should
> just have a command to do that?

One goal is to get `toggle-theme' to work even if no theme has been
enabled.  We could add a new command for that, but I think that my
suggestion above under "2." along with just a "dark" theme could be a
viable solution that wouldn't introduce an inconsistency between
toggling between the default and the dark theme and toggling between all
other dark/light variations in a theme family.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#80135; Package emacs. (Sun, 11 Jan 2026 16:03:02 GMT) Full text and rfc822 format available.

Message #23 received at 80135 <at> debbugs.gnu.org (full text, mbox):

From: Sean Whitton <spwhitton <at> spwhitton.name>
To: Philip Kaludercic <philipk <at> posteo.net>
Cc: 80135 <at> debbugs.gnu.org, Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#80135: [PATCH 1/1] Add minimal dark and light theme
Date: Sun, 11 Jan 2026 16:02:22 +0000
Hello,

Philip Kaludercic [08/Jan  6:42pm GMT] wrote:

>> We already have
>>
>> - a system that tries to decide whether a text frame is on a light or a
>>   dark background;
>>   see frame-set-background-mode and frame--current-background-mode
>>
>> - a way for faces to vary how they appear in different frames, depending
>>   on whether those frames have dark or light backgrounds.
>
> I was not familiar with `frame-set-background-mode', but I also do not
> see how this helps directly?  Do you know how to use it to replicate the
> effect of "dark-theme.el"?

Like this, which works for text frames:

    (let ((f (selected-frame)))
      (set-terminal-parameter f 'background-mode 'dark) ; or 'light
      (frame-set-background-mode t))

For graphical frames it partially works: all the faces except the
default face switch their colours appropriately, the inactive mode line
changes, the scroll bars change (active mode line seems not to).

But it seems like we could (and if so, should) fix that mechanism to
work properly for graphical frames, instead of introducing a new one.
I think by adding the black-on-white and white-on-black to the
definition of the default face?

A toggling command would also want to update the default frame
parameters so that new frames also come up with the correct
background-mode.

>> These mechanisms are already tightly integrated with each other and with
>> the rest of Emacs.  By contrast, your new pseudo-themes would not be
>> integrated with either of these things.  I am a bit suspicious that it
>> is right to add a third, unrelated mechanism connected with frame
>> backgrounds.
>>
>> Could you perhaps explain the concrete problem you want to solve?  Is it
>> about having a way to forcefully toggle the current frame between Emacs
>> considering it to have a dark or a light background?  Maybe we should
>> just have a command to do that?
>
> One goal is to get `toggle-theme' to work even if no theme has been
> enabled.  We could add a new command for that, but I think that my
> suggestion above under "2." along with just a "dark" theme could be a
> viable solution that wouldn't introduce an inconsistency between
> toggling between the default and the dark theme and toggling between all
> other dark/light variations in a theme family.

ISTM that 'toggle-theme' should *not* work if no theme has been enabled.

Our themes are not mutually exclusive, in that you can have more than
one active at once, and they layer on top of each other.
This is important because it's how custom.el works (its 'user' theme).

Therefore the default appearance of Emacs is not in itself a theme,
because it has the special status of being a layer you can't remove from
the stack (because there has to be one such layer).

'toggle-theme' is defined to "Switch from the current theme to one of
its variants."  But when there is no theme, there are, definitionally,
no variants.

-- 
Sean Whitton




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#80135; Package emacs. (Sun, 11 Jan 2026 16:04:03 GMT) Full text and rfc822 format available.

Message #26 received at 80135 <at> debbugs.gnu.org (full text, mbox):

From: Sean Whitton <spwhitton <at> spwhitton.name>
To: Philip Kaludercic <philipk <at> posteo.net>
Cc: 80135 <at> debbugs.gnu.org, Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#80135: [PATCH 1/1] Add minimal dark and light theme
Date: Sun, 11 Jan 2026 16:03:14 +0000
Hello,

Sean Whitton [11/Jan  4:02pm GMT] wrote:
> A toggling command would also want to update the default frame
> parameters so that new frames also come up with the correct
> background-mode.

(This last step isn't necessary, I think, because other frames on the
same X/Wayland display are already on the same terminal.)

-- 
Sean Whitton




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#80135; Package emacs. (Sun, 11 Jan 2026 19:04:01 GMT) Full text and rfc822 format available.

Message #29 received at 80135 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Philip Kaludercic <philipk <at> posteo.net>
Cc: 80135 <at> debbugs.gnu.org
Subject: Re: bug#80135: [PATCH 1/1] Add minimal dark and light theme
Date: Sun, 11 Jan 2026 21:01:40 +0200
> Here is the screenshot:

I have no opinion whether `emacs -rv` is sufficient, or adding
an explicit dark theme would be easier for users to toggle.

So I just fixed the tab-bar/tab-line faces.




This bug report was last modified today.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.