From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Gerd =?UTF-8?Q?M=C3=B6llmann?= Newsgroups: gmane.emacs.bugs Subject: bug#74252: 31.0.50; multi-tty;: init_tty using getenv for COLORTERM Date: Fri, 08 Nov 2024 09:23:59 +0100 Message-ID: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3572"; mail-complaints-to="usenet@ciao.gmane.io" To: 74252@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Nov 08 09:25:17 2024 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 1t9KIv-0000ol-N4 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 08 Nov 2024 09:25:17 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t9KIj-0008Sd-2H; Fri, 08 Nov 2024 03:25:05 -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 1t9KIg-0008RG-QD for bug-gnu-emacs@gnu.org; Fri, 08 Nov 2024 03:25:03 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t9KIg-0006OZ-Bp for bug-gnu-emacs@gnu.org; Fri, 08 Nov 2024 03:25:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:From:To:Subject; bh=vF5iYU9EUzZWThtJ8BWpC9lKTaOzQ3ssNc0qIbmT7Rw=; b=CddoTZSiG77/faR3RtJr/q1vf9TTSXSj3Kd4KcKi0/yFhC1GD6BgOPv76vVpU4BSzMzqhY7vQj2j2ie1W38guDz9ItxNGFQ7vWEak6Cl7TzY/qixEhPRHjGmSdS8VSY9h62Ffg8H1KwTwiiwg3cHJ2Rd26eRHhowfHMNJyrzKNKsFb0vmyiB9xwos2i9ER/gL5eG1k0JsjpOLD9h15SyerGk5Asw+DQZ5w32ggC6VKvaDAb3YMYoW18YBymeEAAGIe+diFAk4qfS5AQmr4giht+B+JRk+CCqeswEIBzEhSLfkc8uinQ8GafOeanflFeTDmLY7o+jSf//KrxvYn5ueA==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1t9KIf-0000Ry-UX for bug-gnu-emacs@gnu.org; Fri, 08 Nov 2024 03:25:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Gerd =?UTF-8?Q?M=C3=B6llmann?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 08 Nov 2024 08:25:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 74252 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.17310542491665 (code B ref -1); Fri, 08 Nov 2024 08:25:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 8 Nov 2024 08:24:09 +0000 Original-Received: from localhost ([127.0.0.1]:51013 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t9KHp-0000Qn-8j for submit@debbugs.gnu.org; Fri, 08 Nov 2024 03:24:09 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:35310) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t9KHm-0000Qe-3U for submit@debbugs.gnu.org; Fri, 08 Nov 2024 03:24:07 -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 1t9KHl-0008Or-J6 for bug-gnu-emacs@gnu.org; Fri, 08 Nov 2024 03:24:05 -0500 Original-Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t9KHj-0006ME-U9 for bug-gnu-emacs@gnu.org; Fri, 08 Nov 2024 03:24:05 -0500 Original-Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-37d4d1b48f3so1067327f8f.1 for ; Fri, 08 Nov 2024 00:24:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731054242; x=1731659042; darn=gnu.org; h=mime-version:message-id:date:subject:to:from:from:to:cc:subject :date:message-id:reply-to; bh=vF5iYU9EUzZWThtJ8BWpC9lKTaOzQ3ssNc0qIbmT7Rw=; b=gnfcDvnISFnF0Wn38mi03iDi0WK0I1jquYDJkSnGyZCFcWE0+XMVe1S5pyBqoX3qf1 Lgm1IAnmz0mLxvs9Pol7mv1Ye+LuwoSv2ybLun5U5gxgzlR74sOOt+RAPAP1mrv7d16s ycgYXXSXjbwfHPS4W6KEUZnTLd9EjqVJjz52lfATqopq007T85+3y7Woo2R3Ia4DQ/sY LH1JEQhhh21hEUIOlXvjBoUPtKB8H0sOJ/iOsuYy+u8NnTlrNsaF8pRIqooNKQPkMoQN ikDp/AOVD6bttnLk0LxErv0DYv8Ii7hmrH82TF18DeUXMUbSFCuo6pzKy18Bb1pFrM2Z 72DA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731054242; x=1731659042; h=mime-version:message-id:date:subject:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=vF5iYU9EUzZWThtJ8BWpC9lKTaOzQ3ssNc0qIbmT7Rw=; b=iEup4AwCw0y8HBnlsi41NMYk9SIMJ89sWC1a9tF1Axbd+w9Lhmv7+a8ThCQdxvDnJK eVgIc7TGtHKI0HiBhgf0EVYrt01Go4Z3e7jyySpCfsVE4EzExGJ6dADRyVf1JmE3xNyR oK/gXNnb1uJI0JGMZOV2w32UhhMdUHbmHNXxahVMptOtjEHIlDwd50Mykb0dRA+MVhlZ seRNiVJ3QRDfuTPqwZopwKE3ZuHtWiaxJSSFjhB07UIsgENqksz5A5O52j9eZrElRiDf j/rM9T0n/9QM95TawJnd5B9TUAGOy8GL8hdnf3i3DoXSzb0nBqftBnWr0bsNg/RimxRt qq4A== X-Gm-Message-State: AOJu0YxryiHA/LvwhjRMp7vPbNrwZPJ8SgD+oZLplhKuIfIxLOjHDpoB lHyZv8t7/8kXsbrXnfs+p1MX4AVa0lY9+Q8q4wQc7MZdDEocZRjZtiMK7w== X-Google-Smtp-Source: AGHT+IGTxDZqmTIIqssRt/lyGYEkbU1bbSqezxyySheBUbNrt2uJXythxCOW5tF3g7Yv99do/OpoMA== X-Received: by 2002:a5d:6da2:0:b0:37d:377d:c7b0 with SMTP id ffacd0b85a97d-381f182edacmr1635491f8f.18.1731054241479; Fri, 08 Nov 2024 00:24:01 -0800 (PST) Original-Received: from pro2 (pd9e36fc2.dip0.t-ipconnect.de. [217.227.111.194]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-432b054b3fesm54222575e9.17.2024.11.08.00.24.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Nov 2024 00:24:00 -0800 (PST) Received-SPF: pass client-ip=2a00:1450:4864:20::42b; envelope-from=gerd.moellmann@gmail.com; helo=mail-wr1-x42b.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: 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:295056 Archived-At: Just copying parts of messages from emacs-devel. ---------- I was playing with multi-tty today, and I encountered strange behavior. 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=xterm-256color, COLORTERM=truecolor), then emacsclient --tty in a Terminal window (TERM=xterm, COLORTERM not set) => The Emacs frame in the Terminal window is obviously confused about the terminal's color capabilties. ---------- 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 'env))) 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. ---------- > They do, but then they change the settings in the per-terminal > tty_display_info, no? Or am I misreading init_tty? Certainly > > TERM=xterm-mono emacsclient -tty > > gives me a mono emacs. 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. 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.