GNU bug report logs - #51297
28.0.60; [PATCH] Update termcap/terminfo to indicate 16-color support

Previous Next

Package: emacs;

Reported by: Jim Porter <jporterbugs <at> gmail.com>

Date: Tue, 19 Oct 2021 23:50:02 UTC

Severity: normal

Tags: moreinfo, patch

Found in version 28.0.60

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 51297 in the body.
You can then email your comments to 51297 AT debbugs.gnu.org in the normal way.

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#51297; Package emacs. (Tue, 19 Oct 2021 23:50:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Jim Porter <jporterbugs <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 19 Oct 2021 23:50:02 GMT) Full text and rfc822 format available.

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

From: Jim Porter <jporterbugs <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 28.0.60; [PATCH] Update termcap/terminfo to indicate 16-color support
Date: Tue, 19 Oct 2021 16:49:53 -0700
[Message part 1 (text/plain, inline)]
In bug#50179, I added support for bright ANSI colors, but neglected to 
update the termcap/terminfo settings to indicate this. Attached is a 
patch to do so. Note that it doesn't need to be merged into Emacs 29, 
since bug#50806 already fixed this when adding 256/24-bit color support.
[0001-Update-termcap-terminfo-to-indicate-16-color-support.patch (text/plain, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#51297; Package emacs. (Wed, 20 Oct 2021 08:26:02 GMT) Full text and rfc822 format available.

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

From: miha <at> kamnitnik.top
To: Jim Porter <jporterbugs <at> gmail.com>, 51297 <at> debbugs.gnu.org
Subject: Re: bug#51297: 28.0.60; [PATCH] Update termcap/terminfo to indicate
 16-color support
Date: Wed, 20 Oct 2021 10:29:27 +0200
[Message part 1 (text/plain, inline)]
Jim Porter <jporterbugs <at> gmail.com> writes:

> In bug#50179, I added support for bright ANSI colors, but neglected to 
> update the termcap/terminfo settings to indicate this. Attached is a 
> patch to do so. Note that it doesn't need to be merged into Emacs 29, 
> since bug#50806 already fixed this when adding 256/24-bit color support.

> -	colors#8,
> +	colors#16,

True, we now do support 16 colors, but the setab and setaf capnames have
to be adjusted as well.  For setaf, for example, the first 8 colors are
specified with sequences \e[30m - \e[37m, and the next 8 colors are
specified with sequences \e[90m - \e[97m.  There is a "gap".  See the
attached patch, which adjusts setab and setaf.

> @@ -1584,7 +1584,7 @@ term-termcap-format
>  :so=\\E[7m:se=\\E[m:us=\\E[4m:ue=\\E[m:md=\\E[1m:mr=\\E[7m:me=\\E[m\
>  :UP=\\E[%%dA:DO=\\E[%%dB:LE=\\E[%%dD:RI=\\E[%%dC\
>  :kl=\\EOD:kd=\\EOB:kr=\\EOC:ku=\\EOA:kN=\\E[6~:kP=\\E[5~:@7=\\E[4~:kh=\\E[1~\
> -:mk=\\E[8m:cb=\\E[1K:op=\\E[39;49m:Co#8:pa#64:AB=\\E[4%%dm:AF=\\E[3%%dm:cr=^M\
> +:mk=\\E[8m:cb=\\E[1K:op=\\E[39;49m:Co#16:pa#64:AB=\\E[4%%dm:AF=\\E[3%%dm:cr=^M\
>  :bl=^G:do=^J:le=^H:ta=^I:se=\\E[27m:ue=\\E[24m\
>  :kb=^?:kD=^[[3~:sc=\\E7:rc=\\E8:r1=\\Ec:"
>    ;; : -undefine ic

As for termcap, I don't think there is a way to specify this gap.  I
think it's best to just leave this unchanged.  In bug#50806, I did
adjust the number of colors in termcap, but I could do it because I
added a way to specify colors without the gap
(with \e[38;2;0m - \e[38;2;15m for setaf).

In conclusion, I think we should update the terminfo, changing colors,
setab and setaf, and leave term.el unchanged.  Patch attached.
[0001-Update-terminfo-to-indicate-16-color-support.patch (text/x-patch, inline)]
From 158e84e403017d2bfc73d9dabeb44bb3ba48f4dc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Miha=20Rihtar=C5=A1i=C4=8D?= <miha <at> kamnitnik.top>
Date: Wed, 20 Oct 2021 10:24:19 +0200
Subject: [PATCH] Update terminfo to indicate 16-color support.

* etc/e/eterm-color.ti: Indicate 16-color support.
Do not merge to master.
---
 etc/e/eterm-color    | Bin 1179 -> 1227 bytes
 etc/e/eterm-color.ti |   6 +++---
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/etc/e/eterm-color b/etc/e/eterm-color
index bd3f5003ae620db49b89a2c1387b0ba1c836f4f1..06e8dc01ed6c136c3b8a32ae42eed81745efd1fb 100644
GIT binary patch
delta 109
zcmbQud76`3iqV~c9|$uUD<^UnG74<0z0AZIxH*tnkI~0owZKrd+M-s~MzzEk#7<F7
awS<Z30(sWC4ARl6$jVHh$_x$A)Bym^7aLdr

delta 61
zcmX <at> jIh&JPiqV~c9|$uUJtuM(GIDIJz0AaDwK<Skk5Q(;P_^3FpjK5|H6 <at> opI$9OT
JSJzO7Z~?9&4dDO)

diff --git a/etc/e/eterm-color.ti b/etc/e/eterm-color.ti
index a6ef814990..a6ed6d28ab 100644
--- a/etc/e/eterm-color.ti
+++ b/etc/e/eterm-color.ti
@@ -9,7 +9,7 @@ eterm-color|Emacs term.el terminal emulator term-protocol-version 0.96,
 # Any change to this file should be done at the same time with a
 # corresponding change to the TERMCAP environment variable in term.el.
 # Comments in term.el specify where each of these capabilities is implemented.
-	colors#8,
+	colors#16,
 	cols#80,
 	lines#24,
 	pairs#64,
@@ -65,8 +65,8 @@ eterm-color|Emacs term.el terminal emulator term-protocol-version 0.96,
 	rmul=\E[24m,
 	rs1=\Ec,
 	sc=\E7,
-	setab=\E[%p1%{40}%+%dm,
-	setaf=\E[%p1%{30}%+%dm,
+	setab=\E[%?%p1%{8}%<%t4%p1%d%e10%p1%{8}%-%d%;m,
+	setaf=\E[%?%p1%{8}%<%t3%p1%d%e9%p1%{8}%-%d%;m,
 	sgr0=\E[m,
 	smir=\E[4h,
 	smul=\E[4m,
-- 
2.33.0

[signature.asc (application/pgp-signature, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#51297; Package emacs. (Wed, 20 Oct 2021 19:51:02 GMT) Full text and rfc822 format available.

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

From: Jim Porter <jporterbugs <at> gmail.com>
To: miha <at> kamnitnik.top, 51297 <at> debbugs.gnu.org
Subject: Re: bug#51297: 28.0.60; [PATCH] Update termcap/terminfo to indicate
 16-color support
Date: Wed, 20 Oct 2021 12:50:26 -0700
On 10/20/2021 1:29 AM, miha--- via Bug reports for GNU Emacs, the Swiss 
army knife of text editors wrote:
> In conclusion, I think we should update the terminfo, changing colors,
> setab and setaf, and leave term.el unchanged.  Patch attached.

Thanks, this seems reasonable to me. I don't know much about the details 
of terminfo, so I wasn't aware of setab/setaf.

More generally, I do wonder if we should be concerned with making it 
possible to distinguish between different versions of Emacs, since 27, 
28, and 29 all have different capabilities. At least as I understand it, 
If I SSH into a system, having `TERM=eterm-color' isn't enough to know 
whether 8, 16, or 256 colors are supported.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#51297; Package emacs. (Wed, 20 Oct 2021 21:03:03 GMT) Full text and rfc822 format available.

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

From: <miha <at> kamnitnik.top>
To: Jim Porter <jporterbugs <at> gmail.com>, 51297 <at> debbugs.gnu.org
Subject: Re: bug#51297: 28.0.60; [PATCH] Update termcap/terminfo to indicate
 16-color support
Date: Wed, 20 Oct 2021 23:06:39 +0200
[Message part 1 (text/plain, inline)]
Jim Porter <jporterbugs <at> gmail.com> writes:

> On 10/20/2021 1:29 AM, miha--- via Bug reports for GNU Emacs, 
> the Swiss 
> army knife of text editors wrote:
>> In conclusion, I think we should update the terminfo, changing 
>> colors, setab and setaf, and leave term.el unchanged.  Patch 
>> attached.
>
> Thanks, this seems reasonable to me. I don't know much about the 
> details  of terminfo, so I wasn't aware of setab/setaf.
>
> More generally, I do wonder if we should be concerned with 
> making it  possible to distinguish between different versions of 
> Emacs, since 27,  28, and 29 all have different capabilities. At 
> least as I understand it,  If I SSH into a system, having 
> `TERM=eterm-color' isn't enough to know  whether 8, 16, or 256 
> colors are supported.

Yeah, that's a somewhat complicated problem.  I thought about the 
option of having something like 'TERM=eterm-16color' on Emacs-28 
in order to make Emacs-28 and Emacs-27 term.el distinguishable. 
The major downside of this option is that many terminal programs 
simply refuse to start if eterm-16color is not registered in the 
terminfo database (try running
'env TERM=eterm-16color top').  ssh-ing from term.el onto a system 
that rarely updates its terminfo database wouldn't be pleasant at 
all.

That's why I think its best to keep using 'TERM=eterm-color' and 
simply update the terminfo file.  Since all our updates to this 
file are backwards-compatible, there shouldn't be any major 
problems even if the terminfo database on the ssh host isn't up to 
date.  A problem does arise in the opposite case when the terminfo 
database on the host is up to date but the ssh client is term.el 
from Emacs version 27 or older.  TUI programs will think they can 
output sequences that the older term.el doesn't understand, but I 
think that term.el handles unknown sequences quite gracefully by 
simply ignoring them.

After Emacs-28 is released, we should probably talk to the ncurses 
maintainer about updating the eterm-color terminfo file 
distributed with the ncurses package.  From my understanding, the 
option I described in the previous paragraph is also the proffered 
way to update terminfo files in the ncurses package.
[signature.asc (application/pgp-signature, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#51297; Package emacs. (Sat, 30 Oct 2021 15:55:01 GMT) Full text and rfc822 format available.

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

From: Stefan Kangas <stefan <at> marxist.se>
To: miha <at> kamnitnik.top
Cc: Jim Porter <jporterbugs <at> gmail.com>, 51297 <at> debbugs.gnu.org
Subject: Re: bug#51297: 28.0.60; [PATCH] Update termcap/terminfo to indicate
 16-color support
Date: Sat, 30 Oct 2021 08:53:57 -0700
<miha <at> kamnitnik.top> writes:

> That's why I think its best to keep using 'TERM=eterm-color' and simply update
> the terminfo file.  Since all our updates to this file are backwards-compatible,
> there shouldn't be any major problems even if the terminfo database on the ssh
> host isn't up to date.  A problem does arise in the opposite case when the
> terminfo database on the host is up to date but the ssh client is term.el from
> Emacs version 27 or older.  TUI programs will think they can output sequences
> that the older term.el doesn't understand, but I think that term.el handles
> unknown sequences quite gracefully by simply ignoring them.

If they are ignored, I see no problem here.  Someone should perhaps double-check
that this is indeed the case?

> After Emacs-28 is released, we should probably talk to the ncurses maintainer
> about updating the eterm-color terminfo file distributed with the ncurses
> package.  From my understanding, the option I described in the previous
> paragraph is also the proffered way to update terminfo files in the ncurses
> package.

Are there any other terminfo files elsewhere that are worth updating, or
do they generally just base themselves on ncurses?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#51297; Package emacs. (Thu, 04 Nov 2021 23:21:01 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: miha <at> kamnitnik.top
Cc: Jim Porter <jporterbugs <at> gmail.com>, 51297 <at> debbugs.gnu.org
Subject: Re: bug#51297: 28.0.60; [PATCH] Update termcap/terminfo to indicate
 16-color support
Date: Fri, 05 Nov 2021 00:20:06 +0100
miha <at> kamnitnik.top writes:

> In conclusion, I think we should update the terminfo, changing colors,
> setab and setaf, and leave term.el unchanged.  Patch attached.
>
> From 158e84e403017d2bfc73d9dabeb44bb3ba48f4dc Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Miha=20Rihtar=C5=A1i=C4=8D?= <miha <at> kamnitnik.top>
> Date: Wed, 20 Oct 2021 10:24:19 +0200
> Subject: [PATCH] Update terminfo to indicate 16-color support.
>
> * etc/e/eterm-color.ti: Indicate 16-color support.
> Do not merge to master.

I think it's too late to put something like this in emacs-28.  Do I
understand correctly that it's not needed in Emacs 29?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) moreinfo. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Thu, 04 Nov 2021 23:21:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#51297; Package emacs. (Thu, 04 Nov 2021 23:48:01 GMT) Full text and rfc822 format available.

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

From: Jim Porter <jporterbugs <at> gmail.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>, miha <at> kamnitnik.top
Cc: 51297 <at> debbugs.gnu.org
Subject: Re: bug#51297: 28.0.60; [PATCH] Update termcap/terminfo to indicate
 16-color support
Date: Thu, 4 Nov 2021 16:47:39 -0700
On 11/4/2021 4:20 PM, Lars Ingebrigtsen wrote:
> miha <at> kamnitnik.top writes:
> 
>> In conclusion, I think we should update the terminfo, changing colors,
>> setab and setaf, and leave term.el unchanged.  Patch attached.
>>
>>  From 158e84e403017d2bfc73d9dabeb44bb3ba48f4dc Mon Sep 17 00:00:00 2001
>> From: =?UTF-8?q?Miha=20Rihtar=C5=A1i=C4=8D?= <miha <at> kamnitnik.top>
>> Date: Wed, 20 Oct 2021 10:24:19 +0200
>> Subject: [PATCH] Update terminfo to indicate 16-color support.
>>
>> * etc/e/eterm-color.ti: Indicate 16-color support.
>> Do not merge to master.
> 
> I think it's too late to put something like this in emacs-28.  Do I
> understand correctly that it's not needed in Emacs 29?

Correct, there's already a fix for this in Emacs 29 from (I think) 
bug#50806. If it's too late to add this for 28, then I think we can 
close this.

For Emacs 28, the only negative to not merging Miha's patch is that 
users will have to manually update eterm-color (and install it to their 
systems) if they want to be sure their terminfo database correctly 
represents the capabilities in Emacs 28's `term-mode'. That's probably 
not a big deal, and worst-case scenario, some commands might only use 8 
colors instead of 16.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#51297; Package emacs. (Fri, 05 Nov 2021 02:28:01 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Jim Porter <jporterbugs <at> gmail.com>
Cc: 51297 <at> debbugs.gnu.org, miha <at> kamnitnik.top
Subject: Re: bug#51297: 28.0.60; [PATCH] Update termcap/terminfo to indicate
 16-color support
Date: Fri, 05 Nov 2021 03:27:47 +0100
Jim Porter <jporterbugs <at> gmail.com> writes:

> Correct, there's already a fix for this in Emacs 29 from (I think)
> bug#50806. If it's too late to add this for 28, then I think we can
> close this.

OK; closing.

> For Emacs 28, the only negative to not merging Miha's patch is that
> users will have to manually update eterm-color (and install it to
> their systems) if they want to be sure their terminfo database
> correctly represents the capabilities in Emacs 28's
> `term-mode'. That's probably not a big deal, and worst-case scenario,
> some commands might only use 8 colors instead of 16.

Yeah, the repercussions to not applying this are fairly low, but the
unknown effects this may have (on obscure systems) is fairly high, so
it's just too late in the development cycle for emacs-28, in my opinion.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug closed, send any further explanations to 51297 <at> debbugs.gnu.org and Jim Porter <jporterbugs <at> gmail.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Fri, 05 Nov 2021 02:29:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 03 Dec 2021 12:24:13 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 135 days ago.

Previous Next


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