0

I am trying to bind a keyboard key for a new emacsclient frame running a specific helm command helm-locate like that:

emacsclient -c --eval '(helm-locate)'

It does not seem to work (no new frame pops-up). When I change the command (e.g. emacsclient -c --eval '(mu4e)') it does work, so it must be something with the way helm-locate works.

Does anyone know how to fix this?

2
  • 2
    Have you tried starting the daemon like this: emacs --daemon -Q and loading just your helm bits? I know helm works fine for me, so you'll probably need to investigate your config. Also, your changed command looks the same to me, although my eyesight is bad. – PythonNut Feb 1 '15 at 16:40
  • Sorry I edited the question. There was a mistake there. --eval '(mu4e)' works fine, --eval '(helm-locate)' does not. – entropiece Feb 1 '15 at 21:50
2

If you had started the erroneous example from a terminal, you would have noticed output similiar to the following:

$ emacsclient -c --eval '(helm-locate)'
[…]
*ERROR*: Wrong number of arguments: (1 . 1), 0

Comparing the arguments both mu4e and helm-locate require (which can be easily found out with M-x find-function) reveals that while both commands are interactive, mu4e doesn't require any argument at all, helm-locate however does and is using (interactive "P") to tell Emacs what to fill in when used interactively. The P specification supplies a raw prefix argument, so without any prefix argument it's going to be nil. That's why emacsclient -c --eval '(helm-locate nil)' should do the trick.

If the interactive spec you're encountering is a lot more complex to figure out (there's an escape hatch to just use an s-expression that evaluates to a list of all arguments, it's used heavily inside Emacs itself and external packages as well), you can cheat by using call-interactively, then the command to execute would be emacsclient -c --eval "(call-interactively 'helm-locate)".

2
  • Thanks for your help. Everything works fine now. I was guessing there was no need for arguments since I was calling it with a simple M-x helm-locate. – entropiece Feb 2 '15 at 13:28
  • 1
    M-x is using call-interactively on the command it reads in, that's why. – wasamasa Feb 2 '15 at 13:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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