emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Berry, Charles" <ccberry@health.ucsd.edu>
To: Michael Gauland <mikelygee@gmail.com>
Cc: emacs-orgmode <emacs-orgmode@gnu.org>
Subject: Re: Babel: Store script in external file
Date: Tue, 17 Dec 2019 18:08:01 +0000	[thread overview]
Message-ID: <D18DBC8D-5A8E-4F4B-8E61-1AA7A714D041@ucsd.edu> (raw)
In-Reply-To: <CA+boh8zhh6JnDZ2vFgEpQkTS=gz5nDJM-kKvgye2BO+pqsOkGA@mail.gmail.com>



> On Dec 16, 2019, at 1:53 PM, Michael Gauland <mikelygee@gmail.com> wrote:
> 
> I've just started playing with #+INCLUDE, so I may not be using it correctly, but this works for me.

Indeed, if what the OP wants is to wrap just that code as a src block and export it and any results it produces during export then that is the way to go. 

However, `org-babel-execute-buffer' , `org-babel-tangle' and so on will not honor the #+INCLUDE directive unless an export is in progress.

HTH,

Chuck

> 
> I have a file 'sh_test', which looks like:
> for i in $(seq 10); do
>     echo $i
> done
> 
> My org file:
> #+HEADER: :exports both
> #+INCLUDE: "sh_test" src sh
> 
> And the results:
> 
> ,----
> | for i in $(seq 10); do
> |     echo $i
> | done
> `----
> 
>   1
>   2
>   3
>   4
>   5
>   6
>   7
>   8
>   9
>  10
> 
> Hope that helps.
> 
> Kind regards,
> Mike
> 
> 
> On Mon, Dec 16, 2019 at 2:22 PM Nathan Neff <nathan.neff@gmail.com> 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.
> 
> Thanks,
> --Nate

      reply	other threads:[~2019-12-17 18:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-16  1:21 Babel: Store script in external file Nathan Neff
2019-12-16 10:09 ` Michael Welle
2019-12-16 18:35 ` Berry, Charles
2019-12-16 21:53 ` Michael Gauland
2019-12-17 18:08   ` Berry, Charles [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=D18DBC8D-5A8E-4F4B-8E61-1AA7A714D041@ucsd.edu \
    --to=ccberry@health.ucsd.edu \
    --cc=emacs-orgmode@gnu.org \
    --cc=mikelygee@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).