From: Max Nikulin <manikulin@gmail.com>
To: emacs-devel@gnu.org
Subject: Re: How to get DISPLAY of emacsclient?
Date: Mon, 28 Nov 2022 22:33:22 +0700 [thread overview]
Message-ID: <tm2kc3$2ov$1@ciao.gmane.io> (raw)
In-Reply-To: <973588ef-d931-47a0-66d3-f8d70d92bd57@gmail.com>
On 28/11/2022 03:36, Jim Porter wrote:
>
> Looking through the emacsclient.c code, I think this is intentional, and
> if you want to do something like this, the above workaround is exactly
> what you're supposed to do:
>
> If the -c option is used (without -t) and no --display argument
> is provided, try $DISPLAY.
> Without the -c option, we used to set 'display' to $DISPLAY by
> default, but this changed the default behavior and is sometimes
> inconvenient. So we force users to use "--display $DISPLAY" if
> they want Emacs to connect to their current display.
Thank you, I have reread emacsclinet code and have realized that I did
not expect such behavior. At first I missed that environment is sent to
server only if -c option is specified and the DISPLAY environment may be
ignored. I believed that display value is always received, but can not
be obtained because it is assigned to a local variable. Actually it is
not sent for simple eval.
It is not stressed in the manual that emacsclient uses the --display
option and the DISPLAY environment in a rather unusual way in comparison
to other X application. I considered --display option as a way to
override $DISPLAY and nothing more.
emacsclient --display "$DISPLAY" --eval ...
behaves as required despite it looks a bit strange. It reuses existing X
connection or creates a new hidden frame. As a result X selection
becomes available without additional function calls.
On 28/11/2022 08:19, Po Lu wrote:
> `x-open-connection' is your friend.
The problem was to determine DISPLAY argument for this function.
Moreover it is not enough and (gui-get-selection) return nil if just
`x-open-connection' is called from emacsclient. In this sense
`server-select-display' is better, but it requires DISPLAY as well.
On 27/11/2022 23:12, Gregory Heytings wrote:
> there is no display involved. If you create an emacsclient process with
> -c or -r, then in Elisp you can get the display on which the frame is
> displayed with (getenv "DISPLAY"), or (cdr (assq 'display
> (frame-parameters))).
I was seeking a way to avoid creation a visible frame and to call a
function that does not work without X connection.
So I should thank Jim again for drawing my attention why the effect of
the --display option is stronger than for the DISPLAY environment. This
option indirectly solves the problem.
next prev parent reply other threads:[~2022-11-28 15:33 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-25 15:17 How to get DISPLAY of emacsclient? Max Nikulin
2022-11-25 16:57 ` Stefan Monnier
2022-11-26 3:36 ` Max Nikulin
2022-11-26 21:33 ` chad
2022-11-27 11:34 ` Max Nikulin
2022-11-27 13:42 ` Gregory Heytings
2022-11-27 14:23 ` Max Nikulin
2022-11-27 14:38 ` Gregory Heytings
2022-11-27 15:26 ` Max Nikulin
2022-11-27 16:12 ` Gregory Heytings
2022-11-28 1:19 ` Po Lu
2022-11-27 20:36 ` Jim Porter
2022-11-28 15:33 ` Max Nikulin [this message]
2022-11-28 17:15 ` Gregory Heytings
2022-11-28 18:19 ` Stefan Monnier
2022-11-29 16:23 ` Max Nikulin
2022-11-30 0:41 ` chad
2022-11-30 2:44 ` Stefan Monnier
2022-11-30 12:47 ` Max Nikulin
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='tm2kc3$2ov$1@ciao.gmane.io' \
--to=manikulin@gmail.com \
--cc=emacs-devel@gnu.org \
/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.