* Re: Babel: How to call code in one org file into another org file
@ 2015-10-31 2:24 John Kitchin
2015-10-31 2:33 ` Lawrence Bottorff
0 siblings, 1 reply; 18+ messages in thread
From: John Kitchin @ 2015-10-31 2:24 UTC (permalink / raw)
To: Lawrence Bottorff, emacs-orgmode@gnu org
[-- Attachment #1: Type: text/plain, Size: 293 bytes --]
Odd. I found this I wrote before http://kitchingroup.cheme.cmu.edu/blog/2014/06/24/Using-org-files-like-el-files/
What org version do you have?
On October 30, 2015, at 10:15 PM, Lawrence Bottorff <borgauf@gmail.com> wrote:
@John Kitchin: I can't seem to find a `org-babel-load-file`.
[-- Attachment #2: Type: text/html, Size: 553 bytes --]
^ permalink raw reply [flat|nested] 18+ messages in thread
* Babel: How to call code in one org file into another org file
@ 2015-10-30 20:21 Lawrence Bottorff
2015-10-30 20:53 ` John Kitchin
` (2 more replies)
0 siblings, 3 replies; 18+ messages in thread
From: Lawrence Bottorff @ 2015-10-30 20:21 UTC (permalink / raw)
To: emacs-orgmode Mailinglist
[-- Attachment #1: Type: text/plain, Size: 559 bytes --]
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
LB
[-- Attachment #2: Type: text/html, Size: 905 bytes --]
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Babel: How to call code in one org file into another org file
2015-10-30 20:21 Lawrence Bottorff
@ 2015-10-30 20:53 ` John Kitchin
2015-10-30 20:55 ` Thomas S. Dye
2015-10-31 9:57 ` Rasmus
2 siblings, 0 replies; 18+ messages in thread
From: John Kitchin @ 2015-10-30 20:53 UTC (permalink / raw)
To: Lawrence Bottorff; +Cc: emacs-orgmode Mailinglist
I don't think this is possible. You probably need some tangling and
loading to make it happen the way I understand it.
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
>
>
> LB
--
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Babel: How to call code in one org file into another org file
2015-10-30 20:21 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
2015-10-31 9:57 ` Rasmus
2 siblings, 2 replies; 18+ messages in thread
From: Thomas S. Dye @ 2015-10-30 20:55 UTC (permalink / raw)
To: Lawrence Bottorff; +Cc: emacs-orgmode Mailinglist
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
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Babel: How to call code in one org file into another org file
2015-10-30 20:55 ` Thomas S. Dye
@ 2015-10-30 22:57 ` briangpowell .
2015-10-31 0:14 ` Lawrence Bottorff
1 sibling, 0 replies; 18+ messages in thread
From: briangpowell . @ 2015-10-30 22:57 UTC (permalink / raw)
To: Thomas S. Dye; +Cc: emacs-orgmode Mailinglist, Lawrence Bottorff
[-- Attachment #1: Type: text/plain, Size: 1154 bytes --]
Could create a named pipe and have one org-mode file write to it and
another org-mode file read from it.
On Fri, Oct 30, 2015 at 4: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: 2037 bytes --]
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Babel: How to call code in one org file into another org file
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 3:08 ` Thomas S. Dye
1 sibling, 2 replies; 18+ messages in thread
From: Lawrence Bottorff @ 2015-10-31 0:14 UTC (permalink / raw)
To: emacs-orgmode Mailinglist
[-- 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 --]
^ permalink raw reply [flat|nested] 18+ messages in thread
[parent not found: <m21tcbx2iy.fsf@andrew.cmu.edu>]
* Re: Babel: How to call code in one org file into another org file
[not found] ` <m21tcbx2iy.fsf@andrew.cmu.edu>
@ 2015-10-31 2:12 ` Lawrence Bottorff
2015-10-31 2:15 ` Lawrence Bottorff
0 siblings, 1 reply; 18+ messages in thread
From: Lawrence Bottorff @ 2015-10-31 2:12 UTC (permalink / raw)
To: emacs-orgmode Mailinglist
[-- Attachment #1: Type: text/plain, Size: 2018 bytes --]
In my init file I have
(custom-set-variables
. . .
'(org-babel-lob-files
(quote
("/home/hercynian/org/babeltest/a.org" "/home/hercynian/org/babeltest/
b.org")))
that, of course, lasted an Emacs reboot after I had set them with
customization. But then right after Emacs reboot, looking into the contents
of `org-babel-library-of-babel`, I do not see the "association list" of the
entire code blocks of a.org and b.org as I did in the last Emacs/org-mode
session when I ran `org-babel-lob-ingest` on a.org and b.org. So
`org-babel-library-of-babel` is populated only
through `org-babel-lob-ingest`. Next question was, Does code alive in the
current `org-babel-library-of-babel` make it live and ready to use?
Apparently not. Experimenting has shown that starting Emacs not only does
not auto-populate `org-babel-library-of-babel`, but even when I do
a `org-babel-lob-ingest` on a.org and b.org, SLIME takes no notice and
fails to see the functions in a.org and b.org.
Here's my `org-babel-library-of-babel`:
Value: ((multi_x2 "lisp" "(defun multi_x2 (x)\n (* 2 x))"
((:comments . "")
(:shebang . "")
(:cache . "no")
(:padline . "")
(:noweb . "no")
(:tangle . "no")
(:exports . "code")
(:results . "replace")
(:session)
(:hlines . "no"))
"" "multi_x2" 0 18)
(myadd "lisp" "(defun myadd (x y)\n (+ x y))"
((:comments . "")
(:shebang . "")
(:cache . "no")
(:padline . "")
(:noweb . "no")
(:tangle . "no")
(:exports . "code")
(:results . "replace")
(:session)
(:hlines . "no"))
"" "myadd" 0 15))
which seems like my code block in c.org should know about them, right? No.
Again, Babel LOB seems to have forgotten to tell SLIME the good news. But
then maybe I need to say something specific in my add&multi_x2 code block
about these helper functions I've got in a.org and b.org?
[-- Attachment #2: Type: text/html, Size: 3314 bytes --]
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Babel: How to call code in one org file into another org file
2015-10-31 0:14 ` Lawrence Bottorff
[not found] ` <m21tcbx2iy.fsf@andrew.cmu.edu>
@ 2015-10-31 3:08 ` Thomas S. Dye
2015-10-31 3:58 ` Lawrence Bottorff
1 sibling, 1 reply; 18+ messages in thread
From: Thomas S. Dye @ 2015-10-31 3:08 UTC (permalink / raw)
To: Lawrence Bottorff; +Cc: emacs-orgmode Mailinglist
Aloha Lawrence,
Lawrence Bottorff <borgauf@gmail.com> writes:
> 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.
I would use local variables for this--something like (untested):
# eval: (org-babel-lob-ingest path/to/your/file)
# eval: (sbe "my-add")
# eval: (sbe "multi_x2")
Computer savvy Org moders don't like eval because anything can happen,
but if you're willing to trust yourself, then it shouldn't cause any
problems.
With this near the bottom of your file, whenever you open the file your
other org files will be loaded into the Library of Babel where you can
load up function definitions as needed.
Of course, you'll need to have slime running when you open the file.
hth,
Tom
--
Thomas S. Dye
http://www.tsdye.com
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Babel: How to call code in one org file into another org file
2015-10-31 3:08 ` Thomas S. Dye
@ 2015-10-31 3:58 ` Lawrence Bottorff
2015-10-31 15:41 ` Nick Dokos
0 siblings, 1 reply; 18+ messages in thread
From: Lawrence Bottorff @ 2015-10-31 3:58 UTC (permalink / raw)
To: Thomas S. Dye; +Cc: emacs-orgmode Mailinglist
[-- Attachment #1: Type: text/plain, Size: 892 bytes --]
>
>
> I would use local variables for this--something like (untested):
>
> # eval: (org-babel-lob-ingest path/to/your/file)
> # eval: (sbe "my-add")
> # eval: (sbe "multi_x2")
>
> Computer savvy Org moders don't like eval because anything can happen,
> but if you're willing to trust yourself, then it shouldn't cause any
> problems.
>
> With this near the bottom of your file, whenever you open the file your
> other org files will be loaded into the Library of Babel where you can
> load up function definitions as needed.
>
> Of course, you'll need to have slime running when you open the file.
>
> hth,
> Tom
>
Thanks Tom. Still, I'm wondering if the whole LOB is worth it in
Lisp/SLIME-land. I can load code with org-babel-lob-ingest into
`org-babel-library-of-babel`, but SLIME doesn't seem to know about it --
which sort of defeats the whole purpose, if you follow what I mean. . . .
[-- Attachment #2: Type: text/html, Size: 1342 bytes --]
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Babel: How to call code in one org file into another org file
2015-10-31 3:58 ` Lawrence Bottorff
@ 2015-10-31 15:41 ` Nick Dokos
2015-10-31 16:17 ` Lawrence Bottorff
0 siblings, 1 reply; 18+ messages in thread
From: Nick Dokos @ 2015-10-31 15:41 UTC (permalink / raw)
To: emacs-orgmode
Lawrence Bottorff <borgauf@gmail.com> writes:
> I would use local variables for this--something like (untested):
>
> # eval: (org-babel-lob-ingest path/to/your/file)
> # eval: (sbe "my-add")
> # eval: (sbe "multi_x2")
>
> Computer savvy Org moders don't like eval because anything can happen,
> but if you're willing to trust yourself, then it shouldn't cause any
> problems.
>
> With this near the bottom of your file, whenever you open the file your
> other org files will be loaded into the Library of Babel where you can
> load up function definitions as needed.
>
> Of course, you'll need to have slime running when you open the file.
>
> hth,
> Tom
>
> Thanks Tom. Still, I'm wondering if the whole LOB is worth it in
> Lisp/SLIME-land. I can load code with org-babel-lob-ingest into
> `org-babel-library-of-babel`, but SLIME doesn't seem to know about it
> -- which sort of defeats the whole purpose, if you follow what I
> mean. . . .
>
You got me all curious to see where things break: I had to install slime
and clisp to find out. Everything is working I think: nothing is broken.
As long as you are willing to add Tom's initialization (slightly
modified - the function I have is org-sbe rather than sbe - I guess Tom
has defined sbe in his own setup for backward-compatibility purposes),
the following process works for me.
Here's what I added to my .emacs:
--8<---------------cut here---------------start------------->8---
(setq inferior-lisp-program "/usr/bin/clisp")
;;; start it - it's important to start slime *before*
;;; you load the c.org file below.
(slime)
(require 'ob-lisp)
--8<---------------cut here---------------end--------------->8---
a.org and b.org are just as you defined them:
--8<---------------cut here---------------start------------->8---
#+name: myadd
#+begin_src lisp :session foo
(defun myadd (x y)
(+ x y))
#+end_src
--8<---------------cut here---------------end--------------->8---
--8<---------------cut here---------------start------------->8---
#+name: multi_x2
#+begin_src lisp :session
(defun multi_x2 (x)
(* 2 x))
#+end_src
--8<---------------cut here---------------end--------------->8---
and c.org with Tom's modifications looks like this:
--8<---------------cut here---------------start------------->8---
#+name: add&multi_x2
#+begin_src lisp :session
(defun add&multi_x2 (x y)
(multi_x2 (myadd x y)))
#+end_src
#+BEGIN_SRC lisp :session
(add&multi_x2 2 3)
#+END_SRC
# Local Variables:
# eval: (org-babel-lob-ingest "./a.org")
# eval: (org-babel-lob-ingest "./b.org")
# eval: (org-sbe "myadd")
# eval: (org-sbe "multi_x2")
# End:
--8<---------------cut here---------------end--------------->8---
Evaluation of the two code block in c.org proceeds correctly and without
problems.
--
Nick
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Babel: How to call code in one org file into another org file
2015-10-31 15:41 ` Nick Dokos
@ 2015-10-31 16:17 ` Lawrence Bottorff
2015-10-31 16:34 ` Nick Dokos
0 siblings, 1 reply; 18+ messages in thread
From: Lawrence Bottorff @ 2015-10-31 16:17 UTC (permalink / raw)
To: emacs-orgmode Mailinglist; +Cc: Nick Dokos
[-- Attachment #1: Type: text/plain, Size: 557 bytes --]
Yes, I experimented with this too -- and got it to work. But strangely, if
you leave out the
# eval: (org-babel-lob-ingest "./a.org")
# eval: (org-babel-lob-ingest "./b.org")
lines and do a regular `org-babel-lob-ingest` (or C-c C-v i) on those two
files -- *it doesn't work. *Rather bizarre behavior, IMHO.
Anyway, the dream behavior for LOB would be to simply add your files to
your `org-babel-lob-files` in your Emacs init, start up an org file -- and
be able to simply use all the LOB files in your "live"
`org-babel-library-of-babel` list library.
[-- Attachment #2: Type: text/html, Size: 838 bytes --]
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Babel: How to call code in one org file into another org file
2015-10-31 16:17 ` Lawrence Bottorff
@ 2015-10-31 16:34 ` Nick Dokos
2015-10-31 16:51 ` Lawrence Bottorff
0 siblings, 1 reply; 18+ messages in thread
From: Nick Dokos @ 2015-10-31 16:34 UTC (permalink / raw)
To: emacs-orgmode
Lawrence Bottorff <borgauf@gmail.com> writes:
> Yes, I experimented with this too -- and got it to work. But strangely, if you leave out the
>
> # eval: (org-babel-lob-ingest "./a.org")
> # eval: (org-babel-lob-ingest "./b.org")
>
> lines and do a regular `org-babel-lob-ingest` (or C-c C-v i) on those
> two files -- it doesn't work. Rather bizarre behavior, IMHO.
>
I think you have some misconceptions about what org-babel-lob-ingest
does. All it does is go through the file and add the named source
blocks in that file to org-babel-library-of-babel: it does *not*
evaluate the code blocks. So if the code block is e.g. a lisp code
block with a defun in it, the function is *not* defined, until the
code block is evaluated by org-babel: that's what org-sbe does.
> Anyway, the dream behavior for LOB would be to simply add your files to your `org-babel-lob-files` in your Emacs init, start up an org file -- and be able to simply use all the LOB
> files in your "live" `org-babel-library-of-babel` list library.
>
You can do that but again all that does is populate a list that
only org-babel knows about. You'd still need to evaluate the code
blocks in order to tell the inferior lisp process about what the
code block define.
--
Nick
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Babel: How to call code in one org file into another org file
2015-10-31 16:34 ` Nick Dokos
@ 2015-10-31 16:51 ` Lawrence Bottorff
2015-11-02 7:09 ` Eric S Fraga
0 siblings, 1 reply; 18+ messages in thread
From: Lawrence Bottorff @ 2015-10-31 16:51 UTC (permalink / raw)
To: Nick Dokos; +Cc: emacs-orgmode Mailinglist
[-- Attachment #1: Type: text/plain, Size: 1903 bytes --]
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.
Otherwise (especially with the extra `org-babel-lob-ingest` in Local
Variable step I mentioned), what John Kitchin suggested with
`org-babel-load-file` is just as good, i.e., LOB seems hardly worth it. My
whole motivation is to avoid having to scroll through endless code blocks
all on the same level, rather, to have things more modular and distributed,
a bit like DDLs in MS-land.
On Sat, Oct 31, 2015 at 4:34 PM, Nick Dokos <ndokos@gmail.com> wrote:
> Lawrence Bottorff <borgauf@gmail.com> writes:
>
> > Yes, I experimented with this too -- and got it to work. But strangely,
> if you leave out the
> >
> > # eval: (org-babel-lob-ingest "./a.org")
> > # eval: (org-babel-lob-ingest "./b.org")
> >
> > lines and do a regular `org-babel-lob-ingest` (or C-c C-v i) on those
> > two files -- it doesn't work. Rather bizarre behavior, IMHO.
> >
>
> I think you have some misconceptions about what org-babel-lob-ingest
> does. All it does is go through the file and add the named source
> blocks in that file to org-babel-library-of-babel: it does *not*
> evaluate the code blocks. So if the code block is e.g. a lisp code
> block with a defun in it, the function is *not* defined, until the
> code block is evaluated by org-babel: that's what org-sbe does.
>
> > Anyway, the dream behavior for LOB would be to simply add your files to
> your `org-babel-lob-files` in your Emacs init, start up an org file -- and
> be able to simply use all the LOB
> > files in your "live" `org-babel-library-of-babel` list library.
> >
>
> You can do that but again all that does is populate a list that
> only org-babel knows about. You'd still need to evaluate the code
> blocks in order to tell the inferior lisp process about what the
> code block define.
>
> --
> Nick
>
>
>
[-- Attachment #2: Type: text/html, Size: 2636 bytes --]
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Babel: How to call code in one org file into another org file
2015-10-31 16:51 ` Lawrence Bottorff
@ 2015-11-02 7:09 ` Eric S Fraga
2015-11-02 13:36 ` Nick Dokos
0 siblings, 1 reply; 18+ messages in thread
From: Eric S Fraga @ 2015-11-02 7:09 UTC (permalink / raw)
To: Lawrence Bottorff; +Cc: Nick Dokos, emacs-orgmode Mailinglist
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.
--
: Eric S Fraga (0xFFFCF67D), Emacs 24.5.1, Org release_8.3.2-215-gb4af3f
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Babel: How to call code in one org file into another org file
2015-11-02 7:09 ` Eric S Fraga
@ 2015-11-02 13:36 ` Nick Dokos
0 siblings, 0 replies; 18+ messages in thread
From: Nick Dokos @ 2015-11-02 13:36 UTC (permalink / raw)
To: emacs-orgmode
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
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Babel: How to call code in one org file into another org file
2015-10-30 20:21 Lawrence Bottorff
2015-10-30 20:53 ` John Kitchin
2015-10-30 20:55 ` Thomas S. Dye
@ 2015-10-31 9:57 ` Rasmus
2 siblings, 0 replies; 18+ messages in thread
From: Rasmus @ 2015-10-31 9:57 UTC (permalink / raw)
To: emacs-orgmode
Hi 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
>
> file2.org:
> ...
>
> #+begin_src lisp
> (defun baa ()
> (foo))
> #+end_src
At export time you could include a named block, but I’m not really sure
that gets you closer to what you want.
E.g. in file 1,
#+name: fun_foo
#+begin_src lisp
(defun foo ()
(...))
#+end_src
In file 2,
#+include: "file1.org::fun_foo"
#+begin_src lisp
(defun baa ()
(foo))
#+end_src
Rasmus
--
Spil noget med Slayer!
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2015-11-02 13:37 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-31 2:24 Babel: How to call code in one org file into another org file John Kitchin
2015-10-31 2:33 ` Lawrence Bottorff
-- strict thread matches above, loose matches on Subject: below --
2015-10-30 20:21 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
2015-10-31 9:57 ` Rasmus
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).