Subject: bug#69598: 29.2; colour support based on $TERM value not terminfo database

From: [email-masked]
Date: Thu, 07 Mar 2024 19:59:17 +0000

Eli Zaretskii writes:
> > From: [email-masked]
> > cc: [email-masked], [email-masked]
> > Comments: In-reply-to Eli Zaretskii <[email-masked]>
> >    message dated "Thu, 07 Mar 2024 19:47:05 +0200."
> > Date: Thu, 07 Mar 2024 18:31:20 +0000
> > 
> > Eli Zaretskii writes:
> > > So I guess you will need to step with a debugger through the code in
> > > term.c which discovers and initializes the color-related capabilities,
> > 
> > If there's something you would like me to look for then I can but
> > I am highly sceptical of the idea that it is isolated to something
> > unique about my computers here.
>
> I think there might be a misunderstanding.  What meant was to see what
> happens in the function init_tty in this part of it:
>
>
>   #ifdef TERMINFO
> 	{
>         ... // calls to terminfo database requests
> 	}
>   #endif

I understand.

I haven't stepped through that piece of code in an emacs binary but
modulo terminfo bugs (which I'm going to assume for now aren't
happening) but you can see from it that it looks up strings in the
database and records the result. Unless emacs has done anything
unusual to load that database (very unlikely) it will 100% return
the strings in the terminfo entry it's directed to look at.

So it certainly (although I have not tried it) is not a problem in
that piece of code.

> By contrast, it sounds like you are only talking about a terminfo
> entry that redirects to another entry.

Yes, the problem can be isolated to creating a new terminfo entry
and using it.

But the problem is not with the terminfo entry itself. The new entry
is an exact duplicate of a working terminfo entry (where working
means that list-colors-display lists 256 named colours) and it only
works if the new entry has a name which begins "xterm-".

This means that somewhere between running the code above which does
detect that 16M colours are available, emacs discards that information
and instead (seems to) decide that support is there based on the
name of the terminal in $TERM.

> No, I cannot try that on the systems to which I have access.  Maybe

Any system with xterm and emacs should be able to reproduce the problem.

I don't know how any other terminal in which emacs detects direct
colour support would perform.

> someone else could, preferably someone who knows more than I do about
> terminfo.

It is almost certainly related to either how terminfo is used, or
because the information terminfo supplies is ignored at a critical
point.

Matthew