emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "William LÉCHELLE" <william.lechelle@ens-lyon.fr>
To: emacs-orgmode@gnu.org
Subject: Re: Selective export of Babel code blocks
Date: Mon, 18 Jun 2012 13:37:47 -0400	[thread overview]
Message-ID: <87395sttas.wl%william.lechelle@ens-lyon.fr> (raw)
In-Reply-To: <CAMXnza1yv3W41OOR1=865JUA+zBQc+Y5ieiSGeHDd=+O+yyF4A@mail.gmail.com>

> On Mon, Jun 18, 2012 at 6:50 PM, John Hendy <jw.hendy@gmail.com> wrote:
> > #+name: preamble
> > #+begin_src R :exports none
> > tikzDevice("file-name")
> > #+end_src
> 
> Are you trying to use "file-name" as a variable? if so I think the
> source block header should include this: ":var file-name" and the source
> block can refer to the variable as $file-name.

It seems to me one of both
    ,----[ insert preamble ]
    | <<preamble>>
    | with the preamble having the header
    | :var file-name="file_1.tex"
    `----
or
    ,----[ eval preamble ]
    | <<preamble(file-name="file_1.tex")>>
    | without any :var header
    `----
would be correct syntax, but using :var <variable> without assigning it should fail
(though I didn't test it).

Both wouldn't give the same result…

> > And by the org-mode Babel documentation it looks like I can do
> > something like:
> >
> > <<preamble(file-name=file_1.tex)>>
> 
> I'm not sure about this. The syntax seems correct but I don't quite
> understand the following statement from the manual:
> 
>   It is possible to include the _results_ of a code block rather than
>   the body. This is done by appending parenthesis to the code block name
>   which may optionally contain arguments to the code block as shown
>   below.
> 
>        <<code-block-name(optional arguments)>>
… as I read this as 
"the noweb reference will expand in either 
1. The litteral of the code-block if there are no parenthesis
2. The results of the block (as obtained with C-c C-c or
org-babel-execute-src-block) (which may depend of a :results header, maybe),
if parenthesis are present.
"

So if the OP wants to call the preamble block with an argument in the noweb
reference, then the preamble block might have to be more like
#+name: preamble
#+begin_src R :results output
print(tikzDevice(file-name))
#+end_src
called with 
<<preamble(file-name="file_1.tex")>>

(but I don't know any R either, I just went myself through variable
substitution over the weekend)

Last alternative, which I use, is putting the file name in some named table,
and then passing it as an argument to

    ,----[ insert preamble ]
    | <<preamble>>
    | with the preamble having the header
    | :var file-name=some-table[0,1]
    `----
(Like
#+tblname: some-table
| file        | "file_1.tex" |
)

HTH,

William

  reply	other threads:[~2012-06-18 17:37 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
2012-06-18 17:08     ` suvayu ali
2012-06-18 17:37       ` William LÉCHELLE [this message]
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=87395sttas.wl%william.lechelle@ens-lyon.fr \
    --to=william.lechelle@ens-lyon.fr \
    --cc=emacs-orgmode@gnu.org \
    /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).