I recently began running emacs in daemon mode on startup. Connecting via GUI client (Emacs.app) appears to load customizations correctly. However, connecting via emacsclient
in Terminal does not.
The first symptom appeared after trying to M-x customize-variable
in Terminal which produced the following message:
Cannot save customizations: init file was not fully loaded
This may have something to do with emacs --daemon
ignoring all X11-related options according to this. Though it would appear in my case that instead of ignoring the X11-related options emacsclient fails to load subsequent options.
After researching the problem and possible solutions I've been unable to determine a bulletproof method for dealing with this. I've seen suggestions to create a different init file and corresponding bash alias that passes it to emacsclient --eval
each time one wants to open an emacs buffer in Terminal. And I've seen others who use if-else statements in their main init file to deal with X11-related options. But before going down one path or another I'm wondering if there's a canonical way of dealing with this that I've somehow overlooked (or if I've simply made a mistake somewhere).
Advice, criticism, tips would be much appreciated.
Edit to add:
* GNU Emacs 24.3.1
* emacsclient 24.3
* both installed with homebrew on OS X 10.9
Here is the LaunchAgent:
<?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>emacsdaemon</string>
<key>ProgramArguments</key>
<array>
<string>/opt/boxen/homebrew/bin/emacs</string>
<string>--daemon</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>ServiceDescription</key>
<string>Emacs Daemon</string>
<key>UserName</key>
<string>my_name</string>
</dict>
</plist>
Here are the dotfile configs:
# relevant lines of .zshrc:
alias emacs="/opt/boxen/homebrew/bin/emacsclient -nw"
# set emacsclient as default editor
export EDITOR="emacsclient"
# use only emacscilent
export ALTERNATE_EDITOR=""
Sometimes I also like to launch emacs from within tmux:
# relevant lines of .tmux.conf:
# open emacs inside of tmux in a new window
# hat tip: http://perlstalker.vuser.org/blog/2012/10/16/emacsclient-and-tmux/
bind-key y new-window -n "emacs" "/opt/boxen/homebrew/bin/emacsclient -nw"