guile in emacs org mode

I wanted to be able to keep an org document as I learned Guile Scheme in emacs. I use doom emacs, and while setup looked super simple, it sadly wasn't.

Getting guile to work in org

It sould be as simple as adding (scheme +guile) to :tools in .doom.d/init.el but there's something funky going on between geiser and org babel in my version of doom --- whenever I'd try to execute a code block, I'd get an error saying symbol's function definition is void run-geiser. I dug into the changelogs and found that run-geiser had been deprecated and renamed just geiser, but it looks like my version of org/bable doesn't know that. Thankfully, the new function has the same signature as the old one, so I was able to bring it back by adding the following to my .doom.d/config.el:

(defun run-geiser (&rest args) (apply 'geiser args))

Running tests in org

Since I'll be experimenting, it would be nice to have tests. And, since I'm taking notes, I might want to be writing code in one block and writing the tests in another. I tried using bable sessions but they both made emacs lock up when executing code blocks and didn't give me test output in my org file, so that was a no-go. However, you can reference names blocks among one another, which means I can do the following:

* Tests in org mode
First, we write a code block that had our module
#+NAME: multi-block-test
#+BEGIN_SRC scheme :tangle yes :noweb yes :results output
(define-module (hey))

(define-public sup
  (lambda ()
    "hey world!"))
#+END_SRC

#+RESULTS: multi-block-test

Then, we write our test!

#+NAME: multi-block-test-tests
#+BEGIN_SRC scheme :tangle yes :noweb yes :results output 
<<multi-block-test>>
(use-modules (srfi srfi-64))

(test-begin "harness")

(test-equal "test-hello"
  "hey world!"
  (sup))

(test-end "harness")
#+END_SRC

#+RESULTS: multi-block-test-tests
: %%%% Starting test harness  (Writing full log to "harness.log")
: # of expected passes      1

This does almost exactly what i want. It's a little annoying to have to name every block and then include it like that, but I can honestly probably write an elisp function that makes the inclusion super simple at least.

guile in emacs org mode
Interactive graph