From: Alan Schmitt <alan.schmitt@polytechnique.org>
To: Charles Berry <ccberry@ucsd.edu>
Cc: emacs-orgmode@gnu.org
Subject: Re: How do I chain babel blocks with arguments?
Date: Thu, 17 Apr 2014 12:11:07 +0200 [thread overview]
Message-ID: <m2k3aob70k.fsf@polytechnique.org> (raw)
In-Reply-To: <loom.20140416T224605-94@post.gmane.org> (Charles Berry's message of "Wed, 16 Apr 2014 20:49:43 +0000 (UTC)")
Hello Charles,
On 2014-04-16 22:49, Charles Berry <ccberry@ucsd.edu> writes:
>> I have several babel blocks that each work well, but I'm now trying to
>> chain them to build some bigger functionality out of them. I'm having
>> trouble finding out how to pass arguments between blocks. Here is
>> a small example:
>>
>> --8<---------------cut here---------------start------------->8---
>> #+name: test1
>> #+begin_src emacs-lisp :var x="foo"
>> x
>> #+end_src
>>
>> #+name:test2
>> #+begin_src emacs-lisp :var z="bar" :var y=test1(x=z)
>> y
>> #+end_src
>>
>> #+call: test2(z="baz")
>> --8<---------------cut here---------------end--------------->8---
>>
>> Unfortunately this does not work: the evaluation of block `test2' fails
>> by telling me `z' does not exist.
>>
>> How can I execute block `test1' from block `test2' by passing an
>> argument that is one from test2?
>
> This is not pretty, but it works:
>
> #+name:test2
> #+begin_src emacs-lisp :var z="bar"
> (let ((y (org-sbe test1 (x (intern z)))))
> y)
> #+end_src
Thank you for the suggestion, but it returns a symbol and not the
string. In the more complex setting I'm playing with I need a string
there.
By the way, this is something that I really don't understand about sbe:
what is allowed as functions inside it? If I do the simple
--8<---------------cut here---------------start------------->8---
#+name:test2
#+begin_src emacs-lisp :var z="bar"
(let ((y (org-sbe test1 (x z))))
y)
#+end_src
--8<---------------cut here---------------end--------------->8---
then it fails, telling me 'z' does not exist. But for some reason,
adding "intern" lets 'z' get the "bar" value and be converted to the bar
symbol.
Is there documentation about what is allowed in sbe? (I had another
similar problem recently, see
http://thread.gmane.org/gmane.emacs.orgmode/84522).
Thanks,
Alan
next prev parent reply other threads:[~2014-04-17 10:11 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-16 17:04 How do I chain babel blocks with arguments? Alan Schmitt
2014-04-16 20:49 ` Charles Berry
2014-04-17 10:11 ` Alan Schmitt [this message]
2014-04-17 10:24 ` Thorsten Jolitz
2014-04-17 11:37 ` Alan Schmitt
2014-04-17 5:42 ` Eric Schulte
2014-04-18 6:43 ` Alan Schmitt
2014-04-20 1:41 ` Eric Schulte
2014-04-20 3:33 ` Xebar Saram
2014-04-21 1:22 ` Eric Schulte
2014-04-22 6:53 ` Alan Schmitt
2014-04-22 11:30 ` Eric Schulte
2014-04-22 12:47 ` Alan Schmitt
2014-04-24 1:16 ` Eric Schulte
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m2k3aob70k.fsf@polytechnique.org \
--to=alan.schmitt@polytechnique.org \
--cc=ccberry@ucsd.edu \
--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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.