Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to use emacs command as a substitution for emacsclient -c -a "", which according to man connects to an existing emacs daemon, or creates a new daemon and connects to it otherwise. So i created a shell script emacs, which calls the aforementioned command in my ~/bin, which itself is included in $PATH. But when i run emacs, it repeats the following numerously:

emacsclient: can't find socket; have you started the server?
To start the server in Emacs, type "M-x server-start".

and then also numerously:

Error: Could not start the Emacs daemon

The content of ~/bin/emacs is:

emacsclient -c -a ""

According to Emacs devs, emacsclient internally calls emacs from $PATH, so calling it enters an infinite recursion. What should i do, so i can use custom emacs executable with the same behavior?

share|improve this question
The content of your wrapper is? – Jiri Xichtkniha Jun 11 '12 at 16:01

Not directly an answer but how about making a shell alias instead of writing your custom script, e.g:

alias emacs='emacsclient -c -a ""'

This allows you to type emacs in your interactive shell and everything should work out of the box.

Another idea is that you either modify PATH in your ~/bin/emacs script and exclude ~/bin/ or export a variable before running emacsclient and check in your script if the variable is set and run the original emacs command instead.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.