From: email@example.com To: Eric S Fraga <firstname.lastname@example.org> Cc: Org Mode List <email@example.com> Subject: Re: Multiple calc commands with orgbabel Date: Wed, 5 May 2021 22:24:58 +0200 [thread overview] Message-ID: <trinity-3a018e76-b185-46d0-bd38-9e782e90bcd7-1620246298102@3c-app-mailcom-bs16> (raw) In-Reply-To: <firstname.lastname@example.org> > Sent: Thursday, May 06, 2021 at 4:39 AM > From: "Eric S Fraga" <email@example.com> > To: "Matt Price" <firstname.lastname@example.org> > Cc: email@example.com, "Org Mode List" <firstname.lastname@example.org> > Subject: Re: Multiple calc commands with orgbabel > > 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. Calc is a great piece of work. Has it been long that work was done on it? > 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) > . 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: >  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 > >
next prev parent reply other threads:[~2021-05-05 20:26 UTC|newest] Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-05-05 5:46 pietru 2021-05-05 6:33 ` Eric S Fraga 2021-05-05 6:40 ` pietru 2021-05-05 6:41 ` Eric S Fraga 2021-05-05 6:45 ` pietru 2021-05-05 15:11 ` Matt Price 2021-05-05 15:29 ` pietru 2021-05-05 16:19 ` Tom Gillespie 2021-05-05 16:39 ` Eric S Fraga 2021-05-05 17:03 ` Tom Gillespie 2021-05-06 11:16 ` Bastien 2021-05-06 15:21 ` Tom Gillespie 2021-05-07 4:04 ` Bastien 2021-05-07 7:01 ` Tom Gillespie 2021-05-07 7:31 ` Bastien 2021-05-05 20:24 ` pietru [this message] 2021-05-05 23:09 ` ob-fortran behaviour Christopher Dimech 2021-05-05 23:29 ` Christopher Dimech 2021-05-06 2:24 ` ob-fortran fixes to column position 6 and subroutine keywords pietru 2021-05-05 7:12 ` Multiple calc commands with orgbabel Dr. Arne Babenhauserheide 2021-05-05 7:20 ` pietru 2021-05-05 7:23 ` Eric S Fraga 2021-05-05 7:26 ` pietru 2021-05-05 7:59 ` Eric S Fraga 2021-05-05 8:00 ` pietru
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style List information: https://www.orgmode.org/ * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=trinity-3a018e76-b185-46d0-bd38-9e782e90bcd7-1620246298102@3c-app-mailcom-bs16 \ --email@example.com \ --firstname.lastname@example.org \ --email@example.com \ --subject='Re: Multiple calc commands with orgbabel' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Code repositories for project(s) associated with this inbox: https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).