emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Eric S Fraga <e.fraga@ucl.ac.uk>
To: "H. Dieter Wilhelm" <dieter@duenenhof-wilhelm.de>
Cc: emacs-orgmode@gnu.org
Subject: Re: Evaluating simple inline expressions in org-mode
Date: Mon, 8 Feb 2016 09:33:03 +0000	[thread overview]
Message-ID: <878u2v35tc.fsf@delle7240.chemeng.ucl.ac.uk> (raw)
In-Reply-To: 87r3gozfqp.fsf@duenenhof-wilhelm.de

On Sunday,  7 Feb 2016 at 16:45, H. Dieter Wilhelm wrote:
>>>> works as well.  I'm not sure how you define variables in calc however...
>>>
>
>>> You could write something like src_calc[:var x=3.41]{2*x} :-)
>>
>> Yes but can you save a variable for use in a later expression?
>
> Well, at the moment I don't know another way as defining the calc
> variables on the lisp level:
>
> #+BEGIN_SRC emacs-lisp
> (setq var-foo 9.81
>       var-x 3.14
>       var-bar ...)
> #+END_SRC
>
> Note: `var-' is a special prefix for the calc variables `foo', `x',

Thanks for this.  Very useful to know.  Using this, I've created a macro
which will be quite useful for me in preparing some lecture notes with
simple calculations for illustration:

#+begin_src org
  ,#+macro: calculate $2 \leftarrow src_calc[:exports code]{$1} = src_emacs-lisp{(setq var-$2 (string-to-number (calc-eval "evalv($1)")))}

  An example:

  {{{calculate(x+y,z)}}}
#+end_src

-- 
: Eric S Fraga (0xFFFCF67D), Emacs 25.0.90.1, Org release_8.3.3-535-g7213aa

      reply	other threads:[~2016-02-08 11:06 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-03 13:45 Evaluating simple inline expressions in org-mode Gary Oberbrunner
2016-02-03 13:58 ` Ken Mankoff
2016-02-03 16:09 ` Eric S Fraga
2016-02-03 16:14   ` Gary Oberbrunner
2016-02-04  7:01   ` H. Dieter Wilhelm
2016-02-04  8:38     ` Eric S Fraga
2016-02-07 15:45       ` H. Dieter Wilhelm
2016-02-08  9:33         ` Eric S Fraga [this message]

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=878u2v35tc.fsf@delle7240.chemeng.ucl.ac.uk \
    --to=e.fraga@ucl.ac.uk \
    --cc=dieter@duenenhof-wilhelm.de \
    --cc=emacs-orgmode@gnu.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public 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).