From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alan Schmitt Subject: Re: How do I chain babel blocks with arguments? Date: Thu, 17 Apr 2014 12:11:07 +0200 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:45729) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WajHq-0007oH-5f for emacs-orgmode@gnu.org; Thu, 17 Apr 2014 06:11:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WajHk-0003Ey-Jf for emacs-orgmode@gnu.org; Thu, 17 Apr 2014 06:11:18 -0400 Received: from mail2-relais-roc.national.inria.fr ([192.134.164.83]:11930) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WajHk-0003EH-D8 for emacs-orgmode@gnu.org; Thu, 17 Apr 2014 06:11:12 -0400 In-Reply-To: (Charles Berry's message of "Wed, 16 Apr 2014 20:49:43 +0000 (UTC)") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Charles Berry Cc: emacs-orgmode@gnu.org Hello Charles, On 2014-04-16 22:49, Charles Berry 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