Subject: Re: bug#62237: 28.1 or higher: 24-bit true color breaks colours in Emacsen built without X under GNU Screen

From: Sebastian Tennant <[email-masked]>
Date: Fri, 17 Mar 2023 16:20:19 +0000

Hello Eli,

Thanks for your prompt response.

Quoth Eli Zaretskii <[email-masked]>
on Fri, 17 Mar 2023 14:15:34 +0200:
>> From: Sebastian Tennant <[email-masked]>
>> Date: Fri, 17 Mar 2023 09:41:36 +0000
>>
>> Summary: Support for 24-bit true colour, added in Emacs 28.1, breaks
>>          colours in Emacsen built without X support and running under
>>          GNU Screen (v4.08.00).
>> […]
>
> Thanks for the report, but it lacks several crucial details for us
> to investigate the problem.
>
> First, if you can build the latest emacs-29 branch of the Emacs Git
> repository, please try that and tell whether the problem persists or
> have been solved in the meantime.

The photos happen to show an Emacs I built from master a couple of
days ago, i.e. Emacs 30.0.50.  If you'd still like me to test branch
emacs-29, then let me know and I will happily do so.

> […]
>
> [T]he user should _only_ set it if the text-mode terminal actually
> supports true color using the commands Emacs expects to work in that
> case, but Emacs cannot detect that without COLORTERM=truecolor being
> set.  Is that your case?

Nope.  Let me explain.

I've been unable to move beyond 27.2 (on my laptops) for over a year
because of these broken colors.  I didn't file a bug report sooner
because I had no idea what the cause of the prolem was.

Yesterday, I read this entry in etc/NEWS.28:

 ** Emacs can support 24-bit color TTY without terminfo database.
 If your text-mode terminal supports 24-bit true color, but your system
 lacks the terminfo database, you can instruct Emacs to support 24-bit
 true color by setting 'COLORTERM=truecolor' in the environment.  This is
 useful on systems such as FreeBSD which ships only with "etc/termcap".

This lead me to investigate whether or not COLORTERM was set in my
environment.  I'm running Debian bullseye and terminfo is installed
but, nevertheless, GNOME Terminal sets COLORTERM=truecolor by default.
I discovered that if I unset COLORTERM, colors start working again!
(In Emacsen I've built without X, running in a screen).

To be clear, the colors are only broken in Emacsen running in a
screen.  Outside of screen, the colors are fine.

> Finally, please show the display produced by "M-x
> list-colors-display" in both cases: when COLORTERM=truecolor is and
> isn't set.  It is important for us to know how many colors Emacs
> uses in each situation.

I've updated the screenshots to show the output of
#'list-colors-display.  Here are the links again, for your
convenience.

 https://download.sebyte.me/misc/truecolor-active.png
 https://download.sebyte.me/misc/truecolor-inactive.png

Seb