17 June, 2013

Using Geiser with Org-babel


I have been wanting to use Racket with Org-babel for a while now but was having trouble setting it up. I finally found a patch(by Michael Gauland) on the emacs-orgmode mailing list that worked for me. It looks like the patch hasn't been merged yet so you're going to have to deal with that yourself.

First, download the patched ob-scheme.el from my dotfiles. Then find ob-scheme.el in your .emacs.d file. For me, its inside .emacs.d/elpa/org-20130527/ but that is going to vary depending on which version you have installed and how you installed it. Then replace that file with the patched one. You might want to make a backup somewhere, just to be safe.

Now, do M-x org-reload (or you might have to restart Emacs), open a .org file and type in:

#+BEGIN_SRC scheme
(+ 1 1 1)
#+END_SRC

Then, inside the block do C-c C-c. And you should see a results block. What you'll notice is that a Racket REPL opens, evaluates and then closes. What I like doing instead is keep the REPL running and eval as I go. To do that, do

#+BEGIN_SRC scheme :session
(define a 5)
#+END_SRC

You can pass session names too:

#+BEGIN_SRC scheme :session my-session1
(define a 5)
#+END_SRC