From mboxrd@z Thu Jan 1 00:00:00 1970 From: tsd@tsdye.com (Thomas S. Dye) Subject: Re: Selective export of Babel code blocks Date: Mon, 18 Jun 2012 09:05:46 -1000 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([208.118.235.92]:56129) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SghGy-0004kI-4H for emacs-orgmode@gnu.org; Mon, 18 Jun 2012 15:06:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SghGv-0004aS-2H for emacs-orgmode@gnu.org; Mon, 18 Jun 2012 15:05:59 -0400 Received: from oproxy5-pub.bluehost.com ([67.222.38.55]:52909) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1SghGu-0004Yg-Ok for emacs-orgmode@gnu.org; Mon, 18 Jun 2012 15:05:56 -0400 In-Reply-To: (suvayu ali's message of "Mon, 18 Jun 2012 19:16:39 +0200") 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: suvayu ali Cc: emacs-orgmode suvayu ali writes: > Hi Thomas, > > On Mon, Jun 18, 2012 at 7:11 PM, Thomas S. Dye wrote: >> #+CALL: clean-up() :exports none >> >> This way, the original code block will be exported and subsequent calls >> should not be. > > I think John's use case requires other code blocks "using" the common > code block. Can a "CALL" be done from inside a codeblock? > > That said, your post gave me an idea; how about defining a function in > the first code block and then using that in the other blocks. This would > require the session feature of course. :) Hi Suvayu, Yes, there are several ways to accomplish John's goal, depending on how he wants to structure the R code and whether or not he wants to preserve state with one or more sessions. I don't think it is possible to use #+CALL: inside a code block. For that, there is noweb syntax. So, for John's recent code, this should work with or without sessions: #+name: preamble #+begin_src R tikzDevice("export-file-name.tex") #+end_src #+begin_src R :noweb yes <> ggplot(data, aex(x=x, y=y)) + geom_point() #+end_src The :noweb header argument can take several values to control when these noweb references are expanded. Many of these don't show in the Org-mode manual on Worg. Here they are in org.texi: The @code{:noweb} header argument controls expansion of ``noweb'' syntax references (see @ref{Noweb reference syntax}) when the code block is evaluated, tangled, or exported. The @code{:noweb} header argument can have one of the five values: @code{no}, @code{yes}, @code{tangle}, or @code{no-export} @code{strip-export}. @itemize @bullet @item @code{no} The default. ``Noweb'' syntax references in the body of the code block will not be expanded before the code block is evaluated, tangled or exported. @item @code{yes} ``Noweb'' syntax references in the body of the code block will be expanded before the code block is evaluated, tangled or exported. @item @code{tangle} ``Noweb'' syntax references in the body of the code block will be expanded before the code block is tangled. However, ``noweb'' syntax references will not be expanded when the code block is evaluated or exported. @item @code{no-export} ``Noweb'' syntax references in the body of the code block will be expanded before the block is evaluated or tangled. However, ``noweb'' syntax references will not be expanded when the code block is exported. @item @code{strip-export} ``Noweb'' syntax references in the body of the code block will be expanded before the block is evaluated or tangled. However, ``noweb'' syntax references will not be removed when the code block is exported. @item @code{eval} ``Noweb'' syntax references in the body of the code block will only be expanded before the block is evaluated. @end itemize So, John might be satisfied with something like this: #+begin_src R :noweb no-export <> ggplot(data, aex(x=x, y=y)) + geom_point() #+end_src hth, Tom -- Thomas S. Dye http://www.tsdye.com