Re: Problem with org-babel and geiser

2022-05-08 Thread Ihor Radchenko
Rudolf Adamkovič  writes:

> P.S.
>
> We should add 'testing/lisp/test-ob-scheme.el' or it will break again
> sooner or later.  Can we make the Org test suite depend on Geiser and
> Guile?  Given that Org uses Geiser out of the box, I think we should.
> What do you think?

Sounds reasonable. Patches are welcome!

Best,
Ihor



Re: Problem with org-babel and geiser

2022-03-27 Thread Rudolf Adamkovič
Zelphir Kaltstahl  writes:

Hi Zelphir,

> Geiser seems to work, if I use /bin/sh with some arguments instead of
> GNU Bash.

I have no idea it means to "use /bin/sh with some arguments instead of
GNU Bash" in the context of Org Babel, Geiser, and Guile.  Then, please
see my other mail, the reply to Neil, where I test the patch posted
upthread and find that it indeed works well!

Rudy
-- 
"Programming reliably -- must be an activity of an undeniably
mathematical nature […] You see, mathematics is about thinking, and
doing mathematics is always trying to think as well as possible."
-- Edsger W. Dijkstra, 1981

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: Problem with org-babel and geiser

2022-03-27 Thread Rudolf Adamkovič
Neil Jerram  writes:

Hi Neil!

> What do you see if you add ":results output" to the "#+begin_src"
> line, and then C-c C-c again?

#+BEGIN_SRC scheme :results output verbatim
(+ 1 1)
#+END_SRC

#+RESULTS:
: Geiser Interpreter produced no output

> Did the patch help in your case?

I had to update the file name inside of the patch:

- old: lisp/org/ob-scheme.el
- new: lisp/ob-scheme.el

After that, the patch applied cleanly on top of 'main'.

So, I restarted Emacs and tried:

#+BEGIN_SRC scheme
(+ 1 1)
#+END_SRC

#+RESULTS:
: 2

Further, I also tried to execute '(display "ABC")' while capturing
standard output using ':results output verbatim'.  It worked.

Lastly, I tried to use a persistent ':session' to avoid waiting for the
Geiser/Guile when executing code blocks.  It worked as well.

TL;DR The patch works.

P.S.

We should add 'testing/lisp/test-ob-scheme.el' or it will break again
sooner or later.  Can we make the Org test suite depend on Geiser and
Guile?  Given that Org uses Geiser out of the box, I think we should.
What do you think?

Rudy
-- 
"The whole science is nothing more than a refinement of everyday
thinking."
-- Albert Einstein, 1879-1955

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: Problem with org-babel and geiser

2022-03-23 Thread Neil Jerram
Hi Rudy,

On Thu, 17 Mar 2022 at 17:07, Rudolf Adamkovič  wrote:
>
> Bob Heffernan  writes:
>
> > I did as you described and the patched version of ob-scheme.el *does*
> > seem to solve the problem.
>
> Today, I needed to use Scheme with Org (9.5.2-24-g668205), and I found
> that the #+RESULTS: always come back empty.  Oh, well!  I use Guile and
> have everything configured correctly.

What do you see if you add ":results output" to the "#+begin_src"
line, and then C-c C-c again?

> Has anyone merged the patch
> discussed in this thread into Org?

Did the patch help in your case?

Best wishes,
Neil



Re: Problem with org-babel and geiser

2022-03-22 Thread Zelphir Kaltstahl

Hello Rudy!

On 3/22/22 21:51, Rudolf Adamkovič wrote:

Zelphir Kaltstahl  writes:

Hello Zelphir!


At some point something changed, I think, […]

In Geiser or in Org?  I use Geiser for work heavily and it works like
magic.  I ask because if the problem resides in Geiser, we could report
a new bug there.

Rudy


Geiser seems to work, if I use /bin/sh with some arguments instead of GNU Bash. 
I am not sure what is going on with that though, because I did not have to do 
that in the past. In org-mode it still does not work. I will have to get into 
the topic again at some point, as I am unsatisfied without having GNU Guile 
source blocks in Org-mode working.

I've successfully used those before in multiple personal or learning projects 
(like 
inhttps://notabug.org/ZelphirKaltstahl/the-little-schemer/src/master/chapter-09-y-combinator/code.org).
 I spent so much time on fixing this problem, that I neglected my actual 
project that I wanted to continue. After 2 or 3 weekends, I left the issue at 
the status in that gitlab issue. I completely blended that one out for now and 
continued by copy pasting into Geiser REPL or using C-c C-r to run regions of 
code. That works at least. But it is less satisfying than doing literate 
programming in org-mode.

If anyone has concrete steps to run, to figure out the problem, I might find the energy to get into the 
matter again. For now I have put it up to "later" / "in the future" / "when some 
update comes" or something like that.

Best regards,
Zelphir

--
repositories:https://notabug.org/ZelphirKaltstahl


Re: Re: Problem with org-babel and geiser

2022-03-22 Thread Rudolf Adamkovič
Zelphir Kaltstahl  writes:

Hello Zelphir!

> At some point something changed, I think, […]

In Geiser or in Org?  I use Geiser for work heavily and it works like
magic.  I ask because if the problem resides in Geiser, we could report
a new bug there.

Rudy
-- 
"One can begin to reason only when a clear picture has been formed in
the imagination."
-- Walter Warwick Sawyer, Mathematician's Delight, 1943

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: Re: Problem with org-babel and geiser

2022-03-18 Thread Zelphir Kaltstahl

Hello Rudy!

On 3/18/22 17:00, emacs-orgmode-requ...@gnu.org wrote:

Today, I needed to use Scheme with Org (9.5.2-24-g668205), and I found
that the #+RESULTS: always come back empty.  Oh, well!  I use Guile and
have everything configured correctly.  Has anyone merged the patch
discussed in this thread into Org?

Thank you.

Rudy


I've had lots of problems with getting it to work as well and have not solved 
all of them. At some point something changed, I think, which made my setup not 
work correctly any longer. You might be interested in the following issue on gitlab:


https://gitlab.com/emacs-geiser/guile/-/issues/13

I've not followed up further yet.

Best regards,
Zelphir

--
repositories: https://notabug.org/ZelphirKaltstahl




Re: Problem with org-babel and geiser

2022-03-17 Thread Rudolf Adamkovič
Bob Heffernan  writes:

> I did as you described and the patched version of ob-scheme.el *does*
> seem to solve the problem.

Today, I needed to use Scheme with Org (9.5.2-24-g668205), and I found
that the #+RESULTS: always come back empty.  Oh, well!  I use Guile and
have everything configured correctly.  Has anyone merged the patch
discussed in this thread into Org?

Thank you.

Rudy
-- 
"Thinking is a momentary dismissal of irrelevancies."
-- Richard Buckminster Fuller, 1969

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: Problem with org-babel and geiser

2022-02-05 Thread Bob Heffernan
On 22-02-05 19:39, Ihor Radchenko wrote:
> It's not a good idea to modify Org packaged together with Emacs. For
> testing, you can just use the attached version of ob-scheme.el. Load
> your Emacs and Org mode, open the attached ob-scheme.el, and run M-x
> eval-buffer. That should be sufficient to test the proposed patch on
> your side.
>
> If the patch solves the problem you are experiencing, let us know. I
> will then apply the proposed patch upstream.
>
> Note that even if I apply the patch, it will only be available on the
> latest version of Org mode (Org 9.5.2). It is _not_ what is shipped
> together with your Emacs. You will need to upgrade your Org mode using
> M-x package-install. See
> https://orgmode.org/manual/Installation.html#Installation for details.

Ihor,

I did as you described and the patched version of ob-scheme.el *does* seem to 
solve the problem.

Thanks & best regards,
Bob



Re: Problem with org-babel and geiser

2022-02-05 Thread Ihor Radchenko
Bob Heffernan  writes:

> Thank you for your response.
> The patch you linked does seem to be intended to fix this issue.
>
> However, I have no experience with applying a patch (to Emacs or anything 
> else).
> On my system, ob-scheme.el.gz can be found at
> /usr/share/emacs/27.2/lisp/org
> can I uncompress the file, patch that, then compress again?
>
> Or, would I need to download the Emacs source, apply the patch and then 
> recompile?

It's not a good idea to modify Org packaged together with Emacs. For
testing, you can just use the attached version of ob-scheme.el. Load
your Emacs and Org mode, open the attached ob-scheme.el, and run M-x
eval-buffer. That should be sufficient to test the proposed patch on
your side.

If the patch solves the problem you are experiencing, let us know. I
will then apply the proposed patch upstream.

Note that even if I apply the patch, it will only be available on the
latest version of Org mode (Org 9.5.2). It is _not_ what is shipped
together with your Emacs. You will need to upgrade your Org mode using
M-x package-install. See
https://orgmode.org/manual/Installation.html#Installation for details.

Best,
Ihor

;;; ob-scheme.el --- Babel Functions for Scheme  -*- lexical-binding: t; -*-

;; Copyright (C) 2010-2022 Free Software Foundation, Inc.

;; Authors: Eric Schulte
;;  Michael Gauland
;; Keywords: literate programming, reproducible research, scheme
;; Homepage: https://orgmode.org

;; This file is part of GNU Emacs.

;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs.  If not, see .

;;; Commentary:

;; Now working with SBCL for both session and external evaluation.
;;
;; This certainly isn't optimally robust, but it seems to be working
;; for the basic use cases.

;;; Requirements:

;; - a working scheme implementation
;;   (e.g. guile https://www.gnu.org/software/guile/guile.html)
;;
;; - for session based evaluation geiser is required, which is available from
;;   ELPA.

;;; Code:
(require 'ob)
(require 'geiser nil t)
(require 'geiser-impl nil t)
(defvar geiser-repl--repl) ; Defined in geiser-repl.el
(defvar geiser-impl--implementation)   ; Defined in geiser-impl.el
(defvar geiser-scheme-implementation)  ; Defined in geiser-impl.el
(defvar geiser-default-implementation) ; Defined in geiser-impl.el
(defvar geiser-active-implementations) ; Defined in geiser-impl.el
(defvar geiser-debug-show-debug-p) ; Defined in geiser-debug.el
(defvar geiser-debug-jump-to-debug-p)  ; Defined in geiser-debug.el
(defvar geiser-repl-use-other-window)  ; Defined in geiser-repl.el
(defvar geiser-repl-window-allow-split) ; Defined in geiser-repl.el

(declare-function run-geiser "ext:geiser-repl" (impl))
(declare-function geiser-mode "ext:geiser-mode" ())
(declare-function geiser-eval-region "ext:geiser-mode"
  (start end  and-go raw nomsg))
(declare-function geiser-repl-exit "ext:geiser-repl" ( arg))
(declare-function geiser-eval--retort-output "ext:geiser-eval" (ret))
(declare-function geiser-eval--retort-result-str "ext:geiser-eval" (ret prefix))

(defcustom org-babel-scheme-null-to 'hline
  "Replace `null' and empty lists in scheme tables with this before returning."
  :group 'org-babel
  :version "26.1"
  :package-version '(Org . "9.1")
  :type 'symbol)

(defvar org-babel-default-header-args:scheme '()
  "Default header arguments for scheme code blocks.")

(defun org-babel-expand-body:scheme (body params)
  "Expand BODY according to PARAMS, return the expanded body."
  (let ((vars (org-babel--get-vars params))
(prepends (cdr (assq :prologue params)))
(postpends (cdr (assq :epilogue params
(concat (and prepends (concat prepends "\n"))
(if (null vars) body
  (format "(let (%s)\n%s\n)"
  (mapconcat
   (lambda (var)
 (format "%S" (print `(,(car var) ',(cdr var)
   vars
   "\n  ")
  body))
(and postpends (concat "\n" postpends)


(defvar org-babel-scheme-repl-map (make-hash-table :test #'equal)
  "Map of scheme sessions to session names.")

(defun org-babel-scheme-cleanse-repl-map ()
  "Remove dead buffers from the REPL map."
  (maphash
   (lambda (x y) (unless (buffer-name y) (remhash x org-babel-scheme-repl-map)))
   org-babel-scheme-repl-map))

(defun org-babel-scheme-get-session-buffer 

Re: Problem with org-babel and geiser

2022-02-04 Thread Bob Heffernan
On 22-02-04 15:00, Ihor Radchenko wrote:
> Does the patch in
> https://orgmode.org/list/3462869.oopU1TnKvU@felipe-thinkpad-x200 help?

Ihor,

Thank you for your response.
The patch you linked does seem to be intended to fix this issue.

However, I have no experience with applying a patch (to Emacs or anything else).
On my system, ob-scheme.el.gz can be found at
/usr/share/emacs/27.2/lisp/org
can I uncompress the file, patch that, then compress again?

Or, would I need to download the Emacs source, apply the patch and then 
recompile?

Thank you!

Bob Heffernan



Re: Problem with org-babel and geiser

2022-02-03 Thread Ihor Radchenko
Bob Heffernan  writes:

> I am having trouble with evaluating scheme source-blocks in org-mode.
> Specifically, in a minimal example such as this:
>
> #+title: Test
> #+PROPERTY: header-args :session *scheme*
>
> #+begin_src scheme
>   (+ 1 1)
> #+end_src
>
> When I evaluate the src block, the results come back empty.

Does the patch in
https://orgmode.org/list/3462869.oopU1TnKvU@felipe-thinkpad-x200 help?

Best,
Ihor



Problem with org-babel and geiser

2022-02-03 Thread Bob Heffernan
Dear all,

I am having trouble with evaluating scheme source-blocks in org-mode.
Specifically, in a minimal example such as this:

#+title: Test
#+PROPERTY: header-args :session *scheme*

#+begin_src scheme
  (+ 1 1)
#+end_src

When I evaluate the src block, the results come back empty.

The *geiser-messages* buffer has this:
WARNING: File /home/bob/.chez-geiser does not exist, so it's not added to CLI 
args

INFO: REQUEST: <1>: (begin (import (geiser)) (write `((result ) (output . ""))) 
(newline))

INFO: RETORT: ((result) (output . ""))

INFO: <1>: processed

ERROR: <2>: continuation failed "(geiser:eval '#f '(begin ;; -*- 
geiser-scheme-implementation: chez -*-
(+ 1 1)
))"
(error Selecting deleted buffer)

In an effort to make sure it's not something funny in my config, I reduced my 
init.el to the following:

(require 'package)
(add-to-list 'package-archives
  '("nongnu" . "https://elpa.nongnu.org/nongnu/;))
(package-initialize)

(require 'geiser)
(require 'geiser-chez)
(setq geiser-chez-binary "chez")
(org-babel-do-load-languages
 'org-babel-load-languages
 '((scheme . t)))

but the problem persists.

I happen to be using chez scheme, but the same issue arises with other 
implementations (I tried guile, chicken and racket).  On the other hand, 
evaluating an elisp block works fine.

This might be a geiser problem, rather than an org problem, but geiser appears 
to be working fine otherwise.

I'm running Emacs 27.2 on Arch Linux with Org 9.4.4.

Any help would be appreciated.

Regards,
Bob Heffernan