On Wednesday, 5 May 2021 at 11:11, Matt Price wrote: > Can you explain how you get calc embedded mode working in org? I have > never used it and it sounds interesting, but I don't understand what > hte delimiters are.
Sure. Here is a mini-tutorial! :-) I recently gave an interactive talk on embedded Calc... The out-of-the-box settings for Emacs embedded mode are such that any line surrounded by empty lines (i.e. couple of blank lines before and after) can be interpreted as an expression to evaluate by Calc using "C-x * u". You do not need to place these expressions in any src block. The detection can be somewhat fragile so extra blank lines are sometimes necessary for some reason. For instance, copy the following few lines to a text buffer and type "C-x * u" on each line in turn: --8<---------------cut here---------------start------------->8--- x := 180 => y := sin(x / 4) => z := 2 y^2 => --8<---------------cut here---------------end--------------->8--- The general format for an embedded calc expression is var := expression => value where only "expression" is required. If you don't have "=>", evaluating the expression will replace the expression with its value. If you have lines as above, with assignments and values after the actual expression, you can then go back to the first line and change the value, say to 90, type "C-x *u" on that line again and all of them should update. The calculations can involve calculus (derivatives, integration), linear algebra, and units. Calc is actually an incredibly powerful (and relatively unknown) computer algebra system hiding within Emacs. The variables that could be customised to have org specific recognition would be calc-embedded-open-formula and calc-embedded-close-formula. It might be useful for the community to think about whether org should have org specific settings for these variables. I actually define settings for org so that only lines that look like this: #+calc: expression are interpreted (without requiring empty lines around such lines) [1]. I then have code for processing these lines on export to LaTeX to present the equations and results in a more accessible way as I use embedded calc a lot for teaching (beamer slides). Final note: the info manual for embedded Calc mode emphasises editing the expressions and interacting with Calc while doing so. I find that method of working rather confusing, tiring, and unproductive (for my use case) so I write the calc lines using normal editing and only "update" the expressions to get the results. YMMV, of course. Let me know if this helped at all, eric Footnotes: [1] it would be nice to have some generic way to hijack C-c C-c on such lines to do what I want, e.g. calc-embedded-update-formula. -- : Eric S Fraga via Emacs 28.0.50, Org release_9.4.5-395-g82fbdd