emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nick Dokos <ndokos@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: Babel: How to call code in one org file into another org file
Date: Mon, 02 Nov 2015 08:36:54 -0500	[thread overview]
Message-ID: <87ziyw7cax.fsf@pierrot.dokosmarshall.org> (raw)
In-Reply-To: 87fv0ozxku.fsf@delle7240.chemeng.ucl.ac.uk

Eric S Fraga <e.fraga@ucl.ac.uk> writes:

> On Saturday, 31 Oct 2015 at 16:51, Lawrence Bottorff wrote:
>> I guess I'm saying that the whole `org-babel-lob-ingest` into
>> `org-babel-library-of-babel` exercise should make code ready and available.
>
> But it does.  There are two levels here: the babel codes and the results
> of the codes.  If your babel codes are emacs which define functions,
> these latter functions are not available until the babel codes are
> executed.  However, the babel codes are now there and ready to be
> executed by name.
>
> I would not want ingest to execute the codes for two reasons: many of
> the codes do not make sense without special arguments and there may be
> many such codes.

Indeed - and just to amplify this a bit, you can arrange (and it's
arguably "better" if you have files whose code blocks you want to reuse)
for all the relevant files to be in org-babel-library-of-babel during
initialization; you do not *need* to have them added through the Local
Variables trick: just add org-babel-lob-ingest calls to .emacs.

You can also add the block evaluations in your .emacs, but that is
probably a bad idea as Eric points out. Instead, use Local Variables
with

eval: (org-sbe "foo")

calls to evaluate just what you need for the current buffer (and make
sure that the relevant inferior process running the language interpreter
is started *before* you open the file: emacs-lisp is exempt, since
it's always there).

The difference of opinion arises in the interpretation of "ready and
available". The LOB in this case (and maybe in all cases, but I haven't
used it often enough to be able to make such a statement) behaves more
like an #include file in C, rather than a library of precompiled code
that you link against (think libc.so or equivalent): you need to
"compile" (i.e. evaluate) the code block before it becomes available
to your code.

-- 
Nick

  reply	other threads:[~2015-11-02 13:37 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-30 20:21 Babel: How to call code in one org file into another org file Lawrence Bottorff
2015-10-30 20:53 ` John Kitchin
2015-10-30 20:55 ` Thomas S. Dye
2015-10-30 22:57   ` briangpowell .
2015-10-31  0:14   ` Lawrence Bottorff
     [not found]     ` <m21tcbx2iy.fsf@andrew.cmu.edu>
2015-10-31  2:12       ` Lawrence Bottorff
2015-10-31  2:15         ` Lawrence Bottorff
2015-10-31  3:08     ` Thomas S. Dye
2015-10-31  3:58       ` Lawrence Bottorff
2015-10-31 15:41         ` Nick Dokos
2015-10-31 16:17           ` Lawrence Bottorff
2015-10-31 16:34             ` Nick Dokos
2015-10-31 16:51               ` Lawrence Bottorff
2015-11-02  7:09                 ` Eric S Fraga
2015-11-02 13:36                   ` Nick Dokos [this message]
2015-10-31  9:57 ` Rasmus
  -- strict thread matches above, loose matches on Subject: below --
2015-10-31  2:24 John Kitchin
2015-10-31  2:33 ` Lawrence Bottorff

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=87ziyw7cax.fsf@pierrot.dokosmarshall.org \
    --to=ndokos@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /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).