From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Tim Ruffing Newsgroups: gmane.emacs.bugs Subject: bug#44950: 28.0.50; 24-bit colors not used in terminal with emacsclient Date: Mon, 31 May 2021 18:45:38 +0200 Message-ID: References: <83wnre27wa.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3855"; mail-complaints-to="usenet@ciao.gmane.io" Cc: tastytea@tastytea.de, 44950@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon May 31 18:46:44 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lnl3s-0000o7-By for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 31 May 2021 18:46:44 +0200 Original-Received: from localhost ([::1]:47980 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lnl3r-00066Q-6D for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 31 May 2021 12:46:43 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51162) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lnl3C-00065X-9U for bug-gnu-emacs@gnu.org; Mon, 31 May 2021 12:46:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:51411) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lnl3C-0004Hf-1H for bug-gnu-emacs@gnu.org; Mon, 31 May 2021 12:46:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lnl3B-0007TX-VW for bug-gnu-emacs@gnu.org; Mon, 31 May 2021 12:46:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Tim Ruffing Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 31 May 2021 16:46:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 44950 X-GNU-PR-Package: emacs Original-Received: via spool by 44950-submit@debbugs.gnu.org id=B44950.162247955228719 (code B ref 44950); Mon, 31 May 2021 16:46:01 +0000 Original-Received: (at 44950) by debbugs.gnu.org; 31 May 2021 16:45:52 +0000 Original-Received: from localhost ([127.0.0.1]:34724 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lnl31-0007T7-Qu for submit@debbugs.gnu.org; Mon, 31 May 2021 12:45:52 -0400 Original-Received: from mout-p-101.mailbox.org ([80.241.56.151]:50058) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lnl2z-0007Ss-C7 for 44950@debbugs.gnu.org; Mon, 31 May 2021 12:45:50 -0400 Original-Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-101.mailbox.org (Postfix) with ESMTPS id 4Fv1Pg0PY8zQj2L; Mon, 31 May 2021 18:45:43 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=timruffing.de; s=MBO0001; t=1622479540; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bjG1NzvOBm1JDdmiTRYi6zzAZAtftgJKBDCrmFh3WVw=; b=KQfpHcJBrIsl3UB1yVkKyPEMlbHcyLEiXSj9xD4AOTH0faFSApupHPqri9J1l80F+UVwLA tbyCIUVcm66HrHdhXXlWrnt8nJl6Mv0kfAxrBihrTNwQkWdiSJ1Ep89+8oOGIxcPVv/vOm xzDEXGhfLczd8RNb+eaMbBNk26DUnevY3f78rn7MA3sZNRbiGGoY1yFlLCuOLfN6wAzYIH YSF4h15MWa456xKf1QtoeFhFNyGYFXDIHQ8d18iNq9Hha1KQahWLv5MCBnjbnk+WIPcwhO SrQswwANUISIufmqVY4K0C5Vp+DiV7QSWuAk8E54iSEd0stXOvH8aln/o+xgcQ== Original-Received: from smtp1.mailbox.org ([80.241.60.240]) by spamfilter04.heinlein-hosting.de (spamfilter04.heinlein-hosting.de [80.241.56.122]) (amavisd-new, port 10030) with ESMTP id zAQqQtYmyQP5; Mon, 31 May 2021 18:45:39 +0200 (CEST) In-Reply-To: <83wnre27wa.fsf@gnu.org> X-Rspamd-Score: -6.75 / 15.00 / 15.00 X-Rspamd-Queue-Id: B4C341894 X-Rspamd-UID: 746ff7 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:207714 Archived-At: For context: I'm coming from  https://github.com/kovidgoyal/kitty/issues/1141#issuecomment-851289392 where the maintainer of kitty told me that they may be able to add a kludge on their side but rather prefer to have it fixed on the emacs side... And yeah, I understand both positions, noone wants to have ugly code but I think someone needs to add it and emacs user would prefer from this (not only in kitty but also in the rather common tmux). But let me give you some more context. I think when emacs was changed to support the RGB flag, it was believed that this is the right ("standard") way to do it. And this may be true if you ask ncurses but apparently the maintainer hasn't been exactly helpful in the past [1]. The thing is that kitty had "RGB" in the terminfo but removed it again and I think they're right. The way it's designed is just awful: RGB is mutually exclusive with 256 color mode, so if you have RGB applications like emacs and other applications that only support 256 colors (which exist out there), you need to set TERM depending on which application you run. That's certainly not the idea of terminfo but apparently this is how ncurses thinks RGB should be used and that's why the ship with all the "-direct" terminfos [2]. But if the user needs to set TERM anyway, what's the point of terminfos? So I can understand but I think the entire situation is just a big mess and at this point some pragmatic solution is the best way forward... By the way, it's interesting to see what others do. neovim's code in fact has quirks for all the terminals [3]. Then "tc" sounds like the easier option, and it's certainly a smaller hack than an env variable. [1] https://lists.gnu.org/archive/html/bug-ncurses/2016-08/msg00036.html [2] https://github.com/kovidgoyal/kitty/issues/1141#issuecomment-851289392 [3] https://github.com/neovim/neovim/blob/c46d9814619cee5183ea08989352d72fb9aaea5a/src/nvim/tui/tui.c#L1618 On Mon, 2021-05-31 at 19:19 +0300, Eli Zaretskii wrote: > > From: Tim Ruffing > > Cc: 44950@debbugs.gnu.org > > Date: Mon, 31 May 2021 16:06:55 +0200 > > > > 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 . > > That sounds like a kludge to me, of which we already have quite a few > there (the COLORTERM thing is already a kludge).  Do we really have to > add one more trick, just to paper over bad terminfo data?  Why don't > these terminals get their act together and fix their terminfo?