From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andreas Leha Subject: Re: tangle on export Date: Thu, 24 Sep 2015 13:14:57 +0100 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:43732) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zf5Qm-0000xI-US for emacs-orgmode@gnu.org; Thu, 24 Sep 2015 08:15:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zf5Qh-00014K-4w for emacs-orgmode@gnu.org; Thu, 24 Sep 2015 08:15:20 -0400 Received: from plane.gmane.org ([80.91.229.3]:43418) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zf5Qg-000147-VZ for emacs-orgmode@gnu.org; Thu, 24 Sep 2015 08:15:15 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1Zf5Qe-0007W4-89 for emacs-orgmode@gnu.org; Thu, 24 Sep 2015 14:15:12 +0200 Received: from 193.63.221.9 ([193.63.221.9]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 24 Sep 2015 14:15:12 +0200 Received: from andreas.leha by 193.63.221.9 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 24 Sep 2015 14:15:12 +0200 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: emacs-orgmode@gnu.org Hi Alan, Rainer M Krug writes: > Alan Schmitt writes: > >> Hello, >> >> I have a question I feel is very basic but I did not find the answer in >> the manual. How can I trigger the tangling of a block upon export. > > Tangling and exporting are two different paths (well - one could see > tangling as a special case of exporting). > > You have to use an export hook (see > http://orgmode.org/tmp/worg/org-configs/org-hooks.html for a list of > hooks in org). > > I have done something similar to run a post-tangle hook: > > #+begin_src emacs-lisp > (defvar org-babel-tangle-run-postTangleScript nil > "If non-nil, postTangleScript.sh will be executed") > (put 'org-babel-tangle-run-postTangleScript 'safe-local-variable 'booleanp) > > (defun org-babel-run-post-tangle-script () > (when org-babel-tangle-run-postTangleScript > (message "running the postTangleScript.sh bash shell script") > (shell-command "bash ./postTangleScript.sh"))) > > (add-hook 'org-babel-post-tangle-hook 'org-babel-run-post-tangle-script) > #+end_src > > Cheers, > > Rainer > >> >> More precisely, I want to give the following example in a lecture: >> >> #+name:hello >> #+begin_src ocaml :tangle myprog.ml >> Printf.printf "Bonjour le monde !\n" >> #+end_src >> #+BEGIN_SRC sh :exports both :results verbatim >> ocamlc -o myprog myprog.ml >> ./myprog >> #+END_SRC >> >> where I show a program to be compiled and actually compile it. Is there >> a header I should put on the "hello" block to tangle it when I export >> it? >> >> Thanks, >> >> Alan if all of this is for a single block, you can get away quite cheaply with sth along (untested) #+begin_src emacs-lisp :results silent (save-excursion ;; tangle (org-babel-goto-named-src-block "hello") (org-babel-tangle '(4))) #+end_src and make sure this gets executed during export. Regards, Andreas