0

This works:

emacsclient  -s emacs -e "(call-interactively 'find-file)"

But this one doesn't:

emacsclient  -s emacs -e "(call-interactively 'newline)"

In fact, none of the functions I tried to run via Terminal with emacsclient didn't work except find-file. Built-in functions tend to turn nil while functions I wrote tend to turn errors like *ERROR*: End of buffer, although I can run the same function directly in emacs without any problem.

The function that turned the above error message is this:

(defun test (&optional args)
  (interactive )
  (forward-char 2)
)

How can I get this to work?

OS X 10.8 Emacs 24.5 (9.0) desktop version

2

What buffer do you think emacsclient runs the command in?

$ emacsclient -e '(current-buffer)' 
#<buffer  *server*>

The server uses the  *server* buffer for its buffer-local variables. Its contents are only used for debugging purposes.

What you're trying to do doesn't make sense: things like inserting a newline and moving the cursor only make sense if you specify which buffer to act in. If you want to act in an already-open buffer, you need to select it first with set-buffer, e.g.

emacsclient -e '(with-current-buffer "my-already-open-file" (forward-char))'
| improve this answer | |

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.