Assuming an Emacs server is running, I want emacsclient <file> to either create a new frame (like -c) when there is no existing frame or reuse an existing frame when there is one. In other words, I want the -c only when there is no existing frame. Is that possible?
Assuming an Emacs server is running, I want emacsclient <file> to either create a
Share
I solved my problem with a set of shell scripts.
my_emacs
You may need to change emacs24-x to something that points to your X11 emacs.
my_emacsclient
Add both files to you PATH via ~/bin or the like.
In my .emacs I also added the followings lines
Also change some environment variables and optionally add an alias
When you run
ein your shell it should create or resuse an existing GUI frame. Also, runninge <filename>opens that file in a frame; you can also pass other flags like-ntoe.For the same behaviour in other applications (say your file manager), you should also change the Emacs .desktop file (for me that’s
/usr/share/applications/emacs24.desktop) to runmy_emacs.It might also be a good idea to change
emacstomy_emacsclientvia the alternatives system in Debian-based (?) distributions.