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 Dec 9 '19 at 16:15

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

| improve this answer | |
  • Thanks, just what I needed. – Tom Dec 9 '19 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 " = "
| 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.