| path | /learnings/emacs |
|---|---|
| title | Learnings: Emacs |
<<Emacs_Calculations_Calc>>
I like literate-calc-mode for most things, and in fact use it to keep track of monthly bills.
But sometimes I want to run quick calculations where getting the answer is more important than showing the work.
Calc mode to the rescue
Formulas can either be on a single line of between delimiters: blank lines or LaTeX math delimiters (@ (TexInfo), and a few others.
note: the blank lines delimiters mean there needs to be a blank line above and below the expression
10 - 5
place your cursor into the formula and M-x calc-embedded-update-formula.
5
now inside a line: $$ 10 - 5 $$ $$ 5 $$
You can also create variables, with :=
$$ budget := 500 $$
This is a bit trickier. In the region you need to M-X calc-embedded, then M-x calc-embedded again to get out
Now you can use this variable in your update formula call, like so: $$ budget - 100 $$ which returns $$ 400 $$.
Now, what if I'm computing things but want to keep the initial formula? Use =>
$$ 500 - 400 => $$ results in $$ 500 - 400 => 100 $$. In fact, if I subtract 300 instead and run the calculations, Emacs updates the answer once I run M-x calc-update-formula
Use swiper-all, type your expression, press M-q for the replacement, ENT, y replaces one and goes on to the next, n skips, ! replaces all
Using Detached.el
Triggered: in eshell do SHIFT-RETURN to execute a shell command. (But Emacs will pay attention to stdin, so you won't notice a difference)
TO DETACH: C-c C-c. The command will continue (it will not abort the long running process)
Use M-x detached-list-sessions to see the list of sessions, and return to select the process to ie see input. Sessions with a * are currently running.
TO REATTACH:
M-x detached-eshell-attach-session <-- will give you a list of sessions to attach to