help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Org mode & "literate programming": including files


From: Arthur Miller
Subject: Re: Org mode & "literate programming": including files
Date: Wed, 07 Apr 2021 18:47:03 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (windows-nt)

Bob Heffernan <bob.heffernan@gmail.com> writes:

> On 21-04-07 05:54, Arthur Miller wrote:
>> I saw your question on reddit, and I saw somebody already posted you an
>> answer. You are looking for `org-babel-lob-ingest`.
>>
>> Check the SX link posted to you on Reddit, it has what you are asking for:
>>
>> https://emacs.stackexchange.com/questions/31999/config-examples-and-use-cases-of-library-of-babel
>
> Arthur,
>
> From what I understand, the library of babel is a feature to glob
> regularly used (named) code blocks into a single file, for use in
> other org files.  While this looks as if it could be used to achieve
> what I want (first, ingest some code into the library, then use it
> elsewhere) I was hoping for something similar to the sort of thing
> that is present in most programming language REPLs: load whatever
> source file you want, then use the procedures therein.

I found the org-babel to be much better option since it will save you
exporting (tangle) and evaluate org files everytime you load them. It is
more efficient. It also let's you use named blocks, so you potentially
don't need to load everything, just what you need.

If you really wish to do this in style oc #include <someheader.h>,
look at the org-babel-load-file. It will do what you ask, but it is
slow. It will export your .org file (tangle it) to .el and then load the
produced lisp file. As a note, you can look up any elisp function in
Emacs with C-h f RET function-name. Now imagine doing that for many
files. The applications will load quite slow if they include many files
and load them that way.

Somebody above already posted you an answer that you
are rather supposed to export your org files to el, and import those el
files. So it is probably better to either export your code to .el files
and byte/native compile them and use orinary `require' or `load' or use
`library-of-babel'.

I am not an expert, but that is how I understand it to be in Emacs. I am
sure if I am wrong someone here will correct me :-).

>> Hope it works for you and don't forgett to say thanks to the guy on Reddit.
>
> I'll take a closer look at it and thanks for your help.
> (& you're right, I need to go back to reddit and respond!)

> Regards,
> Bob

Best regards
/a



reply via email to

[Prev in Thread] Current Thread [Next in Thread]