Subject: bug#25547: 25.1.91; emacsclient -c creates frames on the wrong display

From: Stefan Monnier <[email-masked]>
Date: Mon, 02 Nov 2020 17:37:53 -0500

> To reproduce:
> 1. Run `emacs --daemon' on a system with a graphical display.
> 2. Login to the system using a terminal with no graphical display. You
>    could do this by switching to another virtual terminal (Ctrl-Alt-F1
>    works on Ubuntu), or SSH in from another machine.
> 3. Run `emacsclient -c' or `emacsclient -t' in the terminal to connect
>    to the running Emacs instance.
> 4. Inside Emacs, run M-x shell.
> 5. In the M-x shell buffer, run `emacsclient -c'.
>
> Ideal behavior: emacsclient creates a frame on the current terminal.
> Actual behavior: emacsclient creates a graphical frame in the
>   environment in which it was launched, which is inaccessible from the
>   terminal.

Indeed the current behavior is a bummer.

The second emacsclient runs within a shell process which itself is
associated to the *shell* buffer, which can be displayed in several
windows, including some of them in the GUI.

So in the above case you actually would like to open the emacsclient
wherever `selected-frame` is (because it's generally impossible to walk
out way back from the second emacsclient process to the parent tty in
which the first emacsclient has opened a frame).

Have you tried using `emacsclient` without the `-c` option (you'll have
to provide a file-name in that case)?

        Stefan