When I run emacsclient -nc filename.txt in my terminal, emacs opens in my terminal. I would prefer it to open in the main Emacs.app frame. Similar to how the terminal shortcuts work for Atom.

  • 1
    Possible duplicate of run emacs gui from emacclient
    – Basil
    Commented Feb 10, 2018 at 12:16
  • That is a similar, but different problem. That question also has no accepted answer. I've solved my problem now, and I will explain below.
    – groodt
    Commented Feb 10, 2018 at 23:37

4 Answers 4


I found my problem, so I'll answer my own question.

Homebrew emacs automatically starts the emacs daemon server through launchctl. When I then run emacsclient -nc filename.txt in the terminal it attaches to this daemon, rather than the server that I am running in my GUI Emacs.app frame.

My solution is as follows:

  1. Remove the homebrew installed emacs service brew services stop emacs
  2. Ensure (server-start) is in your init.el
  3. Set your Emacs.app to start at startup by putting it in "Login Items" (System Preferences -> Users & Groups)
  4. Now when I run emacsclient -nc filename.txt, it opens as a frame of the GUI Emacs.app and not inside my terminal.
  5. It can then be convenient to setup an alias for emacsclient. alias ec="emacsclient -nc"
  • 1
    I do not think step 1. is necessary to the solution. Brew services does the same thing as your step 3. The important thing is that the emacs demon is running. If it is not, the OS will start a new emacs process when you call emacsclient and run it on terminal. Without your own answer it was difficult the guess that you were not running the demon. I'll create an answer to that effect.
    – Heikki
    Commented Feb 11, 2018 at 16:10

You need to pass the -c flag.

$ emacsclient -c filename.txt

If that doesn't work, make sure that you have installed Emacs with Cocoa support:

$ brew install --with-cocoa emacs

You own answer contains the answer among other things: You need to have the emacs server running to have emacsclient to open a window or frame in the existing GUI emacs instance.

  • It is true that you need to have the emacs server running to use emacsclient. However, on my system, if the emacs server / daemon is run via launchctl, running emacsclient in the terminal will start emacs in the terminal, not in the GUI emacs instance, which is what I specifically wanted to achieve.
    – groodt
    Commented Feb 11, 2018 at 23:31
  • I can see emacs process running with brew services list and emacsclient works as expected as long as I have the emacs server running. Maybe there is something else in interfering in your system.
    – Heikki
    Commented Feb 12, 2018 at 14:15

For me, the problem was in ALTERNATE_EDITOR env variable set to emacs. So, when emacsclient tried to start, then wouldn't connect via socket (server-start was not started), and failed with nonzero status, it silently started emacs instead.

Setting ALTERNATE_EDITOR="" and starting server-start fixed this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.