15

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.)

Mike Crowe
  • 642
  • 6
  • 18
  • I think this question is more suitable for http://superuser.com/ – Alexey Romanov Jul 13 '10 at 13:54
  • 1
    Thanks for the comprehensive answers, especially for not pointing out that I was just being clueless! It appears that I was mistaken in saying that "emacsclient --create-frame --no-wait" doesn't work due to the lack of filename. I must have got myself a mixture of emacs and emacsclient versions (emacsclient from v22 does appear to require the filename but it makes sense in that version.) – Mike Crowe Jul 14 '10 at 15:43

4 Answers4

21

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

bnbeckwith
  • 1,005
  • 6
  • 7
8

emacsclient -c works for me.

offby1
  • 6,767
  • 30
  • 45
  • Hmm. It does for me too. I'm sure it didn't work when I'd tried it on two previous occasions but now I can't reproduce it. :( – Mike Crowe Jul 14 '10 at 15:32
4

emacsclient -n -e "(make-frame)"

The -n flag means that the emacsclient doesn't wait, and the emacs instance doesn't destroy the frame.

Edric
  • 23,676
  • 2
  • 38
  • 40
3

If you are using emacs from the command line, you might also want to consider emacsclient -t

yonkeltron
  • 643
  • 5
  • 7