Literate Calc Mode
Literate programming for
Displays inline results for calculations, supports variables and updates as you type (if you want). Also works in your favourite markup mode.
There is both a major
literate-calc-mode and a minor
literate-calc-minor-mode. The major mode does some basic syntax
highlighting, while the minor mode only evaluates all calc statements
The minor mode works quite well with org-/markdown mode or other markup language major modes.
There are also some functions which can be called without any mode being active:
||Evaluates a single line|
||Evaluates the whole buffer|
||Evaluates the whole buffer and inserts results|
||Removes all overlays and clears variables|
This is a literate calc file. Lines without "=" are ignored. All results starting with "=>" are an overlay generated by literate-calc-mode. That means they are displayed in Emacs, but not actually in the buffer/file contents. We can calculate a value like so: = 2 + 2 => 4 If there is any string on the left hand side, it becomes a bound variable. Pi = 3.14159 => Pi: 3.14159 We can use this variable below the definiton. Tau = Pi * 2 => Tau: 6.28318 Results are calculated using Emacs' own calc, so you can use formulas as well. = round(Pi, 2) => 3.14 Later bindings shadow earlier ones: Pi = 3 => Pi: 3 = Pi => 3 Variable names can have spaces as well: Monthly Expenses = 500 => Monthly Expenses: 500 Monthly Income = 1000 => Monthly Income: 1000 Annual Savings = 12 * (Monthly Income - Monthly Expenses) => Annual Savings: 6000 All values are recalculated on every update in a spreadsheet-like fashion.