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: Thu, 07 Nov 2024 12:38:42 +0100 Message-ID: References: <8634k3qpie.fsf@gnu.org> <87r07nl2gf.fsf@gmail.com> 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="24206"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Eli Zaretskii , emacs-devel@gnu.org To: Robert Pluim Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Nov 07 12:39:33 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 1t90rM-00064h-MR for ged-emacs-devel@m.gmane-mx.org; Thu, 07 Nov 2024 12:39:32 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t90qh-0006w9-Ex; Thu, 07 Nov 2024 06:38:51 -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 1t90qd-0006vg-CC for emacs-devel@gnu.org; Thu, 07 Nov 2024 06:38:48 -0500 Original-Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t90qb-0007UF-NC; Thu, 07 Nov 2024 06:38:47 -0500 Original-Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-4314c452180so11393375e9.0; Thu, 07 Nov 2024 03:38:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730979523; x=1731584323; 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=dANujINZjWFEZRSBQIPCQJZw2DNYcNuPNdRZafjQ25c=; b=c+fBj2BlGjQcmcAKwnK/wYuoDcRsCgmEEQMr8bawXNPu05Tz+U7Nq5eDy2kAuy0e8B gpBeuBFaXCIRgjZi3V+RfEUG8KzVZDabpPMZy1wLR7SwrfCK236uHc+NqWXaeFE4pBlb I1AY9r1pF8i78Yf6+oOovYvPPETCFrhuJV1GrixxbVuD7cPQKbLbslCUSNKtBYqDVjO0 5UO045or3ufrbXFroeOZKhS2SdQxvjeysgYsahMbqhIFNq2LmJxXyjFSOnOo3lCYVy17 O2cyA3wVraCgtH4fmToz1BXum446l1xzhhTPhQZgUrTRI10qS+XLe4np6NEwtExMqKRU M4Rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730979523; x=1731584323; 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=dANujINZjWFEZRSBQIPCQJZw2DNYcNuPNdRZafjQ25c=; b=to2URRh3mE44U50duDSOErtFbgUcDf9eA0AE8ltGgfOGR7Q1wRcrDJoNQ3bCSqedsp V3oBXd4nBoF3H0HoU97TKD3nEdLNIf/CAj1RPCtm4wM2eksjeCtNptzwLuVX33aH4D3e KYSY0YTAANL2Go9CzU4K1bgI6BQ7emXlRQGejpyr+ldpPbQ7i4RbGrjzTFUGc+ghyWn/ h7k8449cEKoQ0Tt/k2VTLOPL1wA/lyNp7q9rwgoGqKnv+EUiP8QULqt9KPK63zZBIa7V lmUo51PRQb6rWTwbYvTi9WdDMDO4DJRzc1NVpqPybKgbP/X21gVpDpKkk0Vz3Si5K2AM vs8g== X-Forwarded-Encrypted: i=1; AJvYcCW6vybxMuMGw4fCIV6A1rkk6QK3HPfj+owW0Bs4i4IzUrs/kJn3ShGqNUG3KS86YLsLRN00GttX/TBEGg==@gnu.org X-Gm-Message-State: AOJu0Yzb8HPUhIPGhyg2twzWjQKZJEZsF3+VGnIzRyG0SdMY70kaoGZQ POiW+gPijuTJySSr1cmKoMheGvPolOaRuOOs1I1huZEfdTTaJMRKTBs7XQ== X-Google-Smtp-Source: AGHT+IHyaQRkDDjSF9Z5lljrnllEQtWlUZ9QnS+F2L6GA15YSZBzbFbs7skSRWAmNUGMsfaU3dC0Mg== X-Received: by 2002:a5d:47ad:0:b0:37d:4660:c027 with SMTP id ffacd0b85a97d-381ec60c0f4mr2320050f8f.24.1730979523171; Thu, 07 Nov 2024 03:38:43 -0800 (PST) Original-Received: from pro2 (p4fe3a294.dip0.t-ipconnect.de. [79.227.162.148]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381ed9707c8sm1508751f8f.17.2024.11.07.03.38.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Nov 2024 03:38:42 -0800 (PST) In-Reply-To: <87r07nl2gf.fsf@gmail.com> (Robert Pluim's message of "Thu, 07 Nov 2024 12:15:28 +0100") Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=gerd.moellmann@gmail.com; helo=mail-wm1-x329.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:325223 Archived-At: Robert Pluim writes: >>>>>> On Thu, 07 Nov 2024 12:58:33 +0200, Eli Zaretskii sai= d: > > >> From: Gerd M=C3=B6llmann > >> Date: Thu, 07 Nov 2024 10:53:09 +0100 > >> > >> I was playing with multi-tty today, and I encountered strange beha= vior. > >> For example, using 2 terminals that have different capabilties, say > >> different TERM and/or COLORTERM, does not really work. > >> > >> (Informal example: I start an emacs server -nw in iTerm > >> (TERM=3Dxterm-256color, COLORTERM=3Dtruecolor), then emacsclient -= -tty in a > >> Terminal window (TERM=3Dxterm, COLORTERM not set) =3D> The Emacs f= rame in > >> the Terminal window is obviously confused about the terminal's > >> color capabilties.) > >> > >> Is something like that worth writing a bug report? Or maybe it's a= lready > >> known, although I can't find anything in Debbugs? > > Eli> This is simply not supported, never was. The environment variab= les > 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 var= iables > 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. > > Robert Something is fishy here. AFAICS, emacsclient sends its environment to the server before it opens a frame in the server, which is done with server-create-tty-frame. (defun server-create-tty-frame (tty type proc &optional parameters) (unless tty (error "Invalid terminal device")) (unless type (error "Invalid terminal type")) (let ((frame (server-with-environment (process-get proc 'env) '("LANG" "LC_CTYPE" "LC_ALL" ;; For tgetent(3); list according to ncurses(3). "BAUDRATE" "COLUMNS" "ESCDELAY" "HOME" "LINES" "NCURSES_ASSUMED_COLORS" "NCURSES_NO_PADDING" "NCURSES_NO_SETBUF" "TERM" "TERMCAP" "TERMINFO" "TERMINFO_DIRS" "TERMPATH" ;; rxvt wants these "COLORFGBG" "COLORTERM") (server--create-frame ;; Ignore nowait here; we always need to ;; clean up opened ttys when the client dies. nil proc `((window-system . nil) (tty . ,tty) (tty-type . ,type) ,@parameters))))) ;; ttys don't use the `display' parameter, but callproc.c does to set ;; the DISPLAY environment on subprocesses. (set-frame-parameter frame 'display (getenv-internal "DISPLAY" (process-get proc 'en= v))) frame)) The (process-get proc 'env) should contain what emacsclient sent for the enviroment. That apparently doesn't work as expected. Many calls stacks down in make-frame -> ... -> make_terminal_frame -> init_tty Emacs uses C getenv, and that doesn't return what I suspect server-with-environment was intended for. In the case I described, COLORTERM is still truecolor as it was when the server was started. I wonder what is used when Emacs is used as a daemon, hm. Probably getenv returns NULL, at least on macOS/launchd. Anyway - not so important. Just saying :-).