literate-calc-mode.el icon indicating copy to clipboard operation
literate-calc-mode.el copied to clipboard

Units convertion

Open Ypot opened this issue 4 years ago • 3 comments

How can we convert units? I've done it using usimplify like in the readme:

Surface = 5000000 mm^2
=usimplify(1 m^2 + Surface - 1 m^2) => 5 m^2

Is there a better way?

Best regards

Ypot avatar Aug 13 '21 07:08 Ypot

Sorry it took a while to respond. I've been scouring the Emacs docs and source code, but usimplify seems to be the best we have available without implementing something else. Regular calc has calc-convert-units, which is an interactive command that prompts for source and target units, but that is not available as algebraic function.

Maybe the best long-term approach would be to build a custom algebraic function that fills that gap?

sulami avatar Oct 16 '21 07:10 sulami

That's far from my reach, I think. Why don't you ask on orgmode mail list? https://lists.gnu.org/mailman/listinfo/emacs-orgmode

Ypot avatar Oct 19 '21 11:10 Ypot

This was a dealbreaker for me but everything else about literate-calc-mode has been amazing. From another blogpost, you can do something like

(after! calc
  (defalias 'calcFunc-uconv 'math-convert-units))

https://hungyi.net/posts/solve-system-of-equations-literate-calc-mode/

Which works great and also now makes it easy to convert other emacs calc functions -> algebraic functions for use in literate.

Thanks for writing such a nicer mode, I'm using it all the time now!

JZL avatar Aug 17 '22 14:08 JZL