0

I want to something like following to work:

#+begin_src python :tangle file1.py file2.py
import time
#+end_src

And after tangling, I want both file1.py, file2.py has lines.

How tangle single SRC block into multiple output files?

I found same question 4 years ago. But seems didn't work perhaps the versions aren't same as my emacs & org-version.

Is there any other ways?

Garid
  • 545
  • 1
  • 13

1 Answers1

1

You can have a global (or regional) :prologue that inserts common text at the front of blocks, :epilogue that inserts common text at the end of blocks, or use the more verbose <<noweb>> references to insert common text in the middle.

Not as elegant as the linked answer, but for small use cases, this could be manageable:

Common block

#+NAME: common
#+BEGIN_SRC code
common
#+END_SRC

File foo:

#+BEGIN_SRC code :tangle foo.file
<<<common>>>
foo
#+END_SRC

File bar:

#+BEGIN_SRC code :tangle bar.file
<<<common>>>
bar
#+END_SRC
mankoff
  • 4,108
  • 1
  • 22
  • 39