Note: I had asked this question before under https://apple.stackexchange.com/questions/181007/emacsclient-waits-when-alternate-editor-is-used.
I created the following script emc
to invoke emacs (if already an emacs instance is running, the arguments should be opened in this instance, otherwise, a new instance should be started; the -n
causes emacsclient not to wait):
#!/bin/bash
/Applications/MacPorts/Emacs.app/Contents/MacOS/bin/emacsclient --alternate-editor "/Applications/MacPorts/Emacs.app/Contents/MacOS/Emacs" --no-wait ${1+"$@"}
When already an emacs is running, the script works as expected; if, however, no emacs is running so far, a new one is started and the files are opened, but emacsclient waits until this instance is closed and gives the following output:
computerName:bin user$ emc .
/Applications/MacPorts/Emacs.app/Contents/MacOS/bin/emacsclient:
can't find socket; have you started the server?
To start the server in Emacs, type "M-x server-start".
How can I avoid this waiting?
.emacs
:;; Start server and set directory (setq server-socket-dir (format "/tmp/emacs1000"))
and then I have a bash alias of# emacs aliases alias emacs='emacsclient -t -s server --alternate-editor='