Nick Dokos <ndo...@gmail.com> writes:

> Lawrence Bottorff <borg...@gmail.com> writes:
>
>> I think this
>> (https://mobiusengineering.wordpress.com/2015/01/11/using-emacs-org-with-mit-scheme/)
>> describes my problem. Basically, it's with ob-scheme.el. The article
>> seems to say that my problem is scheme stuff being handled improperly
>> by the elisp of ob-scheme.el.
>
> Yes, that sounds right.
>
>> I'll try his workaround and see if it works. He also seems to believe Scheme 
>> is a second-class
>> citizen in babel-land.
>>

Actually... I don't know why that (read result) is there at all: result
is a string representation of the result that the scheme interpreter
returned. It does not make any sense to me that we try to read that and
make it into an elisp object: we should just return the string itself.

With that change (see attached patch) on more-or-less current master
(the exact version is Org-mode version 8.3.1 (release_8.3.1-236-g14f5f6
@ /home/nick/src/emacs/org/org-mode/lisp/), I can evaluate everything
that you sent out without any error (see attached file "scheme.org"
which includes evaluation results).

N.B. this is with guile: I have not tried chicken, MIT Scheme or any
other scheme implementation.

Thoughts?

-- 
Nick

>From 14f5f6312f77b0252f4d29609f996af42c78a938 Mon Sep 17 00:00:00 2001
From: Nick Dokos <ndo...@gmail.com>
Date: Mon, 14 Sep 2015 22:51:26 -0400
Subject: [PATCH] Return result, not (read result) from
 org-babel-scheme-execute-with-geiser

---
 lisp/ob-scheme.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/ob-scheme.el b/lisp/ob-scheme.el
index b10dfc3..c8f7f5e 100644
--- a/lisp/ob-scheme.el
+++ b/lisp/ob-scheme.el
@@ -172,7 +172,7 @@ is true; otherwise returns the last value."
 	(setq result (if (or (string= result "#<void>")
 			     (string= result "#<unspecified>"))
 			 nil
-		       (read result)))))
+		       result))))
     result))
 
 (defun org-babel-execute:scheme (body params)
-- 
2.4.3

#+BEGIN_SRC scheme :session ch1 :exports both
  (define (check-it x)
   (cond
    ((string? x) (string-length x))
    ((number? x) (if (<= x 0) x (- x 1)))
    ((boolean? x) (if (and #t x) 10 20))
    (else #f)))

#+END_SRC

#+RESULTS:


#+BEGIN_SRC scheme :session ch1
(define (square x)
 (* x x))

#+END_SRC

#+RESULTS:

#+BEGIN_SRC scheme :session ch1
(check-it "Foobar")
#+END_SRC

#+RESULTS:
: 6

#+BEGIN_SRC scheme :session ch1
(square 5)
#+END_SRC

#+RESULTS:
: 25

#+BEGIN_SRC scheme :session ch1 :exports both
(define (bool-imply a b)
 (if (or (not a) b) #t #f))
#+END_SRC

#+RESULTS:

#+BEGIN_SRC scheme :session ch1 :exports both
(bool-imply #t #f)
#+END_SRC

#+RESULTS:
: #f

#+BEGIN_SRC scheme :session ch1 :exports both
map
#+END_SRC

#+RESULTS:
: #<procedure map (f l) | (f l1 l2) | (f l1 . rest)>

Reply via email to