1

I have an init file called settings.org (using #+BEGIN_SRC #+END_SRC blocks for elisp code)

I would like to generate settings.el from it, so that I can load it inside init.el easily.

How would I accomplish this?

2

After some research this is the solution I managed to find:

Add :tangle yes to each block of code you want to export

\#+BEGIN_SRC emacs-lisp :tangle yes
elisp code...
\#+END_SRC

Then inside the .org file use

M-x org-babel-tangle

This will create a file with the same name but with the .el extension.

In my case I generated settings.el and included it in init.el

This can be automated with (org-babel-load-file) to directly load the org file.

But I personally prefer the extra step, to make sure I know what I'm loading and when.

  • +1 for finding an answer to your own question. Might it help others to add some info about how you found it? – Drew Jan 2 '17 at 19:15
  • Thanks, at this point I closed all the browser tabs, so don't remember exact links. But for the most part reading up on org-babel and what it does helped solve the problem. – Rtsne42 Jan 2 '17 at 19:26
  • Exporting source code (tangling) is described in the manual orgmode.org/org.html#Extracting-source-code. – Dieter.Wilhelm Jan 3 '17 at 7:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.