emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Babel: Store script in external file


From: Berry, Charles
Subject: Re: Babel: Store script in external file
Date: Mon, 16 Dec 2019 18:35:00 +0000


> On Dec 15, 2019, at 5:21 PM, Nathan Neff <address@hidden> wrote:
> 
> Hello all,
> 
> I think I'm missing something basic:  I'd like to have something like this:
> 
> #+begin_src python
> #+filename: foo.py
> 
> Instead of storing my Python code in the current org file, I would like
> Babel to read foo.py and execute it, as if it was inside the .org file.
> 
> The foo.py mentioned above is fairly large, and I would like the code
> to be stored in a different file than my .org file, for brevity.
> 
> Any ideas?  I feel like I'm missing something obvious.

Two things:

1. Library-of-Babel :: lets you store src blocks of code in an external file

2. noweb chunks :: let you insert code into src blocks

See https://orgmode.org/worg/library-of-babel.html and (info "(org) Noweb 
Reference Syntax")

For your example, a file `my-lob.org' with a src-block named foo-py that 
contains what foo.py contains will do it.

Then you eval `(org-babel-lob-ingest "my-lob.org")' any time before executing 
the file that contains this:

#+begin_src python :noweb yes
<<foo-py>>
...

HTH,

Chuck





reply via email to

[Prev in Thread] Current Thread [Next in Thread]