Subject: bug#64740: 28.2; screen interacts badly with TERMCOLOR=truecolor

From: Eli Zaretskii <[email-masked]>
Date: Thu, 20 Jul 2023 13:19:25 +0300

> From: Francesco Potortì <[email-masked]>
> Date: Thu, 20 Jul 2023 09:55:43 +0200
> 
> emacs -nw -Q  behaves strangely under Screen when COLORTERM=truecolor
> 
> If I unset COLORTERM  the problem goes away
> 
> The problem does not happen outside of Screen.
> 
> The problem is that Emacs starts as if it could not use the terminal's reverse capability, that is, the mode line is made of hyphens rather than filled characters.  Also, all text is dimmed.  Moreover, the text stays dimmed in the shell after exiting Emacs.
> 
> I do not know if this is an Emacs problem, a Screen problem or else, and unfortunately at the moment I have no time to dig deeper, hope someone else can.

It's a Screen problem, see etc/PROBLEMS and bug#62237.  Since you only
have Emacs 28, I reproduce the PROBLEMS entry below:

  ** Colors are not available or messed up on TTY frames inside 'screen'.

  This can happen if you have COLORTERM=truecolor defined in the
  environment when Emacs starts, but your version of 'screen' doesn't
  actually support 24-bit true colors.

  The COLORTERM environment variable is supposed to be set to the value
  "truecolor" only if the terminal used by Emacs actually supports true
  color.  Emacs does not have any means of verifying that this support
  is available, it takes the fact that the variable is defined to this
  value as an indication that true color support is, in fact, available,
  and uses color setting commands that COLORTERM=truecolor presumes,
  bypassing the usual Terminfo capabilities related to colors.

  Some text-mode terminals, such as GNOME Terminal, are known to set
  this environment variable, supposedly to announce their own support
  for true color; however the setting is then inherited by any other
  terminal emulators started from such a terminal, even though those
  other terminal emulators might not themselves support true color using
  the same commands as Emacs uses when it sees COLORTERM=truecolor.

  The solution is to either upgrade to a newer version of 'screen'
  (version 5.x or later reportedly supports true color), or to unset the
  COLORTERM variable before starting 'screen', and let Emacs use the
  color support provided by the terminal emulator as defined in the
  Terminfo database.