emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] How do I chain babel blocks with arguments?


From: Alan Schmitt
Subject: Re: [O] How do I chain babel blocks with arguments?
Date: Thu, 17 Apr 2014 12:11:07 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (darwin)

Hello Charles,

On 2014-04-16 22:49, Charles Berry <address@hidden> 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]