Hello everyone, I have been using emacs and writing simple functions for a while, I had also tried to make minor modes previously, and have made things that were super useful to me, but those were so niche that I didn't feel like it's be useful. But this time I made something that I think might be useful to others so I'm sharing it here.
This is a minor mode that can do well with LaTeX or org-mode.
What it does is: convert valid lisp expressions to LaTeX expressions. As you know we can evaluate lisp expressions directly in emacs (C-x C-e), so I had this thought why not use emacs as a calculator while typing the text without the need to move to another buffer to calculate things. But the problem was I couldn't leave the lisp expressions as it is if I have to submit the paper somewhere. So I had been manually converting them to mainstream expressions. But now I have LiTeX mode for that.
It can convert expressions like:
(+ 2 3 (* 6 x)) ⇒ 2 + 3 + 6 x
(setq x 5) ⇒ x = 5
(setq time-0 1) ⇒ time_{0} = 1
(defun fun (x) x+2) ⇒ \mathrm{fun}(x):x+2
(sin (* 2 θ)) ⇒ \sin(2θ)
(sin (* 2 time)) ⇒ \sin(2 \times time)
(setq y (+ x (expt x 2) (fun x))) ⇒ y = x + x^{2} + \mathrm{fun}(x)
It also has helper functions besides the main conversion like:
2.12e34 ⇒ 2.12 \times 10^{34}
Even do step by step solve for homeworks like:
(setq y (+ 2 3 (* 6 x))) ⇒
\begin{eqnarray*}
y &=& 2 + 3 + 6 x \\
&=& 2 + 3 + 6 \times 5 \\
&=& 2 + 3 + 30\\
&=& 35
\end{eqnarray*}
You can do step by step solve and get results in lisp expressions, or equation environment (steps rendered in same line) or eqnarray environment (steps rendered in different lines).
NOTE: the steps by steps evaluation needs to get the values of variables to solve things, so be sure to evaluate all expressions before running it.
All the activities of functions are controlled by variables you can customize. Like the format for float is "%.3f", you can change those and many more.
Demo Image: https://imgur.com/bRKFsSy
Github: https://github.com/Atreyagaurav/litex-mode
Video demo: https://youtu.be/esEf63gSSPg