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.
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:
- Remove the homebrew installed emacs service
brew services stop emacs
(server-start)is in your init.el
- Set your Emacs.app to start at startup by putting it in "Login Items" (System Preferences -> Users & Groups)
- Now when I run
emacsclient -nc filename.txt, it opens as a frame of the GUI Emacs.app and not inside my terminal.
- It can then be convenient to setup an alias for emacsclient.
alias ec="emacsclient -nc"
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
ALTERNATE_EDITOR="" and starting
server-start fixed this.