From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?Q?Gerd_M=C3=B6llmann?= Newsgroups: gmane.emacs.devel Subject: Re: Multi-tty Date: Fri, 08 Nov 2024 10:42:58 +0100 Message-ID: References: <8634k3qpie.fsf@gnu.org> <87r07nl2gf.fsf@gmail.com> <868qtup0s5.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38188"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Stefan Monnier , rpluim@gmail.com, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Nov 08 10:43:53 2024 Return-path: Envelope-to: ged-emacs-devel@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 1t9LWz-0009jW-24 for ged-emacs-devel@m.gmane-mx.org; Fri, 08 Nov 2024 10:43:53 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t9LWE-0001E7-1K; Fri, 08 Nov 2024 04:43:06 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t9LWC-0001Dl-KS for emacs-devel@gnu.org; Fri, 08 Nov 2024 04:43:04 -0500 Original-Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t9LWA-000778-Gn; Fri, 08 Nov 2024 04:43:04 -0500 Original-Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-4315baec69eso17421085e9.2; Fri, 08 Nov 2024 01:43:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731058980; x=1731663780; darn=gnu.org; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=X1gilJj4P/L/UFbAvyORYffL8fIMbtkKC+FRjqbBV7w=; b=eKBeO9fbg/0DVAG9JfR9LwayEXWzFs4lL3pFACJd4Dv7cqUwe40mxXlFS6ghFMtike t6RzqCDwI5Q3MCXU+g807D2Sy2FUroPe+kFz6u+6hstTTzNoCwhfs8PEA3AeW7VLbM2x mHHH6Vvh66kwYh0KEvGijlpHiDB7dX1GUrkeO4v2MtSdLisYgW2P+9lFHn2H3oJQzm4V Ls1UETUP1iwjZijeEFgFB8bppupq2neYK9FvlLVjyV59ZyFvkc3QTPb7KozmJL6tlIVt EGORsEibyneOND7dLNvB9SGEvg1zRptDsz6UcqJC23hyrCnLsQ9OAkkg9E76i0eBU010 Y5wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731058980; x=1731663780; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=X1gilJj4P/L/UFbAvyORYffL8fIMbtkKC+FRjqbBV7w=; b=oeEILuHAryq+r+Pc4I5wsCZnvo8Z+Kl2RYO/E7E2Cfj6MLqtQpZGXT+PRRN2RzMfKA se43+6AcDF06QaF7z2UCnfIxhFJdJB9beQVGkrXE4BImFL36mpF2Cj4XnrZQQQJ2xyPx 5eC8pSdMQYW7S6059vmAHabCgOFezgzMkKxmqSsphl1B21dR6b/TNkPGduEbg4c6ko+v Y+Zn6YO7HjGPq0YjDQWsAQv+zyDyN9SBALtvvPmxjfCDwE91lR1YbusfRrUnXvkUAf++ ROcMQ0GXHZsPWtEje5qJ17ZzToAf88gipgvVgMQJlZi+V0qpmb8/sqpu27NerbnVLoYv k3qw== X-Forwarded-Encrypted: i=1; AJvYcCXfJAyKlo9UZ/VdMqtGF4H+S0nAjMUWFEyphoo/yMucur9r3XRnI4Eb/dRnQbQRY3x8TKpdnI4Iwc9ZXg==@gnu.org X-Gm-Message-State: AOJu0YytwKgXz2DtA5m3h5t9yg+c3exxQR7oHtPypeJMotRJgPZsgShX e9BycLBS/rBKsQ6Gb9xhpznWj5PMIFfHs+u/yXmTEJGFVD6kzmkGauYXlw== X-Google-Smtp-Source: AGHT+IGqwTMUdKOq+kn/WESnW8kwj+4lcUmhrMVulmaavEOUsHVjt/PjhyPmQe8V6rN2lSuqyZgVrA== X-Received: by 2002:a05:600c:4f83:b0:42a:a6d2:3270 with SMTP id 5b1f17b1804b1-432b7517aa4mr15179975e9.21.1731058980032; Fri, 08 Nov 2024 01:43:00 -0800 (PST) Original-Received: from pro2 (pd9e36fc2.dip0.t-ipconnect.de. [217.227.111.194]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-432b05e5f77sm58067325e9.43.2024.11.08.01.42.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Nov 2024 01:42:59 -0800 (PST) In-Reply-To: ("Gerd =?utf-8?Q?M=C3=B6llmann=22'?= =?utf-8?Q?s?= message of "Fri, 08 Nov 2024 10:16:05 +0100") Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=gerd.moellmann@gmail.com; helo=mail-wm1-x331.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:325263 Archived-At: Gerd M=C3=B6llmann writes: > Eli Zaretskii writes: > >>> From: Gerd M=C3=B6llmann >>> Cc: Eli Zaretskii , emacs-devel@gnu.org >>> Date: Fri, 08 Nov 2024 09:18:05 +0100 >>>=20 >>> > Eli> This is simply not supported, never was. The environment va= riables >>> > Eli> are not per-terminal, so their effect is global, and the way= we >>> > Eli> process them (and have no other way) is that the environment= variables >>> > Eli> override what terminfo tells us. >>> > >>> > They do, but then they change the settings in the per-terminal >>> > tty_display_info, no? Or am I misreading init_tty? Certainly >>> > >>> > TERM=3Dxterm-mono emacsclient -tty >>> > >>> > gives me a mono emacs. >>>=20 >>> And TERN works because emacsclient picks it up and sends its value as >>> part of the frame creation command to the server. In the server, it is >>> then passed down to make_terminal_frame as a frame parameter which >>> itself uses it for init_tty. >> >> Yes, exactly. But TERM is special in this sense. > > Right. > >>> A pretty easy fix would be to make the environment that we got from >>> emacsclient anyway another frame parameter. Then init_tty wouldn't have >>> to use getenv to get the value of COLORTERM. >> >> I'm not sure this is easy. The general problem of environment >> variables being terminal-specific (_not_ frame-specific!) was >> discussed at length around the introduction of multi-tty into Emacs, >> but AFAIR the decision was eventually to leave that unsolved, due to >> non-trivial difficulties whose details I no longer recall. You may >> wish looking up those discussions, around 2003 to 2007 (look for >> messages posted by K=C3=A1roly L=C5=91rentey, who implemented multi-tty = in >> Emacs). Or maybe Stefan remembers those discussions better. > > I wouldn't try to "fix" the general handling of environment variables, > if that's even possible, which I kind of doubt as you do, I think. I'd > just replace the getenv("COLORTERM") with some lookup of COLORTERM in > what emacsclient sent to the server. And all that's necessary is modified src/term.c @@ -4383,7 +4383,7 @@ init_tty (const char *name, const char *terminal_type= , bool must_succeed) (de-facto standard introduced by tmux) or if requested by the COLORTERM environment variable. */ else if ((tigetflag ("Tc") > 0) - || ((bg =3D getenv ("COLORTERM")) !=3D NULL + || ((bg =3D egetenv ("COLORTERM")) !=3D NULL && strcasecmp (bg, "truecolor") =3D=3D 0)) { tty->TS_set_foreground =3D "\033[%?%p1%{8}%<%t3%p1%d%e38;2;%p1%{65536= }%/%d;%p1%{256}%/%{255}%&%d;%p1%{255}%&%d%;m"; A one character change, isn't that funny :-). It works because server.el puts COLORTERM in process-environment already, in server-with-environment.