Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emacs - connect to daemon (if it exists) without using emacsclient

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?

like image 355
bstamour Avatar asked Dec 21 '22 05:12

bstamour


1 Answers

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.

like image 172
Luke Girvin Avatar answered Dec 27 '22 10:12

Luke Girvin