emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Lawrence Bottorff <borgauf@gmail.com>
To: emacs-orgmode Mailinglist <emacs-orgmode@gnu.org>
Subject: Re: Babel: How to call code in one org file into another org file
Date: Sat, 31 Oct 2015 00:14:52 +0000	[thread overview]
Message-ID: <CAFAhFSXY90XvO5VvUD5FH+ES-UQqqq+nTwOgqph7E5p3mrW01w@mail.gmail.com> (raw)
In-Reply-To: <m2d1vwrs82.fsf@tsdye.com>

[-- Attachment #1: Type: text/plain, Size: 2154 bytes --]

Doing M-x org-babel-lob-files called up a customization buffer that allowed
me to put in many separate file paths. I did this for ../a.org and ../b.org.

a.org:

#+name: myadd
#+begin_src lisp :session
(defun myadd (x y)
  (+ x y))
#+end_src

b.org:

#+name: multi_x2
#+begin_src lisp :session
(defun multi_x2 (x)
  (* 2 x))
#+end_src

then in c.org:

#+name: add&multi_x2
#+begin_src lisp :session
(defun add&multi_x2 (x y)
  (multi_x2 (myadd x y)))
#+end_src

but upon C-c C-c in c.org SLIME didn't know about myadd or multi_x2 ...
until I did C-c C-c in both a.org and b.org for the respective functions.
Then c.org's add&multi_x2 knew about the helper functions. That is
wonderful and allows a very distributed and modular approach to org-mode LP
for Lisp. However, it would be nice if I didn't have to acquaint my SLIME
session by hand all of my ingested babel-lob files. Any way to have this
happen automatically upon C-c C-c-ing my main org file? I found this
<https://lists.gnu.org/archive/html/emacs-orgmode/2010-09/msg01172.html>
discussion,
but I don't believe it really addresses my wish.

LB



On Fri, Oct 30, 2015 at 8:55 PM, Thomas S. Dye <tsd@tsdye.com> wrote:

> Aloha Lawrence,
>
> Lawrence Bottorff <borgauf@gmail.com> writes:
>
> > There are many, many Babel examples, but I can't seem to find this
> > functionality: A function in a Lisp code block in one org file is to be
> > called from a Lisp code block in another org file. Is this possible? I
> know
> > you can stick stuff into your personal "Library of Babel," but I just
> want
> > to write a Lisp block that calls a function from another org file. I'll
> > have SLIME running, of course.
> >
> >
> > file1.org:
> > ...
> >  #+begin_src lisp
> > (defun foo ()
> >    (...))
> > #+end_src
> >
> > is then called from. . .
> >
> > file2.org:
> > ...
> > #+begin_src lisp
> > (defun baa ()
> >   (foo))
> > #+end_src
>
> Any Org mode file can function as Library of Babel.  In your case,
> (org-babel-lob-ingest path/to/file1.org) should do what you want.  Note
> that org-babel-lob-ingest is bound to C-c C-v i.
>
> hth,
> Tom
>
> --
> Thomas S. Dye
> http://www.tsdye.com
>

[-- Attachment #2: Type: text/html, Size: 3694 bytes --]

  parent reply	other threads:[~2015-10-31  0:14 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 [this message]
     [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
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=CAFAhFSXY90XvO5VvUD5FH+ES-UQqqq+nTwOgqph7E5p3mrW01w@mail.gmail.com \
    --to=borgauf@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).