unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Tim Ruffing <crypto@timruffing.de>
To: Eli Zaretskii <eliz@gnu.org>, tastytea <tastytea@tastytea.de>
Cc: 44950@debbugs.gnu.org
Subject: bug#44950: 28.0.50; 24-bit colors not used in terminal with emacsclient
Date: Mon, 31 May 2021 16:06:55 +0200	[thread overview]
Message-ID: <b69eea4ee690640ebf7c2f00dfebb5085108d1e8.camel@timruffing.de> (raw)
In-Reply-To: <20201129165641.00308157@ventiloplattform.tastytea.de>

[-- Attachment #1: Type: text/plain, Size: 759 bytes --]

I think what tastytea is saying is that when emacs checks the env
variable COLORTERM, it uses the environment of the server and not the
one of emacsclient. And yes, that's just a bug. emacsclient should read
that variable and pass it to server. But this requires new code because
it breaks with the pattern of using terminfo to detect term support.

So the terminfo detection is currently more reliable. Would you be
willing to accept something like the attached patch? This will improve
detection without relying on COLORTERM, which should make the situation
already much better. Tc is in the terminfo of many terminals, see
https://gist.github.com/XVilka/8346728 .

If yes, I can send an improved patch (with added explanations to
doc/misc/efaq.texi).

Tim

[-- Attachment #2: 0001-Support-Tc-terminfo-flag-forg-24-bit-color-support-i.patch --]
[-- Type: text/x-patch, Size: 1340 bytes --]

From 8c5851a96447cd06f41d2983390e699461870072 Mon Sep 17 00:00:00 2001
From: Tim Ruffing <crypto@timruffing.de>
Date: Mon, 31 May 2021 15:38:19 +0200
Subject: [PATCH] Support Tc terminfo flag forg 24-bit color support in
 terminal

---
 src/term.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/term.c b/src/term.c
index c995a4499c..fdcc116b69 100644
--- a/src/term.c
+++ b/src/term.c
@@ -4157,10 +4157,12 @@ init_tty (const char *name, const char *terminal_type, bool must_succeed)
 	       could return 32767.  */
 	    tty->TN_max_colors = 16777216;
 	  }
-	/* Fall back to xterm+direct (semicolon version) if requested
-	   by the COLORTERM environment variable.  */
-	else if ((bg = getenv("COLORTERM")) != NULL
-		 && strcasecmp(bg, "truecolor") == 0)
+	/* Fall back to xterm+direct (semicolon version) if Tc is set
+	   (de-facto standard introduced by tmux) or if	requested by
+	   the COLORTERM environment variable.  */
+	else if (tigetflag("Tc")
+		 || ((bg = getenv("COLORTERM")) != NULL
+		     && strcasecmp(bg, "truecolor") == 0))
 	  {
 	    tty->TS_set_foreground = "\033[%?%p1%{8}%<%t3%p1%d%e38;2;%p1%{65536}%/%d;%p1%{256}%/%{255}%&%d;%p1%{255}%&%d%;m";
 	    tty->TS_set_background = "\033[%?%p1%{8}%<%t4%p1%d%e48;2;%p1%{65536}%/%d;%p1%{256}%/%{255}%&%d;%p1%{255}%&%d%;m";
-- 
2.31.1


  parent reply	other threads:[~2021-05-31 14:06 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-29 15:56 bug#44950: 28.0.50; 24-bit colors not used in terminal with emacsclient tastytea via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-11-29 18:47 ` Eli Zaretskii
2020-11-29 20:01   ` tastytea via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-05-31 14:06 ` Tim Ruffing [this message]
2021-05-31 16:19   ` Eli Zaretskii
2021-05-31 16:45     ` Tim Ruffing
2021-05-31 17:04       ` Eli Zaretskii
2021-06-06 10:36   ` Lars Ingebrigtsen
2021-07-21 12:05     ` Lars Ingebrigtsen
2021-07-21 18:39       ` Tim Ruffing
2021-10-11 12:34         ` Stefan Kangas
2021-11-11  6:15         ` Lars Ingebrigtsen
2021-11-12 19:44           ` Tim Ruffing
2021-11-13 15:10             ` Eli Zaretskii
2021-11-16 16:42               ` Tim Ruffing
2021-11-16 17:22                 ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b69eea4ee690640ebf7c2f00dfebb5085108d1e8.camel@timruffing.de \
    --to=crypto@timruffing.de \
    --cc=44950@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=tastytea@tastytea.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).