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

From: Eliza Velasquez <[email-masked]>
Date: Mon, 2 Nov 2020 16:34:39 -0800

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

Yeah, that's what our golang wrapper was created to do. It would
detect edge cases like this and instead of invoking emacsclient with
-c, it would run elisp code to create a new frame. But that breaks the
blocking functionality, so a further workaround was used to block
during the lifetime of the frame by tracking the life of a temporary
file which our internal emacs elisp package created and deleted
specifically during ediff sessions.

This seems like it might be tricky to solve properly. My guess from
looking at the emacsclient source is that a new option would be
required in order to maintain backwards compatibility, maybe something
like `--smart-create-frame` or `-C`, which would behave as in the
expected behavior of the bug report. I think the emacs server might
need some tweaking as well, since I'm not sure there's any existing
combination of options that can be passed through the pipe for this.

On Mon, Nov 2, 2020 at 2:37 PM Stefan Monnier <[email-masked]> wrote:
>
> > 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
>