1

I cannot find a way to intercept the output when I evaluate a scheme code block as below (I'm trying with Geiser):

#+NAME: test
#+BEGIN_SRC scheme :session sicp :lexical t :results output verbatim replace
(define a (list 2 3 4))
(set-car! a 9)
a
#+END_SRC

#+RESULTS: test
: Geiser Interpreter produced no output

This seems to not be possible with Geiser at all as answered on this other question

Is there's another scheme mode that can support my use case?

I just want to get the output from a scheme REPL as in:

#+NAME: test
#+BEGIN_SRC scheme :session sicp :lexical t :results output verbatim replace
(define a (list 2 3 4))
(set-car! a 9)
a
#+END_SRC

#+RESULTS: test
(9 3 4)

The software versions I'm using are:

  • GNU Emacs 28.1
  • Doom 3.0-dev (can't find a better version than the SHA1 commit 7a30582505)
  • org 9.6
  • chez scheme 9.5.8

2 Answers 2

3

Find the path of ob-scheme.el, for me that is

~/.emacs.d/.local/straight/repos/org/lisp/ob-scheme.el

and then in function org-babel-scheme-execute-with-geiser, change geiser-eval-region to geiser-eval-region/wait, which will wait for the evaluation to finish

        ;;(let ((ret (geiser-eval-region (point-min) (point-max))))
        (let ((ret (geiser-eval-region/wait (point-min) (point-max))))

Finally, press C-M-x to eval the function, and the Geiser worked.

4
  • This did work for me--the one packaged with Homebrew emacs plus was compiled as ob-scheme.elc. Nevertheless, replacing geiser-eval-region with geiser-eval-region/wait did the trick!
    – Jay Lee
    Commented Jun 20, 2022 at 21:05
  • The patched version from gitlab.com/emacs-geiser/guile/-/issues/21 is now also available through Doom emacs and it works correctly.
    – pfmaggi
    Commented Jun 21, 2022 at 10:34
  • For macOS Homebrew installations of Emacs, where would ob-scheme.el be installed? Searching my home directory I can see: $HOME/Library/Caches/Homebrew/emacs-plus@29--git/lisp/org/ob-scheme.el and $HOME/Library/Caches/Homebrew/emacs--git/lisp/org/ob-scheme.el
    – stu002
    Commented Oct 9, 2022 at 8:22
  • Found it at /System/Volumes/Data/opt/homebrew/Cellar/emacs-plus@28/28.2/share/emacs/28.2/lisp/org
    – stu002
    Commented Oct 9, 2022 at 8:39
0

Either use :results value, not :results output, in the code block header, or keep :results output and use (princ a) rather than a (or whatever the equivalent of Elisp's princ is in Scheme).

1
  • With Geiser this doesn't work. I'm not sure if there's another mode I should use to connect org with a scheme REPL. Using :results value I don't get anything from Geiser (the result is left empty in the org file). (printc a) also doesn't produce any output that can be captured by Geiser. I've also tried (printf "a = ~d/n" a) with similar, unsuccesfull, results.
    – pfmaggi
    Commented May 6, 2022 at 14:25

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.