From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lawrence Bottorff Subject: Re: Babel: How to call code in one org file into another org file Date: Sat, 31 Oct 2015 00:14:52 +0000 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a11401f0eda9c6505235b6e7a Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:34243) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZsJot-0008H3-5o for emacs-orgmode@gnu.org; Fri, 30 Oct 2015 20:14:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZsJor-0005PB-NZ for emacs-orgmode@gnu.org; Fri, 30 Oct 2015 20:14:55 -0400 Received: from mail-lf0-x22e.google.com ([2a00:1450:4010:c07::22e]:34261) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZsJor-0005ON-Ax for emacs-orgmode@gnu.org; Fri, 30 Oct 2015 20:14:53 -0400 Received: by lfaz124 with SMTP id z124so42534577lfa.1 for ; Fri, 30 Oct 2015 17:14:52 -0700 (PDT) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode Mailinglist --001a11401f0eda9c6505235b6e7a Content-Type: text/plain; charset=UTF-8 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 discussion, but I don't believe it really addresses my wish. LB On Fri, Oct 30, 2015 at 8:55 PM, Thomas S. Dye wrote: > Aloha Lawrence, > > Lawrence Bottorff 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 > --001a11401f0eda9c6505235b6e7a Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Doing M-x org-babel-lob-files called up a customization bu= ffer that allowed me to put in many separate file paths. I did this for ../= a.org and ../b.org.


#+name: myadd
#+begin_src lisp :session
(d= efun myadd (x y)
=C2=A0 (+ x y))
#+end_src
<= div>

=
#+name: multi_x2
#+begin_src lisp :session
(d= efun multi_x2 (x)
=C2=A0 (* 2 x))
#+end_src
=

then in c.org:
<= br>
#+name: add&multi_x2
#+begin_src lisp :ses= sion
(defun add&multi_x2 (x y)
=C2=A0 (multi_x2 (my= add 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. T= hen c.org's add&multi_x2 knew about th= e helper functions. That is wonderful and allows a very distributed and mod= ular approach to org-mode LP for Lisp. However, it would be nice if I didn&= #39;t have to acquaint my SLIME session by hand all of my ingested babel-lo= b files. Any way to have this happen automatically upon C-c C-c-ing my main= org file? I found=C2=A0this=C2=A0discussion, but I don't b= elieve it really addresses my wish.

LB
<= br>


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

Lawrence Bottorff <borgauf@gmail.co= m> 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 b= e
> 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," b= ut I just want
> to write a Lisp block that calls a function from another org file. I&#= 39;ll
> have SLIME running, of course.
>
>
> file= 1.org:
> ...
>=C2=A0 #+begin_src lisp
> (defun foo ()
>=C2=A0 =C2=A0 (...))
> #+end_src
>
> is then called from. . .
>
> file= 2.org:
> ...
> #+begin_src lisp
> (defun baa ()
>=C2=A0 =C2=A0(foo))
> #+end_src

Any Org mode file can function as Library of Babel.=C2=A0 In your ca= se,
(org-babel-lob-ingest path/to/file1.org) should do what you want.=C2=A0 Note
that org-babel-lob-ingest is bound to C-c C-v i.

hth,
Tom

--
Thomas S. Dye
http:= //www.tsdye.com

--001a11401f0eda9c6505235b6e7a--