4

Is it possible for a code-block in one org file to include a noweb reference to a code-block in another org file?

4

In the case of dereferencing noweb references for export the include feature of Org does the trick.

Example (see the Org mode info pages for the fullest-disk code):

#+BEGIN_SRC sh :tangle yes :noweb yes :shebang #!/bin/sh
<<fullest-disk>>
#+END_SRC
#+INCLUDE: "path to the org file defining fullest-disk"

AFAICS the include feature does not work for tangling.

For getting a tangle one could concatenate the files. E.g.

cat my-code-blocks-lib.org main.org > tangle-me.org

and then tangle file tangle-me.org.

And also note the library of babel aka lob. You can ingest a file into the lob which means that its source code blocks are available in every Org file.

E.g. have a file chilllib.org:

#+NAME: chill
#+BEGIN_SRC shell
echo chill...
#+END_SRC

Then ingest

M-x org-babel-lob-ingest chilllib.org

and use e.g. the following block in some Org file for execution or tangling

#+BEGIN_SRC shell :tangle yes :noweb yes :shebang #!/bin/sh
<<chill>>
#+END_SRC

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.