reddit / emacs
New Package: units-mode (is on melpa), convert between units interactively and in lisp code. [uses gnu units for conversion]
thevoidzero · 2022-09-04 16:22
thevoidzero · 2022-09-04 17:18
Forgot this but here's the repository,
https://github.com/Atreyagaurav/units-mode
The instructions and features are explained in the readme. But basically it's mostly a interface to gnu units which can do a lot of things related to units.
Feel free to give suggestions on more features or improvements.
grimscythe_ · 2022-09-04 18:21
Very, very nice. Thanks, needed something like this for quite some time.
ieure · 2022-09-04 18:26
Another option is the built-in [calc](https://www.gnu.org/software/emacs/manual/html_mono/calc.html#Units). I've been learning it more the last year or so and it's very nice.
thevoidzero · 2022-09-04 18:32
Welcome, i was surprised to not see one already made for this.
thevoidzero · 2022-09-04 18:33
I learned it does unit conversions while I was searching for existing ones before developing it, and you can use calc in embedded mode, but i'm not comfortable in calc, and I wanted it to be available to be used from other packages.
nv-elisp · 2022-09-04 18:39
Nice idea for a package!
I left some feedback on your MELPA proposal for the package.
https://github.com/melpa/melpa/pull/8187#issuecomment-1236390755
agumonkey · 2022-09-04 18:40
calc may be the most underused feat of emacs
thevoidzero · 2022-09-04 18:45
Thank you, I've replied you there. I've fixed the `string-join` problem, and I'm looking at the `call-process`, I've tried similar methods for other packages and had decided `shell-command-to-string` was the easiest one, as others needed me to parse the outputs and have intermediate pipes to receive stdout.
ieure · 2022-09-04 18:50
It's kind of incredible how much it can do.
thevoidzero · 2022-09-04 19:10
ikr, I was super surprised at the symbolic calculations, i found about it when accidentally putting text instead of number in org table. Like how far have they made it.
qZeta · 2022-09-04 20:41
> Feel free to give suggestions on more features or improvements.
Drop the requirement for GNU `units`/other external programs and instead use `calc-units.el`, if possible. `units` might not be installed on the system, but `calc-units.el` is part of Emacs' built-in `calc` package.
karthink · 2022-09-04 20:43
That's not surprising, the user interface and discoverability of calc features are terrible.
thevoidzero · 2022-09-04 20:45
I did consider that. I don't use calc that much so i don't know how it performs compared to gnu units that's very advanced for unit operations.
I wasn't able to find the comparison on the internet.
kkvi115 · 2022-09-04 20:47
I was looking for something like this for my wood DIY projects :)
deaddyfreddy · 2022-09-04 22:18
I'm interested, what's the reason to write software like `gnu units` in C these days?
mariownyou · 2022-09-04 22:23
What colorcheme do you use? It is awesome
thevoidzero · 2022-09-04 22:24
`wombat` theme from `M-x customize-themes` I don't remember installing it so probably is there by default.
thevoidzero · 2022-09-04 22:29
1. I didn't write gnu units
2. I don't think it was written "these days" ( [version 1.53 seems to be released 1997-01-14 03:00](https://ftp.gnu.org/gnu/units/) , couldn't find ones before it)
3. What's wrong with writing program in C? C is an excellent tool if you know what you're doing.
mariownyou · 2022-09-04 22:51
Thanks
[deleted] · 2022-09-05 00:09
[deleted]
MangyCanine · 2022-09-05 02:25
The documentation is also godly. Years ago, I killed a forest printing it out — it was 300+ pages.
ieure · 2022-09-05 02:48
I just have a hardcopy of the quick reference I printed up on some cardstock.
agumonkey · 2022-09-05 03:42
Depends where you're coming from. As an HP calc lover i like it.
karthink · 2022-09-05 05:23
The UI is fine for trivial arithmetic. For anything I'd actually need to use its advanced features for it's terrible. Many of calc's mappings are ridiculous. For example, prefix arguments of -1 through -15 to `calc-pack` do fifteen different, arbitrary things like pack stack numbers into intervals, complex numbers, modulo or date forms. Some tasks that are a pain in calc:
- Example: Generate a few polynomials with random coefficients from a normal distribution and plot the areas between successive pairs of them on a graph.
- Example: Run calc on a math expression involving an integral in my latex document using embedded mode.
- Example: Solve a 10x10 system of equations.
- Example: QR factorize or find the SVD of a non-trivial matrix.
- Example: The units table has basic omissions. It knows the electron magnetic moment but I can't convert farenheit to celcius.
All of these are possible in Calc, but have very clumsy solutions. Calc makes easy things easy, and possible things obtuse.
EDIT: If you want to make its UI more discoverable and accessible you're welcome to try. I tried ([image1](https://uploads.disquscdn.com/images/ef105cdc9707ac2fc53e6c5838b9179078db3b50c31f38d2f8b3f791716c1da9.png?w=600&h=351), [image2](https://uploads.disquscdn.com/images/0ecca7e42fb660fc532d805c3ab2ceea431049f953b71dbc288c3877b1c6611e.png)) and gave up.
deaddyfreddy · 2022-09-05 08:38
>What's wrong with writing program in C?
* spending extra time without a need?
* The source code (not including resources and stuff like that) are about 200Kb, more code - more bugs, it's harder to maintain.
* Besides that, GNU/Units is not intended to be used as a highload real time application, so no one cares if a calculation takes 10ms or 100ms. Given a fact that unit conversions are pure - there's absolutely no reason to use an imperative mutable language.
>C is an excellent tool
I wouldn't call it excellent, it's just happened to be popular in the 80s (together with Unix-likes) and was ok enough
>if you know what you're doing.
I know what I'm doing, that's why I don't code in C these days
AuroraDraco · 2022-09-05 10:26
Looks cool