Subject: bug#47806: 28.0.50; `make-frame` frame should probably clone the `environment` parameter into the new frame

From: Thibault Polge <[email-masked]>
Date: Thu, 15 Apr 2021 21:47:01 +0200

> Doesn't the 'display' parameter fit the bill?

Not on Wayland, I'm afraid.  I believe all the XWayland instances will
have the same value for `display`, which may be a non-usable value.  I'm
also not sure that we can go from `display` to the Wayland server.  (As
an example, in my case, what I actually need is `SWAYSOCK`).

> How do we know whether a particular frame should or shouldn't have the
> 'environment' frame parameter?  When the frame is created by the
> server on behalf of a client, we know.  But for a random
> frame-creation function, how do we know?

That's a tricky question.  In my understanding, it makes sense in an
ancestor/child relationship: if the ancestor of FRAME has some distinct
set of environment variables, we copy them to the new frame.  I'm not
too clear on the various execution contexts of Emacs Lisp, but couldn't
something similar to:

(when (called-interactively-p) ; I assume this implies there's a frame
                               ; this is being called "from".
  (set-frame-property TARGET 'environment
                      (frame-property SOURCE 'environment')))

To clarify all my assumptions, I understand that the `environment`
property exists because frames of the same daemon or server can appear
in very different environments, like multiple X or Wayland servers,
terminals, remote sessions, and so on. If my understanding is correct,
it makes sense that further frames share these values, even when not
created directly from `emacsclient`.

Best regards,
Thibault