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 11:50:05 -0500 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([208.118.235.92]:57398) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sgf9b-0004h7-70 for emacs-orgmode@gnu.org; Mon, 18 Jun 2012 12:50:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sgf9U-0007ec-89 for emacs-orgmode@gnu.org; Mon, 18 Jun 2012 12:50:14 -0400 Received: from mail-bk0-f41.google.com ([209.85.214.41]:34776) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sgf9T-0007dc-UX for emacs-orgmode@gnu.org; Mon, 18 Jun 2012 12:50:08 -0400 Received: by bkcjm19 with SMTP id jm19so5034790bkc.0 for ; Mon, 18 Jun 2012 09:50:05 -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 On Mon, Jun 18, 2012 at 11:08 AM, suvayu ali wrote: > Hi John, > > On Mon, Jun 18, 2012 at 4:53 PM, John Hendy wrote: >> Doing this got me to thinking how it would be >> quite neat to run code in a block but mark it to be omitted from >> export for these kind of "setup" lines that are necessary for the >> desired graphs but unnecessary for your reader to see over and over >> again. >> >> Thoughts? I'm quite a novice and very possibly missed something that >> can already do this. > > Hopefully I understood your question correctly. My solution to "setup" > code blocks is use the noweb syntax. Following is an example with Gnuplot= . > I didn't get it at first as I'm not familiar with noweb, but after reading a bit, I think I get it. > > =C2=A0#+PROPERTY: noweb yes > =C2=A0#+PROPERTY: results silent > =C2=A0#+BIND: org-confirm-babel-evaluate nil > > =C2=A0* Gnuplot source > =C2=A0#+name: preamble > =C2=A0#+begin_src gnuplot > =C2=A0 =C2=A0reset > =C2=A0 =C2=A0set terminal pdfcairo color size 21cm,14.8cm > =C2=A0 =C2=A0set termoption enhanced > =C2=A0 =C2=A0set encoding utf8 > =C2=A0 =C2=A0set termoption font "DejaVuSerif,8" > =C2=A0 =C2=A0# ... > =C2=A0#+end_src > > =C2=A0#+begin_src gnuplot :noweb yes :var limits=3DBpluslimits > =C2=A0 =C2=A0<> > =C2=A0 =C2=A0plot "$limits" using 1:2 title 'Theory' =C2=A0set output > =C2=A0#+end_src > > =C2=A0* Table > =C2=A0#+tblname: Bpluslimits > =C2=A0| =C2=A0 | =C2=A0Theory | > =C2=A0| =C2=A0 | =C2=A0 =C2=A0 =C2=A0 =C2=A0 | > =C2=A0|---+---------| > =C2=A0| 1 | 3.6E-14 | > =C2=A0| 2 | 3.6E-14 | > =C2=A0| 3 | 6.3E-13 | > =C2=A0| 4 | 6.3E-13 | > =C2=A0| 5 | 1.7E-14 | > =C2=A0| 6 | 1.7E-14 | > =C2=A0| 7 | =C2=A0 =C2=A0 =C2=A0 =C2=A0 | > =C2=A0#+tblfm: $1=3D(@#-2) > > =C2=A0* COMMENT local setup > > =C2=A0# Local Variables: > =C2=A0# org-export-allow-BIND: t > =C2=A0# End: > Gotcha. So I can define a preamble/postamble and be all set. Still struggling on how to make this work for each file, though. I'm guessing I need something like: #+name: preamble #+begin_src R :exports none tikzDevice("file-name") #+end_src And by the org-mode Babel documentation it looks like I can do something li= ke: <> Or something like this? I didn't see much coverage explaining the whole <> bit at the end of the noweb section: - http://orgmode.org/worg/org-contrib/babel/intro.html#literate-programming I think this will work; I just need the bit on variable substitution. Thanks a ton! John > HTH > > -- > Suvayu > > Open source is the future. It sets us free.