Is there some package or builtin emacs feature which evaluates an algebraic formula in place?

E.g. I type in the scratch buffer:

(3 + 4) *  5  

and when I invoke some command on this line then I get in the buffer:

(3 + 4) *  5 = 35

It's not hard to implement, I'd just like to know of there is an existing feature which can do this.

  • For this kind of stuff there exists the package calc-embedded.
    – Tobias
    Commented Dec 9, 2019 at 16:15

2 Answers 2


calc provides calc-eval for this kind of use, just pass it a string and receive a string result back.

  • Thanks, just what I needed.
    – Tom
    Commented Dec 9, 2019 at 9:11

For reference I'm posting my solution based on wasamasa's answer:

  (if (re-search-forward " *=.*" (line-end-position) t)
      (replace-match ""))
  (insert " = "

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.