Re: [O] Scheme code block gives false error message
Again, this code #+BEGIN_SRC scheme :session ch1 :exports both (define (bool-imply a b) (if (or (not a) b) #t #f)) #+END_SRC gives the error org-babel-scheme-execute-with-geiser: Invalid read syntax: "#" and this time attempting to use the function #+BEGIN_SRC scheme :session ch1 :exports both (bool-imply #t #f) #+END_SRC produces no #RESULTS: block, rather, again, the error (in Messages buffer) org-babel-scheme-execute-with-geiser: Invalid read syntax: "#" even though this is perfectly healthy code, and it works in the accompanying "ch1" REPL. Any ideas what's happening?
Re: [O] Scheme code block gives false error message
Lawrence Bottorff writes: > Again, this code > > #+BEGIN_SRC scheme :session ch1 :exports both > (define (bool-imply a b) > (if (or (not a) b) #t #f)) > #+END_SRC > > gives the error > > org-babel-scheme-execute-with-geiser: Invalid read syntax: "#" > > and this time attempting to use the function > > #+BEGIN_SRC scheme :session ch1 :exports both > (bool-imply #t #f) > #+END_SRC > > produces no #RESULTS: block, rather, again, the error (in Messages buffer) > > org-babel-scheme-execute-with-geiser: Invalid read syntax: "#" > > even though this is perfectly healthy code, and it works in the accompanying > "ch1" REPL. Any ideas what's happening? > Your previous example worked for me (both with master and maint - I use guile, not chicken, but that should make no difference). But this one fails with the "Invalid read syntax error" and with the attached backtrace (running on maint - master gave the same error but I didn't get a backtrace). read("#f") (if (or (string= result "#") (string= result "#")) nil (read result)) (setq result (if (or (string= result "#") (string= result "#")) nil (read result))) (let ((repl-buffer (save-current-buffer (org-babel-scheme-get-repl impl repl (if (not (eq impl (org-babel-scheme-get-buffer-impl (current-buffer (progn (message "Implementation mismatch: %s (%s) %s (%s)" impl (symbolp impl) (org-babel-scheme-get-buffer-impl (current-buffer)) (symbolp (org-babel-scheme-get-buffer-impl (current-buffer)) (setq geiser-repl--repl repl-buffer) (setq geiser-impl--implementation nil) (setq result (if noninteractive (let ((original-message (symbol-function (quote message))) (current-message nil)) (unwind-protect (progn (defalias (quote message) (function ...)) (geiser-eval-region (point-min) (point-max)) current-message) (fset (quote message) original-message))) (progn (geiser-eval-region (point-min) (point-max)) (current-message (setq result (if (and (stringp result) (equal (substring result 0 3) "=> ")) (replace-regexp-in-string "^=> " "" result) "\"An error occurred.\"")) (if (not repl) (progn (save-current-buffer (set-buffer repl-buffer) (geiser-repl-exit)) (set-process-query-on-exit-flag (get-buffer-process repl-buffer) nil) (kill-buffer repl-buffer))) (setq result (if (or (string= result "#") (string= result "#")) nil (read result (progn (insert (format ";; -*- geiser-scheme-implementation: %s -*-" impl)) (newline) (insert (if output (format "(with-output-to-string (lambda () %s))" code) code)) (geiser-mode) (let ((repl-buffer (save-current-buffer (org-babel-scheme-get-repl impl repl (if (not (eq impl (org-babel-scheme-get-buffer-impl (current-buffer (progn (message "Implementation mismatch: %s (%s) %s (%s)" impl (symbolp impl) (org-babel-scheme-get-buffer-impl (current-buffer)) (symbolp (org-babel-scheme-get-buffer-impl (current-buffer)) (setq geiser-repl--repl repl-buffer) (setq geiser-impl--implementation nil) (setq result (if noninteractive (let ((original-message (symbol-function ...)) (current-message nil)) (unwind-protect (progn (defalias ... ...) (geiser-eval-region ... ...) current-message) (fset (quote message) original-message))) (progn (geiser-eval-region (point-min) (point-max)) (current-message (setq result (if (and (stringp result) (equal (substring result 0 3) "=> ")) (replace-regexp-in-string "^=> " "" result) "\"An error occurred.\"")) (if (not repl) (progn (save-current-buffer (set-buffer repl-buffer) (geiser-repl-exit)) (set-process-query-on-exit-flag (get-buffer-process repl-buffer) nil) (kill-buffer repl-buffer))) (setq result (if (or (string= result "#") (string= result "#")) nil (read result) (unwind-protect (progn (insert (format ";; -*- geiser-scheme-implementation: %s -*-" impl)) (newline) (insert (if output (format "(with-output-to-string (lambda () %s))" code) code)) (geiser-mode) (let ((repl-buffer (save-current-buffer (org-babel-scheme-get-repl impl repl (if (not (eq impl (org-babel-scheme-get-buffer-impl (current-buffer (progn (message "Implementation mismatch: %s (%s) %s (%s)" impl (symbolp impl) (org-babel-scheme-get-buffer-impl (current-buffer)) (symbolp (org-babel-scheme-get-buffer-impl ...) (setq geiser-repl--repl repl-buffer) (setq geiser-impl--implementation nil) (setq result (if noninteractive (let ((original-message ...) (current-message nil)) (unwind-protect (progn ... ... current-message) (fset ... original-message))) (progn (geiser-eval-region (point-min) (point-max)) (current-message (setq result (if (and (stringp result) (equal (substring result 0 3) "=> ")) (replace-regexp-in-string "^=> " "" result) "\"An error occurred.\"")) (if (not repl) (progn (save-current-buffer (set-buffer repl-buffer) (geiser-repl-exit)) (set-process-query-on-exit-flag (get-buffer-process repl-buffer) nil) (kill-buffer repl-buffer))) (setq result (if (or (string= result "#") (string= result "#")) nil (read result) (and (buffer-name
Re: [O] Scheme code block gives false error message
Sorry, Nick, not following you. Could you elaborate more? As a rank beginner, I'm not sure what a backtrace is or how to produce one or how it read it. What do you mean by "master" and "maint"? On Sun, Sep 13, 2015 at 5:41 AM, Nick Dokos wrote: > Lawrence Bottorff writes: > > > Again, this code > > > > #+BEGIN_SRC scheme :session ch1 :exports both > > (define (bool-imply a b) > > (if (or (not a) b) #t #f)) > > #+END_SRC > > > > gives the error > > > > org-babel-scheme-execute-with-geiser: Invalid read syntax: "#" > > > > and this time attempting to use the function > > > > #+BEGIN_SRC scheme :session ch1 :exports both > > (bool-imply #t #f) > > #+END_SRC > > > > produces no #RESULTS: block, rather, again, the error (in Messages > buffer) > > > > org-babel-scheme-execute-with-geiser: Invalid read syntax: "#" > > > > even though this is perfectly healthy code, and it works in the > accompanying "ch1" REPL. Any ideas what's happening? > > > > Your previous example worked for me (both with master and maint - I use > guile, not chicken, but that should make no difference). > > But this one fails with the "Invalid read syntax error" and with the > attached backtrace (running on maint - master gave the same error but > I didn't get a backtrace). > > > > HTH. > -- > Nick > >
Re: [O] Scheme code block gives false error message
Lawrence Bottorff writes: > Sorry, Nick, not following you. Could you elaborate more? As a rank > beginner, I'm not sure what a backtrace is or how to produce one or > how it read it. What do you mean by "master" and "maint"? > It's a debugging aid: it's a dump of the call stack at the time of the error. It tells you how you got there. See (info "(org) Feedback") on how to enable it and produce a useful backtrace. You read it from bottom to top: the bottom-most function has called the next-to-bottom-most function, ..., which has called the top-most function, which is in the middle of evaluating some expression when the error occurred. The section on Debugging in the Emacs Lisp manual contains more information. Re: "master" and "maint" - I didn't know which version of org you were using, so I tried it with both the master branch and the maint branch of the git tree, as they were yesterday. I should probably have provided more explicit versions but it was late and I was tired. For the record, at the time that I was doing that: "master" was Org-mode version 8.3.1 (release_8.3.1-234-g8c85c9 @ /home/nick/elisp/org-mode/lisp/) "maint" was Org-mode version 8.3.1 (release_8.3.1-120-gbc322f @ /home/nick/elisp/org-mode/lisp/) HTH -- Nick
Re: [O] Scheme code block gives false error message
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. I'll try his workaround and see if it works. He also seems to believe Scheme is a second-class citizen in babel-land. On Sun, Sep 13, 2015 at 7:48 PM, Nick Dokos wrote: > Lawrence Bottorff writes: > > > Sorry, Nick, not following you. Could you elaborate more? As a rank > > beginner, I'm not sure what a backtrace is or how to produce one or > > how it read it. What do you mean by "master" and "maint"? > > > > It's a debugging aid: it's a dump of the call stack at the time of the > error. It tells you how you got there. > > See > > (info "(org) Feedback") > > on how to enable it and produce a useful backtrace. > > You read it from bottom to top: the bottom-most function has called > the next-to-bottom-most function, ..., which has called the top-most > function, which is in the middle of evaluating some expression when > the error occurred. The section on Debugging in the Emacs Lisp manual > contains more information. > > Re: "master" and "maint" - I didn't know which version of org you were > using, so I tried it with both the master branch and the maint branch of > the git tree, as they were yesterday. I should probably have provided > more explicit versions but it was late and I was tired. > > For the record, at the time that I was doing that: > > "master" was Org-mode version 8.3.1 (release_8.3.1-234-g8c85c9 @ > /home/nick/elisp/org-mode/lisp/) > "maint" was Org-mode version 8.3.1 (release_8.3.1-120-gbc322f @ > /home/nick/elisp/org-mode/lisp/) > > HTH > -- > Nick > > >
Re: [O] Scheme code block gives false error message
Lawrence Bottorff 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. > -- Nick
Re: [O] Scheme code block gives false error message
So it looks like Scheme is not a Babel language after all. Is there a formal "bug report" to do? On Mon, Sep 14, 2015 at 1:39 PM, Nick Dokos wrote: > Lawrence Bottorff 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. > > > > -- > Nick > > >
Re: [O] Scheme code block gives false error message
Lawrence Bottorff writes: > So it looks like Scheme is not a Babel language after all. What do you mean? There is an ob-scheme.el but it's buggy: I suspect that every ob-*.el is buggy to some extent. Does that mean that every language that babel supports is not a babel language? > Is there a formal "bug report" to do? Well, whether a formal bug report will help is not clear: it's probably best that one be submitted if only for documentation purposes, but whether it will be addressed or not very much depends on somebody picking it up and fixing it. You might be able to persuade "Möbius" to sign FSF papers and submit his implementation (but note that there are limitations there, as mentioned on the page you linked - so there will be bugs...) > > On Mon, Sep 14, 2015 at 1:39 PM, Nick Dokos wrote: > > Lawrence Bottorff 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. > > > > -- > Nick -- Nick
Re: [O] Scheme code block gives false error message
On Mon, Sep 14, 2015 at 6:55 PM, Nick Dokos wrote: > > So it looks like Scheme is not a Babel language after all. > > What do you mean? There is an ob-scheme.el but it's buggy: I suspect > that every ob-*.el is buggy to some extent. Does that mean that every > language that babel supports is not a babel language? > I only mean it can't be used as it now is. I was only three simple example code snippets into this when it proved inoperable. I wanted to use it as a study aid for HTDP or SICP or one of the other Scheme tutorials . . . as in make some personal comments around code samples. > > > Is there a formal "bug report" to do? > > Well, whether a formal bug report will help is not clear: it's probably > best that one be submitted if only for documentation purposes, but > whether it will be addressed or not very much depends on somebody > picking it up and fixing it. You might be able to persuade "Möbius" > to sign FSF papers and submit his implementation (but note that there > are limitations there, as mentioned on the page you linked - so there > will be bugs...) > > I keep putting off learning elisp. Maybe this is the "Schub" I need. You know, stop being such a needy org-mode tourist and start being a local. :-)
Re: [O] Scheme code block gives false error message
Lawrence Bottorff writes: > On Mon, Sep 14, 2015 at 6:55 PM, Nick Dokos wrote: > > > > So it looks like Scheme is not a Babel language after all. > > What do you mean? There is an ob-scheme.el but it's buggy: I suspect > that every ob-*.el is buggy to some extent. Does that mean that every > language that babel supports is not a babel language? > > I only mean it can't be used as it now is. I was only three simple > example code snippets into this when it proved inoperable. I wanted to > use it as a study aid for HTDP or SICP or one of the other Scheme > tutorials . . . as in make some personal comments around code > samples. > > > Is there a formal "bug report" to do? > > Well, whether a formal bug report will help is not clear: it's probably > best that one be submitted if only for documentation purposes, but > whether it will be addressed or not very much depends on somebody > picking it up and fixing it. You might be able to persuade "Möbius" > to sign FSF papers and submit his implementation (but note that there > are limitations there, as mentioned on the page you linked - so there > will be bugs...) > > I keep putting off learning elisp. Maybe this is the "Schub" I > need. You know, stop being such a needy org-mode tourist and start > being a local. :-) > That would be ideal :-) Did you try the alternative ob-scheme.el? If (when) you do, maybe you can post some comments: would it be worth to pursue replacing the current one with the alternative? -- Nick
Re: [O] Scheme code block gives false error message
Nick Dokos writes: > Lawrence Bottorff 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 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 "#") (string= result "#")) 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: : #
Re: [O] Scheme code block gives false error message
Nick Dokos writes: > N.B. this is with guile: I have not tried chicken, MIT Scheme or any > other scheme implementation. > A comment on SO says that geiser (which is used by ob-scheme) only supports guile and racket, so until that changes, chicken or MIT Scheme won't work: http://stackoverflow.com/questions/26578152/use-mit-scheme-instead-of-guile-for-org-mode-code-block-evaluation -- Nick
Re: [O] Scheme code block gives false error message
Nick Dokos writes: > Nick Dokos writes: > >> N.B. this is with guile: I have not tried chicken, MIT Scheme or any >> other scheme implementation. >> > > A comment on SO says that geiser (which is used by ob-scheme) > only supports guile and racket, so until that changes, chicken or MIT > Scheme won't work: > > http://stackoverflow.com/questions/26578152/use-mit-scheme-instead-of-guile-for-org-mode-code-block-evaluation Eh, I should have checked the geiser site: it says Racket 6.0 or better Guile 2.0.9 or better Chicken 4.8.0 or better are supported and there is work afoot to support scsh - no mention of MIT Scheme afaict. -- Nick
Re: [O] Scheme code block gives false error message
I've tried the Moebius workaround (see above). It seems to work, and #+begin_src scheme . . . seems to call my MIT scheme and do results just fine. But it ignores the idea of multiple sessions, which the geiser-based ob-scheme did so well and just has one MIT scheme "session." However it does not start a normal scheme REPL, rather, a "scratch"-like buffer that, in fact, seems to have MIT scheme listening to it. That is, I can type in (define (me x) (* x x x x)) and with C-x C-e everything is working, just like scratch and elisp do. Will try to use your patch and get back to you On Tue, Sep 15, 2015 at 12:48 AM, Nick Dokos wrote: > Nick Dokos writes: > > > Nick Dokos writes: > > > >> N.B. this is with guile: I have not tried chicken, MIT Scheme or any > >> other scheme implementation. > >> > > > > A comment on SO says that geiser (which is used by ob-scheme) > > only supports guile and racket, so until that changes, chicken or MIT > > Scheme won't work: > > > > > http://stackoverflow.com/questions/26578152/use-mit-scheme-instead-of-guile-for-org-mode-code-block-evaluation > > Eh, I should have checked the geiser site: it says > > > Racket 6.0 or better > Guile 2.0.9 or better > Chicken 4.8.0 or better > > are supported and there is work afoot to support scsh - no mention of > MIT Scheme afaict. > > -- > Nick > > >
Re: [O] Scheme code block gives false error message
. . . quick question, Nick (et al): how do I (enlightened beginner) apply the above patch? I'm using latest ELPA from org-mode repo. LB
Re: [O] Scheme code block gives false error message
Ach, disregard that last bleating. Got it changed, and yes, it works -- for both guile and chicken. Thanks a ton, ND. But, yes, if there's a cool emacs way to take your diff and apply it I'd like to know. . . LB On Tue, Sep 15, 2015 at 5:25 PM, Lawrence Bottorff wrote: > . . . quick question, Nick (et al): how do I (enlightened beginner) apply > the above patch? I'm using latest ELPA from org-mode repo. > > LB > > >
Re: [O] Scheme code block gives false error message
Lawrence Bottorff writes: > . . . quick question, Nick (et al): how do I (enlightened beginner) apply the > above patch? I'm using > latest ELPA from org-mode repo. > Save the patch in a file (say "ob-scheme.patch") in the top level directory of your org-mode tree (the one that includes the lisp/ subdirectory), cd to that directory and (assuming you have the "patch" executable on your system), say patch -p 1 < ob-scheme.patch Alternatively, just edit .../lisp/ob-scheme.el, find the line that says (read result) (line 175 in my version) and replace the "(read result)" with just "result" - leave the rest of the parens alone. Nick