From: Dan Davison <davison@stats.ox.ac.uk>
To: Francesco Pizzolante <fpz@missioncriticalit.com>
Cc: mailing-list-org-mode <emacs-orgmode@gnu.org>
Subject: Re: [babel] Executing source block which includes another block
Date: Thu, 10 Dec 2009 11:20:48 -0500 [thread overview]
Message-ID: <87vdge3in3.fsf@stats.ox.ac.uk> (raw)
In-Reply-To: <87k4wudhe8.fsf@missioncriticalit.com> (Francesco Pizzolante's message of "Thu, 10 Dec 2009 15:37:35 +0100")
Francesco Pizzolante <fpz@missioncriticalit.com> writes:
> Hi,
>
> Here's a small example where I'm interested both in tangling source blocks and
> executing sources blocks in my org buffer:
>
> * Test
>
> ** Common part
>
> #+srcname: common
> #+begin_src sh :exports none :results silent
> VAR=ThisIsATest
> #+end_src
>
> ** My shell script
>
> #+srcname: script
> #+begin_src sh :exports results :tangle my-script
> <<common>>
> date
> echo $VAR
> #+end_src
>
>
> When I tangle the script block, I correctly get the following my-script.sh
> file:
>
> #!/usr/bin/env sh
> # generated by org-babel-tangle
> # [[id:a0232b32-0b2c-4105-94ae-8c0f1ca67101][script]]
> VAR=ThisIsATest
> date
> echo $VAR
> # script ends here
>
>
> When I try to execute (C-cC-c) the same script block I get the following
> result:
>
> #+results: script
> | "sh:" | "line" | "6:" | "syntax" | "error" | "near" | "unexpected" | "token" | "`newline'" |
> | "sh:" | "line" | "6:" | "`<<common>>'" | "" | "" | "" | "" | "" |
>
> The included <<common>> block should also be executed when executing the
> <<script>> block.
>
> Is there another way of doing?
Hi Francesco,
Thanks for the very clear example. I believe that adding the :noweb
header argument as below solves your problem. I'm sorry that this is not
yet documented.
Dan
-------------------------------------------------------------------
* Test
** Common part
#+srcname: common
#+begin_src sh :exports none :results silent
VAR=ThisIsATest
#+end_src
** My shell script
#+srcname: script
#+begin_src sh :exports results :noweb :tangle my-script
<<common>>
date
echo $VAR
#+end_src
#+results: script
| "Thu" | "Dec" | 10 | "11:15:57" | "EST" | 2009 |
| "ThisIsATest" | "" | "" | "" | "" | "" |
-------------------------------------------------------------------
>
> Thanks,
> Francesco
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
next prev parent reply other threads:[~2009-12-10 16:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-10 14:37 [babel] Executing source block which includes another block Francesco Pizzolante
2009-12-10 16:20 ` Dan Davison [this message]
[not found] ` <87vdge3in3.fsf-+7o2aNKnwVPQzY9nttDBhA@public.gmane.org>
2009-12-11 9:01 ` Francesco Pizzolante
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=87vdge3in3.fsf@stats.ox.ac.uk \
--to=davison@stats.ox.ac.uk \
--cc=emacs-orgmode@gnu.org \
--cc=fpz@missioncriticalit.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).