2

The following command works to open a file in an existing emacs instance:

emacsclient --eval \
"(progn (find-file \\"/a/b.txt\\") (goto-line 1) (forward-char 2) (recenter))" \
--no-wait \
--alternate-editor=emacs

However when there is no emacs instance running it creates a buffer called b.txt").

Is there a way this can be made to work in both cases?

1 Answer 1

1

In emacs 26 this will be supported by using --alternate-editor="emacs --eval"

For now you can write a script that wraps emacs, eg:

emacs-eval-wrapper

#!/bin/bash
exec emacs --eval "$@"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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