From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Hendy Subject: Re: Selective export of Babel code blocks Date: Mon, 18 Jun 2012 12:31:38 -0500 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Return-path: Received: from eggs.gnu.org ([208.118.235.92]:59298) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sgfnn-0001Oh-Ff for emacs-orgmode@gnu.org; Mon, 18 Jun 2012 13:31:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sgfng-0002l0-To for emacs-orgmode@gnu.org; Mon, 18 Jun 2012 13:31:47 -0400 Received: from mail-bk0-f41.google.com ([209.85.214.41]:45258) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sgfng-0002kc-Fo for emacs-orgmode@gnu.org; Mon, 18 Jun 2012 13:31:40 -0400 Received: by bkcjm19 with SMTP id jm19so5090096bkc.0 for ; Mon, 18 Jun 2012 10:31:38 -0700 (PDT) In-Reply-To: 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 , "Thomas S. Dye" On Mon, Jun 18, 2012 at 12:16 PM, suvayu ali wrote: > 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? > I think Thomas' suggestion would work. Let me try one more time to clarify what I'm doing: ---------- First, I need to define my output file name for R -> tikz code. No code export #+name: preamble #+begin_src R tikzDevice("export-file-name.tex") #+end_src Now, I run my actual code, which executes statistics and generates a plot. I want this code exported in the paper. #+begin_src R ggplot(data, aex(x=x, y=y)) + geom_point() #+end_src Now R is sitting there with a plot in the "buffer" (not sure the proper name). To get it to dump the plot into the tex file, I need to execute =dev.off()=. Then I have to convert the tikz .tex file into a pdf for including in the report: #+name: postamble #+begin_src R dev.off() tools::texi2pdf("export-file-name.tex") #+end_src For the report I'll have many, many iterations of: <> to define my export file Some sort of R code doing something. <> to create the export file and convert to pdf. I obviously can't use the same file name over and over as I'll be overwriting it. Thus, I need some way to set the file name in the preamble (something like <>) and a way to tell the postamble which file to convert to pdf (the same one I created in the preamble). This if this noweb path is going to work, I need to be able to pass file name arguments to tikzDevice() in the first block and tools::texi2pdf() in the last. Is that clearer? I tried to think of an analogous situation in gnuplot where you need the same code block again and again, but with unique names/vars passed, but couldn't. If #+call is doing what I think it does, that definitely could work... again, as long as I can tell the #+call argument which filenames to use in the "master" code blocks. > 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. :) I have session feature enabled in my paper because all subsequent blocks depend on the very first block where I load my data file. If I didn't use session, I'd have to repeat that code again and again or they wouldn't know what data I was accessing/plotting. Your proposal is possible, but again, it's not entirely one "static" block -- it's a block using the same exact functions but with different arguments passed for the unique filenames of each plot. Hopefully this makes sense! Thanks for the input, John > > -- > Suvayu > > Open source is the future. It sets us free.