I know that emacs can open a file while evaluating an expression:
emacs file --eval "(toggle-frame-maximized)"
However I failed to replicate this with emacsclient:
1.emacsclient can open a file:
emacsclient file
2.And it can also evaluate an expression:
emacsclient --eval "(toggle-frame-maximized)"
3.But a problem happens when the two are put together:
emacsclient file --eval "(toggle-frame-maximized)"
It starts to report error and does not open the file. So is it possible to use emacsclient to open a file while still do eval?
--eval
is given, the arguments are interpreted as a list of expressions to evaluate, so you can also useemacsclient --eval "(find-file \"file\")" "(toggle-frame-maximized)"
. – xuchunyang Dec 23 '16 at 08:10find-file "file"
is great and simple (which is important). However, it has the disadvantage that the buffer is not considered a "server-editing-buffer", so some of the nice in-built emacsclient machinery does not work — for example, when you callemacsclient -c --eval "(find-file \"file\")" "(other-elisp-functions)"
, and then close the frame, the buffer you just opened is not killed (irrespective of whether it was open before or not), unlike withemacsclient -c file
. – aplaice Feb 12 '17 at 18:05server-visit-files
— e.g.(server-visit-files '(("file" . nil )) proc)
— might be a solution, except that we'd need to know the process id of the client, which I have no idea how to get. – aplaice Feb 12 '17 at 19:16