How can I make emacsclient -a '' -n
create a new frame only if there isn't one already?
The problem with the -c
flag is that it creates a new frame every time. The problem without it is that if there is no frame open it will open in the command line.
If I can check if there is an open Emacs frame from the shell, I can call with or without -c
depending on that to get the behavior I want. I tried:
$ emacsclient -a '' --eval '(frames-on-display-list)'
(#<frame F1 0xba2740>)
I always get the same result.
I could use temporary files or pgrep, but those approaches are very error prone.
This is similar to this question, but it is not a duplicate, since the OP there was satisfied with having to have a frame open before calling emacsclient
.