From: "Eric Schulte" <schulte.eric@gmail.com>
To: Christopher Witte <chris@witte.net.au>
Cc: Org Mode <emacs-orgmode@gnu.org>
Subject: Proposed New Syntax For Calling Code Blocks was: Problem with Babel and sessions
Date: Fri, 10 Sep 2010 12:06:47 -0600 [thread overview]
Message-ID: <87vd6deafb.fsf@gmail.com> (raw)
In-Reply-To: AANLkTim32fcEKcLMNV_R6WaUmL=KpojeC8ySaHYyottC@mail.gmail.com
Hi Christopher,
Thanks for the well documented example.
The header arguments on the call line, are actually being used by the
call line itself, not by the R block which is called. To unpack that,
on evaluation the call line expands to a trivial emacs-lisp code block
which is equivalent to
#+begin_src emacs-lisp :var results=chartPolAngle(pol=tableTestBabel) :session testBabel:file
results
#+end_src
So the :session header argument is used by the emacs-lisp code block in
the call line, and never propagates to the R code block which is
evaluated. Notice that header arguments like :results silent, will have
the expected results.
So for now you will have to place the header argument on the actual R
code block.
That said, I think that we should provide a mechanism for passing header
arguments through to called code blocks making the original
functionality you described possible. I'm not sure how best to do that,
but currently I think we should expand the syntax used to call code
blocks to be more similar to inline code blocks, s.t. header arguments
can be placed inside of an optional square bracket section between the
name of the code block and the arguments. Using this new proposed
syntax your example below would be written as
#+call: chartPolAngle[:session testBabel :file testBabel.pdf](pol=tableTestBabel)
I'd be interested to hear what the community thinks of this new syntax.
As an unrelated note, we also need to think of a natural way to allow
the header argument portion of a code block to span multiple lines.
Best -- Eric
Christopher Witte <chris@witte.net.au> writes:
> I'm having a bit of trouble with org bable and R. When I try to execute the
> code below (C-c C-c on the call line), as you can see, I get the results
> :nil
>
> ---------------------------------------
> #+tblname: tableTestBabel
> | 0 | 4.40 |
> | 30 | 4.54 |
> | 60 | 7.09 |
> | 90 | 9.40 |
> | 120 | 9.22 |
> | 150 | 6.65 |
> | 180 | 4.22 |
>
> #+srcname: chartPolAngle(pol)
> #+begin_src R
> angle <- pol[,1]
> energy <- pol[,2]
> plot(angle,energy)
> energy.model <- nls (energy ~ a1 + a2 * (sin(pi / a3 *(angle-a4)))^2,
> start=list(a1=3.0, a2=7.0, a3=180, a4=0.0))
> lines(spline(angle, fitted.values(energy.model)), lwd=2)
> summary(energy.model)
> #+end_src
>
> #+call: chartPolAngle(pol=tableTestBabel) :session testBabel :file testBabel.pdf
>
> #+results: chartPolAngle(pol=tableTestBabel)
> : nil
> ------------------------------------
>
> but If I move the header arguments to the source block, as in the code
> below, everything works fine. I also get asked "ESS [S(R): R] starting data
> directory? ~/doc/org/" which I don't get with the code above.
>
> ---------------------------------------
> #+tblname: tableTestBabel
> | 0 | 4.40 |
> | 30 | 4.54 |
> | 60 | 7.09 |
> | 90 | 9.40 |
> | 120 | 9.22 |
> | 150 | 6.65 |
> | 180 | 4.22 |
>
> #+call: chartPolAngle(pol=tableTestBabel)
>
> #+results: chartPolAngle(pol=tableTestBabel)
> : testBabel.pdf
>
>
> #+srcname: chartPolAngle(pol)
> #+begin_src R :session testBabel :file testBabel.pdf
> angle <- pol[,1]
> energy <- pol[,2]
> plot(angle,energy)
> energy.model <- nls (energy ~ a1 + a2 * (sin(pi / a3 *(angle-a4)))^2,
> start=list(a1=3.0, a2=7.0, a3=180, a4=0.0))
> lines(spline(angle, fitted.values(energy.model)), lwd=2)
> summary(energy.model)
> #+end_src
> ---------------------------------------
>
> Org doesn't appear to respect the head arguments on the call. I pulled from
> git a couple days ago. Any ideas why?
>
> Cheers
> Chris Witte
> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
next prev parent reply other threads:[~2010-09-10 18:11 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-09 15:09 Problem with Babel and sessions Christopher Witte
2010-09-10 18:06 ` Eric Schulte [this message]
2010-09-10 19:58 ` Proposed New Syntax For Calling Code Blocks was Jambunathan K
2010-09-10 21:12 ` Jambunathan K
2010-09-13 12:05 ` Proposed New Syntax For Calling Code Blocks was: Problem with Babel and sessions Christopher Witte
2010-09-18 12:24 ` Eric Schulte
2010-09-14 19:03 ` Sébastien Vauban
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=87vd6deafb.fsf@gmail.com \
--to=schulte.eric@gmail.com \
--cc=chris@witte.net.au \
--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).