Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make emacsclient just open a window for an existing emacs daemon without opening a new file

I use an emacs daemon to preserve my emacs session even if I have to reboot the machine that I run my X server on or if I want to access the same session from a different machine. This works very well but when restoring a session I'd quite like to just run "emacsclient --create-frame --no-wait" to connect to the daemon without opening a new file. It won't let me get away without specifying a filename.

I've tried using --eval to execute a function rather than open a file but the window just goes away when the evaluation is complete.

(Emacs 23.1 via backports on Debian GNU/Linux 5.0.)

like image 838
Mike Crowe Avatar asked Jul 13 '10 13:07

Mike Crowe


People also ask

How do I open Emacs daemon?

One easy way to start the Emacs daemon is via “Settings > Session and Startup > Application Autostart”. You can also place an init script to place in /etc/init. d/emacsd.

How do I restart my Emacs server?

With server-start To start a server in an existing Emacs session, run M-x server-start. A server started in this manner will close when the last visible Emacs frame closes. If you want Emacs to automatically run a server on startup, add the following to your configuration file.

How do I know if my Emacs server is running?

Using the aliases "vi", "e", and "em" you can connect to a running emacs instance (which is the server). If there is no running emacs server, a new instance will be opened (in server mode). It also works nicely with Midnight Commander, where F3 is view, F4 is edit.


1 Answers

From the help provided by emacsclient, you have a few options. First, is the one mentioned already which is emacsclient -c. That will try to create a frame associated with the emacs daemon. The advantage to this is that if DISPLAY is not set, then it will open emacs in the terminal.

Which brings us to the next best option (especially if you are logging in remotely): emacsclient -t which forces emacs to open up in terminal mode even if DISPLAY is set.

Also keep in mind that you can set the display from the command-line as well. I use this often when logging in remotely from VNC. The full command would be emacsclient -d DISPLAY -c

like image 126
bnbeckwith Avatar answered Sep 19 '22 19:09

bnbeckwith