all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* How to get DISPLAY of emacsclient?
@ 2022-11-25 15:17 Max Nikulin
  2022-11-25 16:57 ` Stefan Monnier
  0 siblings, 1 reply; 19+ messages in thread
From: Max Nikulin @ 2022-11-25 15:17 UTC (permalink / raw)
  To: emacs-devel

Hi,

Is it possible to get display of an emacsclient process? I mean either 
--display option argument or the DISPLAY environment variable namely for 
the client.

Unfortunately the value of following expression is the DISPLAY 
environment of the server process

     emacsclient --eval '(getenv "DISPLAY")'

I admit, it should work in most cases, but it is not robust:

     DISPLAY= emacs --daemon --display :0

causes empty string returned by `getenv'. In general, emacsclient's 
display is not necessary the same as the server's one. If I have got it 
correctly, the value is passed from client to server and there is a 
local "display" variable in server.el hidden from evaluated expression.

The context of the question is the following. Org-capture allows to 
create notes in non-distracting way (by setting :immediate-finish t 
property of the capture template). The idea is to save text currently 
selected in some application (either PRIMARY or CLIPBOARD) using a 
global window manager shortcut invoking

      emacsclient --eval '(org-capture nil "x")'

There is a pitfall. Emacs daemon has no frame at startup, so selection 
is inaccessible:

      emacsclient --eval "(org-get-x-clipboard 'PRIMARY)"

returns nil (it is merely a convenient way to call `gui-get-selection'). 
A workaround is to call `server-select-display', but to do so it is 
necessary to know display. That is why I am asking how to obtain display 
of emacsclient.




^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2022-11-30 12:47 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

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.