It's really handy to get stuff calculated in minibuffer using quick-calc (C-x * q) - I especially like that it automatically copies the result into buffer so it's just one C-y away.

Now the questions is - can I get all this goodness via emacsclient? Just printing out the results of calculating some string would be nice but having it in clipboard as well - even better.

  • 4
    What exactly do you want? Do you want a way to call quick-calc from the command line if Emacs isn't even open yet?
    – zck
    Commented Oct 12, 2015 at 16:45
  • No, emacs is running in daemon mode. I want to call quick-calc with emacsclient and immediately exit after result is calculated.
    – god
    Commented Oct 16, 2015 at 12:09

2 Answers 2


You can use the -e option to just eval a lisp expression (from man emacsclient):

-e, --eval
       Do not visit files but instead evaluate the arguments as Emacs Lisp expressions.


$ emacsclient -e '(calc-eval "solve(x^2 +x = 23, x)")'
"x = 4.3218"

I suppose that can be made easier via a shell function. E.g.

$ calc() { emacsclient -e "(calc-eval \"$@\")" | xargs; }
$ calc 'inv(
     [1, 2, 3, 4;
      6, 5, 4, 3;
      7, 12, 3, 4;
      5, 6, 3, 2])'
((-0.28571 0.71429 0.16667 -0.83333) (0.071429 -0.42857 1.1351e-14 0.5) (0.28571 -0.71429 -0.5 1.5) (0.071429 0.57143 0.33333 -1.1667))

I use the pipe through xargs here to get rid of the quotes (which implies passing the output as arguments to echo), which seems to work fine, but let me know if you see any adverse side effects.


Well, it's not really an answer but it did solved the overall problem for me: instead of trying to reach Emacs' calc via emacsclient from shell I've flipped the problem upside-down and started using eshell as my main shell which allows me to use "calc-eval EXPR" directly :)

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.