0

I have a document with only several source code blocks that should be tangled. So the structure is:

    # Some main.org
    ...
    #+BEGIN_SRC awk :tangle file1.awk
    ...
    #+END_SRC awk
    ...
    ...
    #+BEGIN_SRC awk :tangle file2.awk
    #+END_SRC
    ...

Firstly, I have noticed that just exporting main.org is not goint to trigger tangling. Then, I decided to add a call to (org-babel-tangle) somewhere at the top of main.org. This call will produce file1.awk and file2.awk, but will also have an undesired side-effect of tangling the entire main.org file (#+INCLUDE directives substituted with contents of the included files, macros substituted, ...) into, well, main.org. How to avoid this behavior and produce only the files intended for tangling?

  • The key sequence C-c C-v t tangles the current org-file. For the combination of tangling and exporting there exists already an answer: emacs.stackexchange.com/a/29472/2370. Whereas I am willing to re-treat my close-vote if you insinst on tangling by a command in the org-buffer. – Tobias Feb 21 '18 at 12:11
  • 1
    Possible duplicate of Exporting and Tangling simultaneously in org mode – Tobias Feb 21 '18 at 12:12
  • I don't have time now, but I'll try to edit the question later to point out that I want to do it by invoking a lisp prologue, if possible. – Mali Remorker Feb 21 '18 at 12:29
0

The following org-file works for me with emacs 25.3.2 and org-version 9.1.6:

# Some main.org
#+BEGIN_SRC emacs-lisp :results silent :exports results
(org-babel-tangle)
#+END_SRC
#+INCLUDE includeFile.org
#+BEGIN_SRC emacs-lisp :tangle file1.el
"Contents of file1.el"
#+END_SRC

#+BEGIN_SRC emacs-lisp :tangle file2.el
"Contents of file2.el"
#+END_SRC

The contents of includeFile.org for that test is:

* This is includeFile.org
Some text here.

After export to HTML the files file1.el and file2.el are tangled and I am notified that main.org has changed but the contents of main.org remains the same after answering with y and also after M-x revert-buffer. The relevant content of the generated html file is:

generated html file

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.