I want to run the Emacs.app in daemon mode on Mac OS X. I can run emacs in daemon mode via the terminal, but instructions for running the app in a client-server pattern do not work (e.g.: http://overtone.github.io/emacs-live/doc-starting.html, yet /Applications/Emacs.app/Contents/MacOS/bin/emacsclient does not exist) with the latest versions of Emacs.

How can I run Emacs 24.x app on Mac OS X in daemon mode?

My goals are to start the server on start up (which I know how to do), and, when I launch a client, to launch a new frame in the app version of Emacs which is already running.

  • I'm running Emacs.app 24.4 from from emacsformacosx.com and it contains emacsclient. Which build are you using? – Alan Shutko Feb 12 '15 at 20:38
  • I'm running from homebrew – pwalsh Feb 13 '15 at 5:28

I used https://korewanetadesu.com/emacs-on-os-x.html and it worked fine, but recently I've installed Emacs via 'brew' and it works much better (less hassle and better daemon experience) for the daemon part: http://www.emacswiki.org/emacs/EmacsForMacOS#toc16

Once you install it, it says that get emacs to load on startup, execute:

$ ln -sfv /usr/local/opt/emacs/*.plist ~/Library/LaunchAgents
$ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.emacs.plist
| improve this answer | |
  • I use the homebrew version too. Your answer helps with starting the app in daemon mode, but when I connect with a client, e.g: emacsclient -c it creates a new 'instance' of the app in the dock, rather than launching a new window or frame in my current emacs instance. Is that consistent with the behaviour you have? – pwalsh Feb 12 '15 at 15:09
  • I never use emacsclient. I launch emacs directly and runs fast enough for me. I dunno much about this, but I suspect that those two operations I mentioned above speed up emacs loading. When using the "korewanetadesu" suggestions, I found that when I was using emacsserver, which created a instance of the app in the doc, it used to hang sometimes. – Galder Zamarreño Feb 13 '15 at 8:58
  • That's great, but the question is clearly about connecting to the app in daemon mode when launching a client. – pwalsh Feb 13 '15 at 19:49
  • There is a package in melpa called osx-pseudo-daemon which might be worth looking at. – Tim X Feb 14 '15 at 8:18
  • @pwalsh To run emacs in daemon mode, the launchctrl command above will start an emacs process for you. So to make a new frame you would do: emacsclient -n -c The emacs icon will appear in the dock, it will stay in the dock until the process started by launchctrl (emacs -daemon) exits, or is killed. You can also use emacsclient -t in a terminal. Both commands connect to the emacs daemon instance if the instance is not running, the commands will throw an error. – xmonk Apr 22 '15 at 11:51

I've also run into issues trying to run Emacs as a daemon in OS X, so I wrote a "pseudo-daemon" mode that just creates a new hidden GUI frame when you close the last frame. The result is that Emacs just hides in the dock whenever it would normally exit, which provides a surprisingly good approximation of daemon mode while keeping the Dock icon functional. You can get it from MELPA: https://melpa.org/#/mac-pseudo-daemon

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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