2

How do I open a frame at start-up when using emacs --daemon? I don't run emacs --daemon directly. Instead, I use emacsclient -c -a '' which starts an emacs-server if there isn't one running already. However, if I simply add something like (make-frame '((name . "SomeName")) to .emacs, I get an error saying Unknown terminal type. How do I fix this?

Pradhan
  • 2,330
  • 14
  • 28

1 Answers1

3

This happens because your .emacs runs when the daemon is started. Usually, you start the daemon without any display system at all, and Emacs doesn't know how to make frames. After emacsclient forces Emacs to create a frame in the current session, Emacs then knows how to create frames.


You can fix this by using the --eval flag of emacsclient, which evaluates the lisp after Emacs is made aware of your windowing system. In order to create another frame, as you specify, execute this:

$ emacsclient -c -a '' --eval "(make-frame '((name . \"SomeName\")))"

Which should spawn two frames: the default one, and a new one named "SomeName".

PythonNut
  • 10,243
  • 2
  • 29
  • 75
  • 1
    Emacs will happily create 'frames' in terminals (e.g. try `C-x 5 2`, `C-x 5 o`, `C-x 5 0` in terminal Emacs). IIRC, when the daemon starts, Emacs does not have a terminal at all. – phils Feb 03 '15 at 20:22
  • True. I just realized that, and the functionality is pretty cool. I've amended my answer. – PythonNut Feb 03 '15 at 20:23
  • 1
    `C-h i g (elisp) Frames` and `(elisp) Multiple Terminals` are of note here. – phils Feb 03 '15 at 20:31