all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Gerd Möllmann" <gerd.moellmann@gmail.com>
To: Robert Pluim <rpluim@gmail.com>
Cc: Eli Zaretskii <eliz@gnu.org>,  emacs-devel@gnu.org
Subject: Re: Multi-tty
Date: Thu, 07 Nov 2024 12:38:42 +0100	[thread overview]
Message-ID: <m21pznxohp.fsf@gmail.com> (raw)
In-Reply-To: <87r07nl2gf.fsf@gmail.com> (Robert Pluim's message of "Thu, 07 Nov 2024 12:15:28 +0100")

Robert Pluim <rpluim@gmail.com> writes:

>>>>>> On Thu, 07 Nov 2024 12:58:33 +0200, Eli Zaretskii <eliz@gnu.org> said:
>
>     >> From: Gerd Möllmann <gerd.moellmann@gmail.com>
>     >> Date: Thu, 07 Nov 2024 10:53:09 +0100
>     >>
>     >> 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.)
>     >>
>     >> Is something like that worth writing a bug report? Or maybe it's already
>     >> known, although I can't find anything in Debbugs?
>
>     Eli> This is simply not supported, never was.  The environment variables
>     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=xterm-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 '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.

Anyway - not so important. Just saying :-).



  reply	other threads:[~2024-11-07 11:38 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-07  9:53 Multi-tty Gerd Möllmann
2024-11-07 10:58 ` Multi-tty Eli Zaretskii
2024-11-07 11:15   ` Multi-tty Robert Pluim
2024-11-07 11:38     ` Gerd Möllmann [this message]
2024-11-07 11:47     ` Multi-tty Eli Zaretskii
2024-11-08  8:18     ` Multi-tty Gerd Möllmann
2024-11-08  8:28       ` Multi-tty Gerd Möllmann
2024-11-08  8:50       ` Multi-tty Eli Zaretskii
2024-11-08  9:16         ` Multi-tty Gerd Möllmann
2024-11-08  9:42           ` Multi-tty Gerd Möllmann
2024-11-08 10:17             ` Multi-tty Robert Pluim
2024-11-08 11:09               ` Multi-tty Gerd Möllmann
2024-11-08 11:49                 ` Multi-tty Eli Zaretskii
2024-11-08 11:43             ` Multi-tty Eli Zaretskii
2024-11-08 11:41           ` Multi-tty Eli Zaretskii
2024-11-08 11:49             ` Multi-tty Gerd Möllmann
2024-11-08 12:03               ` Multi-tty Eli Zaretskii
2024-11-08 12:25                 ` Multi-tty Gerd Möllmann
2024-11-08 12:11               ` Multi-tty Robert Pluim
2024-11-08 12:29                 ` Multi-tty Gerd Möllmann
2024-11-08 13:53               ` Multi-tty Stefan Monnier
2024-11-08 13:55                 ` Multi-tty Eli Zaretskii
2024-11-08 14:05                 ` Multi-tty Gerd Möllmann
2024-11-08 14:11                   ` Multi-tty Gerd Möllmann
2024-11-08 15:42                     ` Multi-tty Yuri Khan
2024-11-08 13:55             ` Multi-tty Stefan Monnier
2024-11-08 14:24               ` Multi-tty Robert Pluim

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

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

  git send-email \
    --in-reply-to=m21pznxohp.fsf@gmail.com \
    --to=gerd.moellmann@gmail.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=rpluim@gmail.com \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.