emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to get DISPLAY of emacsclient?


From: Gregory Heytings
Subject: Re: How to get DISPLAY of emacsclient?
Date: Mon, 28 Nov 2022 17:15:28 +0000



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.


I still think this is an ill-posed problem, so here are a few additional thoughs, in case you find them useful. There are at least three cases:

1. "emacsclient --eval '(+ 1 1)'" does NOT use a display: it is evaluated in the server process. You can use '(getenv DISPLAY)' there, but it will not return any useful information, it will return the value of DISPLAY that was current when the Emacs daemon was created.

2. "emacsclient -c", which creates a frame on the display specified in the environment variable DISPLAY (if DISPLAY is unset, "emacsclient -c" is equivalent to "emacsclient -nw").

3. "emacsclient --display <DISPLAY> -c", which creates a frame on the specified display <DISPLAY>; it is equivalent to "env DISPLAY=<DISPLAY> emacsclient -c".

If you want to know the value if the environment variable DISPLAY in case 1, the best way to do that is to explicitly include "$DISPLAY" in the form you evaluate, e.g. like this:

emacsclient --eval '(progn (setq display "'$DISPLAY'") (princ display))'



reply via email to

[Prev in Thread] Current Thread [Next in Thread]