I'm trying to setup Emacs (which I installed via brew install emacs --cocoa
) in a way that I can use it the in following way:
emacsclient file.txt
creates a new GUI Frame if there is none alreadyemacsclient file2.txt
replaces the contents of the existing frame if there is oneemacsclient
should always return immediately and not block the shell it has been called fromemacs --daemon
processAs I said I installed Emacs via homebrew. To have a daemon starting when I log in I added ~/Library/LaunchAgents/org.gnu.emacs.plist
with the following content:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.gnu.emacs</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/Cellar/emacs/HEAD/bin/emacs</string>
<string>--daemon</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
I confirmed that this starts the process. So far I tried various variants to call emacsclient:
/usr/local/Cellar/emacs/HEAD/bin/emacsclient file.txt
this opens emacs in my terminal/usr/local/Cellar/emacs/HEAD/bin/emacsclient -c file.txt
this opens up a new Emacs GUI frame (good!) but it somehow does not have the same font-size/typeface settings. Also when I close that frame and open another file with emacsclient -c
the Emacs process seems to crash./usr/local/Cellar/emacs/HEAD/bin/emacsclient -n file.txt
just exits right awayI'm not sure what I'm supposed to do. I've found a lot of tutorials on this but many weren't clear if the objective is to get a daemon working just for terminal usage of emacs etc.
I'd be very interested to hear how you use Emacs on OS X, especially how you setup an Emacs daemon and how/if you are using the GUI variant.
If you are working with a graphical user interface, start Emacs by clicking its icon or by running emacs & at the command line. The & tells the command line to open Emacs in the background and immediately return control of the terminal to you.
OS X comes with a preinstalled version of Emacs, but alas it is the outdated Emacs 22. Fortunately, obtaining a newer release is really simple. There are several popular ways to do it.
Mostly simply, download and run the emacs- version -installer.exe which will install Emacs and create shortcuts for you. Alternately, download emacs- version . zip then unzip, preserving the directory structure.
As it happens so often I found a solution while writing this. Putting the following into my init.el
allowed me to open files in the existing GUI frame.
(require 'server)
(unless (server-running-p)
(server-start))
I assume that this works because the server process is bound to the GUI instance of Emacs but I'm still very open to someone else enlightening me on this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With