I want to write a scheme program in an org file. I want to be able to execute the #+SRC blcoks and see the result in #+RESULT: block. However, when I execute the #+SRC_BEGIN/END I get no output. Instead I get a guile REPL and that's it.

These are the config I have:

(setq geiser-default-implementation 'guile)

'((scheme . t)
 (emacs-lisp . t)
 (ruby . t)
 (R . t)
 (python . t)
 (C . t)
 (sh . t)))

There's an interesting detail. When I execute this code

(write "hello")

I get this output in the org file:

[blank here]

And another buffer with this:

=> #<unspecified>

"hello world";; -*- geiser-scheme-implementation: guile -*-
(write "hello world")

But the following program produces no output at all, not even the empty #+RESULT: block, except for a new guile REPL with nothing loaded into it.

This is the program (from SICP):

#+NAME rules
#+BEGIN_SRC scheme :tangle yes :noweb yes
(define (deriv exp var)
  (cond ((constant? exp var) 0 )
        ((same-var? exp var) 1)
        ((sum? exp)
         (make-sum (deriv (A1 exp) var)
                   (deriv (A2 exp) var)))
        ((product? exp) 
         (make-sum (make-product (M1 exp)
                                 (deriv (M2 exp) var))
                   (make-product (deriv (M1 exp) var)
                                 (M2 exp)))))) 

#+BEGIN_SRC scheme :tangle yes :noweb yes

(define atom?
  (lambda (x)
    (and (not (pair? x)) (not (null? x)))))

(define (constant? exp var)
  (and (atom? exp)
       (not (eq? exp var))))

(define (same-var? exp var)
  (and (atom? exp)
       (eq? exp var)))

(define (sum? exp)
  (and (not (atom? exp))
       (eq? (car exp) '+)))

(define (make-sum a1 a2)
  (list '+ a1 a2))

(define A1 cadr) ;;TODO rewrite these as lambda expressions (lambada (x) (car (cdr x)). something like that.

(define A2 caddr) 

(define (product? exp)
  (and (not (atom? exp))
       (eq? (car exp) '*)))

(define (make-product m1 m2)
  (list '* m1 m2))

(define M1 cadr)

(define M2 caddr)

(define foo '(+ (* a (* x x))
               (* (* b x)


(deriv foo 'x)


Can someone tell me why the program isnt executed and instead a guile REPL is opened for some reason?

  • Re' unspecified: you need to specify the language of the src block (otherwise Babel doesn't know what interpreter to use). :tangle and :noweb are features of literate programming, which you may not need at this moment. What you do need is to make sure that you enabled Scheme using org-babel-do-load-languages.
    – wvxvw
    Jul 25, 2015 at 19:17
  • thanks. I edited the question to add my org-babel-do-load-languages Jul 25, 2015 at 19:28
  • The code, the way you have it written, is supposed to be tangled (its pieces will be joined together and printed into a file). You could do the tangling by calling M-x org-babel-tangle or by pressing C-c C-v t (same thing). See this: orgmode.org/manual/noweb.html for more options.
    – wvxvw
    Jul 25, 2015 at 19:49
  • okay thanks. and how can I immediately execute that code? is it possible to simply open the file and run the scheme interpreter on it? Jul 25, 2015 at 21:07
  • actually I take the last comment back. It a niece feature to tangle and print it to another file. But what I really want, is org-mode to tangle it behind the scenes a print the result of the execution into this file. Is that possible? Jul 25, 2015 at 21:31

1 Answer 1


But what I really want, is org-mode to tangle it behind the scenes a print the result of the execution into this file.

For that you need the :results directive as shown below.

BEGIN_SRC scheme :tangle yes :noweb yes :results output

See babel documentation for details of whether to use value instead of output in the :results directive. Value is good if want only the last statement's output.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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