问题
If I have emacs running as a daemon on my system, I can connect to it easily using emacsclient. This I know. However, what I would like to know is, is there a way to tell emacs (not emacsclient) to behave like emacsclient if a daemon is already running?
e.g.
# emacs daemon is not running
emacs # should start a new frame
# ...
# emacs daemon IS running
emacs # should actually behave like emacsclient, i.e. connect to my daemon
Is there anything I can do to my init.el to replicate this kind of behaviour?
回答1:
I don't think so, but can you achieve a similar effect by using emacsclient
with an empty string as the the --alternate-editor
option? From http://www.gnu.org/s/libtool/manual/emacs/emacsclient-Options.html#emacsclient-Options:
-a command
--alternate-editor=command
. . . As a special exception, if command is the empty string, then emacsclient starts Emacs in daemon mode and then tries connecting again.
来源:https://stackoverflow.com/questions/8328469/emacs-connect-to-daemon-if-it-exists-without-using-emacsclient