[Orgmode] [babel] Executing source block which includes another block

2009-12-10 Thread Francesco Pizzolante
Hi,

Here's a small example where I'm interested both in tangling source blocks and
executing sources blocks in my org buffer:

--8---cut here---start-8---
* 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
--8---cut here---end---8---


When I tangle the script block, I correctly get the following my-script.sh
file:

--8---cut here---start-8---
#!/usr/bin/env sh
# generated by org-babel-tangle
# [[id:a0232b32-0b2c-4105-94ae-8c0f1ca67101][script]]
VAR=ThisIsATest
date
echo $VAR
# script ends here
--8---cut here---end---8---


When I try to execute (C-cC-c) the same script block I get the following
result:

--8---cut here---start-8---
#+results: script
| sh: | line | 6: | syntax   | error | near | unexpected | 
token | `newline' |
| sh: | line | 6: | `common' |   |  ||  
 |   |
--8---cut here---end---8---

The included common block should also be executed when executing the
script block.

Is there another way of doing?

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


Re: [Orgmode] [babel] Executing source block which includes another block

2009-12-10 Thread Dan Davison
Francesco Pizzolante f...@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


___
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