From: Eric Schulte <schulte.eric@gmail.com>
To: Rainer@krugs.de
Cc: emacs orgmode-mailinglist <Emacs-orgmode@gnu.org>
Subject: Re: [babel] Using :prologue and :epilogue with unbalanced brackets
Date: Sun, 26 Jan 2014 11:16:51 -0700 [thread overview]
Message-ID: <87ppnewnzf.fsf@gmail.com> (raw)
In-Reply-To: 52DE4BBD.4090807@krugs.de
Rainer M Krug <Rainer@krugs.de> writes:
> On 01/20/14, 16:34 , Eric Schulte wrote:
>> Rainer M Krug <Rainer@krugs.de> writes:
>>
>>> Hi
>>>
>>> I would like to use :prologue and :epilogue to enclose the code block
>>> in a local({}) block, i.e.
>>>
>>> * test
>>> #+begin_src R :prologue local({ :epilogue })
>>> qwerty <- "test"
>>> #+end_src
>>>
>>
>> I tried wrapping the prologue and epilogue values in quotes so that they
>> would be interpreted as strings, and I no longer see the problem you
>> describe and it works in a session, but I get a different R issues
>> outside of a session.
>
> Agreed -
>
> * test
> #+begin_src R :results output :prologue "local({" :epilogue "})" :session
> cat("Test")
> #+end_src
>
> #+RESULTS:
>
> no :session nothing happens
>
> using :session the execution does not complete because the :epilogue is not appended.
>
The problem here is when `org-babel-balanced-split' parses the following
string.
":results output :prologue \"local({\" :epilogue \"})\" :session"
It isn't smart enough to *not* balance the ({}) parens because of the
enclosing quotes. Unfortunately I don't have time to address this right
now. A hacky work around would be the following...
#+headers: :epilogue "})"
#+headers: :prologue "local({"
#+begin_src R :results output :session
cat("Test")
#+end_src
Best,
>
>
> * test 2
> #+begin_src R :results output :prologue "cat(1, '###\n')" :epilogue "cat(2, '###\n')" :session
> cat("Test\n")
> #+end_src
>
> #+RESULTS:
> : 1 ###
> : Test
>
> works under :session and without
>
> but
> * test 2
> #+begin_src R :results output :prologue "{cat(1, 2 )" :epilogue "cat(2, 3)}" :session
> cat("Test\n")
> #+end_src
>
> works only without :session as R is waiting for the "}" which is in the :epilogue but which is not added.
>
> Cheers,
>
> Rainer
>
>
>>
>> Best,
>>
>>>
>>> But the problem seems to be the unbalanced brackets, and everything is
>>> passed on as the prologue, as I get the error:
>>>
>>> Error: unexpected ':' in:
>>> "{
>>> local({ :"
>>> Execution halted
>>>
>>> Can I somehow use unbalanced brackets, or is this a missing option in
>>> epilogue and prologue?
>>>
>>> Cheers,
>>>
>>> Rainer
>>>
>>>
>>> --
>>> Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation
>>> Biology, UCT), Dipl. Phys. (Germany)
>>>
>>> Centre of Excellence for Invasion Biology
>>> Stellenbosch University
>>> South Africa
>>>
>>> Tel : +33 - (0)9 53 10 27 44
>>> Cell: +33 - (0)6 85 62 59 98
>>> Fax : +33 - (0)9 58 10 27 44
>>>
>>> Fax (D): +49 - (0)3 21 21 25 22 44
>>>
>>> email: Rainer@krugs.de
>>>
>>> Skype: RMkrug
>>
>
> --
> Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany)
>
> Centre of Excellence for Invasion Biology
> Stellenbosch University
> South Africa
>
> Tel : +33 - (0)9 53 10 27 44
> Cell: +33 - (0)6 85 62 59 98
> Fax : +33 - (0)9 58 10 27 44
>
> Fax (D): +49 - (0)3 21 21 25 22 44
>
> email: Rainer@krugs.de
>
> Skype: RMkrug
--
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D
next prev parent reply other threads:[~2014-01-26 19:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-20 14:11 [babel] Using :prologue and :epilogue with unbalanced brackets Rainer M Krug
2014-01-20 15:34 ` Eric Schulte
2014-01-21 10:28 ` Rainer M Krug
2014-01-26 18:16 ` Eric Schulte [this message]
2014-01-27 9:16 ` Rainer M Krug
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=87ppnewnzf.fsf@gmail.com \
--to=schulte.eric@gmail.com \
--cc=Emacs-orgmode@gnu.org \
--cc=Rainer@krugs.de \
/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).