emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: John Hendy <jw.hendy@gmail.com>
To: suvayu ali <fatkasuvayu+linux@gmail.com>
Cc: emacs-orgmode <emacs-orgmode@gnu.org>
Subject: Re: Selective export of Babel code blocks
Date: Mon, 18 Jun 2012 11:50:05 -0500	[thread overview]
Message-ID: <CA+M2ft9_a2QFmdOAr8XZN5ic_-wnLHxOjbxLek7NhfSMUts3Ng@mail.gmail.com> (raw)
In-Reply-To: <CAMXnza2wtDSU8trkTJHRfQ8zZN5gZH=7qSfhGyuMZ_5DsZNLaQ@mail.gmail.com>

On Mon, Jun 18, 2012 at 11:08 AM, suvayu ali
<fatkasuvayu+linux@gmail.com> wrote:
> Hi John,
>
> On Mon, Jun 18, 2012 at 4:53 PM, John Hendy <jw.hendy@gmail.com> 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.

>
>  #+PROPERTY: noweb yes
>  #+PROPERTY: results silent
>  #+BIND: org-confirm-babel-evaluate nil
>
>  * Gnuplot source
>  #+name: preamble
>  #+begin_src gnuplot
>    reset
>    set terminal pdfcairo color size 21cm,14.8cm
>    set termoption enhanced
>    set encoding utf8
>    set termoption font "DejaVuSerif,8"
>    # ...
>  #+end_src
>
>  #+begin_src gnuplot :noweb yes :var limits=Bpluslimits
>    <<preamble>>
>    plot "$limits" using 1:2 title 'Theory'  set output
>  #+end_src
>
>  * Table
>  #+tblname: Bpluslimits
>  |   |  Theory |
>  |   |         |
>  |---+---------|
>  | 1 | 3.6E-14 |
>  | 2 | 3.6E-14 |
>  | 3 | 6.3E-13 |
>  | 4 | 6.3E-13 |
>  | 5 | 1.7E-14 |
>  | 6 | 1.7E-14 |
>  | 7 |         |
>  #+tblfm: $1=(@#-2)
>
>  * COMMENT local setup
>
>  # Local Variables:
>  # org-export-allow-BIND: t
>  # 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 like:

<<preamble(file-name=file_1.tex)>>

Or something like this? I didn't see much coverage explaining the
whole <<example-block(a=9>> 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.

  reply	other threads:[~2012-06-18 16:50 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-18 14:53 Selective export of Babel code blocks John Hendy
2012-06-18 16:08 ` suvayu ali
2012-06-18 16:50   ` John Hendy [this message]
2012-06-18 17:08     ` suvayu ali
2012-06-18 17:37       ` William LÉCHELLE
2012-06-18 17:11 ` Thomas S. Dye
2012-06-18 17:16   ` suvayu ali
2012-06-18 17:31     ` John Hendy
2012-06-18 18:06       ` Andreas Leha
2012-06-18 19:05     ` Thomas S. Dye
2012-06-19 12:55       ` suvayu ali
2012-06-19 13:36         ` John Hendy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CA+M2ft9_a2QFmdOAr8XZN5ic_-wnLHxOjbxLek7NhfSMUts3Ng@mail.gmail.com \
    --to=jw.hendy@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=fatkasuvayu+linux@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).