From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christopher Witte Subject: Re: Proposed New Syntax For Calling Code Blocks was: Problem with Babel and sessions Date: Mon, 13 Sep 2010 14:05:32 +0200 Message-ID: References: <87vd6deafb.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1667563625==" Return-path: Received: from [140.186.70.92] (port=36494 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ov7my-0002jf-PV for emacs-orgmode@gnu.org; Mon, 13 Sep 2010 08:05:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Ov7mx-0007QU-8X for emacs-orgmode@gnu.org; Mon, 13 Sep 2010 08:05:36 -0400 Received: from mail-bw0-f41.google.com ([209.85.214.41]:63556) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Ov7mw-0007QG-Vi for emacs-orgmode@gnu.org; Mon, 13 Sep 2010 08:05:35 -0400 Received: by bwz6 with SMTP id 6so5532636bwz.0 for ; Mon, 13 Sep 2010 05:05:32 -0700 (PDT) In-Reply-To: <87vd6deafb.fsf@gmail.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Eric Schulte Cc: Org Mode --===============1667563625== Content-Type: multipart/alternative; boundary=001636eefc8ace3866049022e9e8 --001636eefc8ace3866049022e9e8 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Thanks for reply Eric. Thanks for the reply. The reason why I wanted this was because I have multiple sets of data and I would like to be able to apply the same code block to the different sets of data and have the results in different pdfs. Is there anyway to do this with the current version of org? Cheers, Chris On 10 September 2010 20:06, Eric Schulte wrote: > 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=3DchartPolAngle(pol=3DtableTestBabel) > :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=3DtableTestBabel) > > 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 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 result= s > > :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=3Dlist(a1=3D3.0, a2=3D7.0, a3=3D180, a4=3D0.0)) > > lines(spline(angle, fitted.values(energy.model)), lwd=3D2) > > summary(energy.model) > > #+end_src > > > > #+call: chartPolAngle(pol=3DtableTestBabel) :session testBabel :file > testBabel.pdf > > > > #+results: chartPolAngle(pol=3DtableTestBabel) > > : 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=3DtableTestBabel) > > > > #+results: chartPolAngle(pol=3DtableTestBabel) > > : 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=3Dlist(a1=3D3.0, a2=3D7.0, a3=3D180, a4=3D0.0)) > > lines(spline(angle, fitted.values(energy.model)), lwd=3D2) > > 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 > --=20 Postdoctoral Research Fellow Molecular Imaging Group Leibniz-Institut f=FCr Molekulare Pharmakologie (FMP) Campus Berlin-Buch Robert-Roessle-Str. 10 13125 Berlin, Germany Phone: 00493094793-279 --001636eefc8ace3866049022e9e8 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Thanks for reply Eric.

Thanks for the reply.=A0 The reason why I wan= ted this was because I have multiple sets of data and I would like to be ab= le to apply the same code block to the different sets of data and have the = results in different pdfs.=A0 Is there anyway to do this with the current v= ersion of org?

Cheers,
Chris

On 10 September 2010= 20:06, Eric Schulte <schulte.eric@gmail.com> wrote:
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. =A0To 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=3DchartPolAngle(pol=3DtableTestBabel) := session testBabel:file
=A0results
#+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. =A0Notice that header arguments like :results silent, will have<= br> 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. =A0I'm not sure how best to do th= at,
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. =A0Using this new proposed
syntax your example below would be written as

#+call: chartPolAngle[:session testBabel :file testBabel.pdf](pol=3DtableTe= stBabel)

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 ex= ecute the
> code below (C-c C-c on the call line), as you can see, I get the resul= ts
> :nil
>
> ---------------------------------------
> #+tblname: tableTestBabel
> | =A0 0 | 4.40 |
> | =A030 | 4.54 |
> | =A060 | 7.09 |
> | =A090 | 9.40 |
> | 120 | 9.22 |
> | 150 | 6.65 |
> | 180 | 4.22 |
>
> #+srcname: chartPolAngle(pol)
> #+begin_src R
> =A0 angle <- pol[,1]
> =A0 energy <- pol[,2]
> =A0 plot(angle,energy)
> =A0 energy.model <- =A0nls (energy ~ a1 + a2 * (sin(pi / a3 *(angle= -a4)))^2,
> start=3Dlist(a1=3D3.0, a2=3D7.0, a3=3D180, a4=3D0.0))
> =A0 lines(spline(angle, fitted.values(energy.model)), lwd=3D2)
> =A0 summary(energy.model)
> #+end_src
>
> #+call: chartPolAngle(pol=3DtableTestBabel) :session testBabel :file t= estBabel.pdf
>
> #+results: chartPolAngle(pol=3DtableTestBabel)
> : 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] sta= rting data
> directory? ~/doc/org/" which I don't get with the code above.=
>
> ---------------------------------------
> #+tblname: tableTestBabel
> | =A0 0 | 4.40 |
> | =A030 | 4.54 |
> | =A060 | 7.09 |
> | =A090 | 9.40 |
> | 120 | 9.22 |
> | 150 | 6.65 |
> | 180 | 4.22 |
>
> #+call: chartPolAngle(pol=3DtableTestBabel)
>
> #+results: chartPolAngle(pol=3DtableTestBabel)
> : testBabel.pdf
>
>
> #+srcname: chartPolAngle(pol)
> #+begin_src R :session testBabel :file testBabel.pdf
> =A0 angle <- pol[,1]
> =A0 energy <- pol[,2]
> =A0 plot(angle,energy)
> =A0 energy.model <- =A0nls (energy ~ a1 + a2 * (sin(pi / a3 *(angle= -a4)))^2,
> start=3Dlist(a1=3D3.0, a2=3D7.0, a3=3D180, a4=3D0.0))
> =A0 lines(spline(angle, fitted.values(energy.model)), lwd=3D2)
> =A0 summary(energy.model)
> #+end_src
> ---------------------------------------
>
> Org doesn't appear to respect the head arguments on the call. I pu= lled 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



--
<= span style=3D"color: rgb(102, 102, 102);">Postdoctoral Research Fellow
Molecular Imaging Group
Leibniz-Ins= titut f=FCr Molekulare Pharmakologie (FMP)
Campus Berlin-Buch
Robert-Roessle-Str. 1013125 Berlin, Germany
= Phone: 00493094793-279

--001636eefc8ace3866049022e9e8-- --===============1667563625== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ 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 --===============1667563625==--