Re: Babel (scheme): Evaluation errors are not shown

2023-01-25 Thread Ihor Radchenko
Marc Nieper-Wißkirchen  writes:

>> > Rebased against the latest main.  Please see the appended patch.

Applied, onto main, adding TINYCHANGE cookie and removing "." from the
commit summary.

https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=f35fb8ac2

You are now also listed as Org contributor:
https://git.sr.ht/~bzg/worg/commit/4f193b43

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: Babel (scheme): Evaluation errors are not shown

2023-01-07 Thread Marc Nieper-Wißkirchen
Am Sa., 7. Jan. 2023 um 08:44 Uhr schrieb Ihor Radchenko :
>
> Marc Nieper-Wißkirchen  writes:
>
> >> Thanks!
> >> Note that your patch does not apply onto main.
> >
> > Rebased against the latest main.  Please see the appended patch.
>
> Hmm.
> Not sure what is going on here, but I am getting
>
> 128 git … am --3way -- 
> /tmp/0001-lisp-ob-scheme.el-Do-not-hide-Scheme-evaluation-erro.patch
> Applying: lisp/ob-scheme.el: Do not hide Scheme evaluation errors.
> Using index info to reconstruct a base tree...
> error: patch failed: lisp/ob-scheme.el:194
> error: lisp/ob-scheme.el: patch does not apply
> error: Did you hand edit your patch?
> It does not apply to blobs recorded in its index.
> Patch failed at 0001 lisp/ob-scheme.el: Do not hide Scheme evaluation errors.
> hint: Use 'git am --show-current-patch=diff' to see the failed patch
> When you have resolved this problem, run "git am --continue".
> If you prefer to skip this patch, run "git am --skip" instead.
> To restore the original branch and stop patching, run "git am --abort".

Okay, apparently, `git format-patch -w' to ignore whitespace changes
does not work (at least not as simple as I thought).

A new patch file is attached; `git am' against the upstream head works here.

Thanks,

Marc

>
> --
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at .
> Support Org development at ,
> or support my work at 


0001-lisp-ob-scheme.el-Do-not-hide-Scheme-evaluation-erro.patch
Description: Binary data


Re: Babel (scheme): Evaluation errors are not shown

2023-01-07 Thread Bastien Guerry
Ihor Radchenko  writes:

> As for GCC-related assignment, I am not sure if it is sufficient.

I confirm that the copyright assignment should explicitely mention
EMACS as a GNU project.

-- 
 Bastien



Re: Babel (scheme): Evaluation errors are not shown

2023-01-06 Thread Marc Nieper-Wißkirchen
Am Fr., 6. Jan. 2023 um 17:34 Uhr schrieb :
>
> On Fri, Jan 06, 2023 at 04:20:29PM +, Ihor Radchenko wrote:
> > Ihor Radchenko  writes:
> >
> > > Marc Nieper-Wißkirchen  writes:
> > > ...
> >
> > May someone forward my last email to Marc?
> > For some reason, his mail server classifies my emails as spam and
> > rejects them.
>
> Just tried. Happens for me too.

Strange.  Can you try marc.nie...@gmail.com instead?

Thanks,

Marc

>
> Cheers
> --
> t



Re: Babel (scheme): Evaluation errors are not shown

2023-01-06 Thread Rudolf Adamkovič
Bastien  writes:

> Sure, done.

Thank you for your understanding, Bastien!

> (Or write ob-fennel.el?)

It already exists, FYI:

https://gitlab.com/andreyorst/ob-fennel

Rudy
-- 
"Simplicity is complexity resolved."
-- Constantin Brâncuși, 1876-1957

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



Re: Babel (scheme): Evaluation errors are not shown

2023-01-06 Thread tomas
On Fri, Jan 06, 2023 at 04:20:29PM +, Ihor Radchenko wrote:
> Ihor Radchenko  writes:
> 
> > Marc Nieper-Wißkirchen  writes:
> > ...
> 
> May someone forward my last email to Marc?
> For some reason, his mail server classifies my emails as spam and
> rejects them.

Just tried. Happens for me too.

Cheers
-- 
t


signature.asc
Description: PGP signature


Re: Babel (scheme): Evaluation errors are not shown

2023-01-06 Thread Ihor Radchenko
Ihor Radchenko  writes:

> Marc Nieper-Wißkirchen  writes:
> ...

May someone forward my last email to Marc?
For some reason, his mail server classifies my emails as spam and
rejects them.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: Babel (scheme): Evaluation errors are not shown

2023-01-06 Thread Ihor Radchenko
Marc Nieper-Wißkirchen  writes:

> Despite the unfortunate lack of a maintainer, I hope the (latest
> version of the) patch can still be applied as the current behavior of
> ob-scheme.el, namely, silencing any evaluation errors is infeasible.

Yes, it can. Can you please take a look at patch failure issue in my
last reply?

> Do you need any FSF copyright assignments from me? (I already
> contributed to GCC and Gnulib under such an assignment in the past.)

For this particular patch, your changes fall within TINYCHANGE (~15LOC),
so copyright should not be necessary.

As for GCC-related assignment, I am not sure if it is sufficient. In my
own assignment, GNU EMACS changes are mentioned explicitly. If your
assignment also mentions GCC and Gnulib only, I doubt that GNU EMACS is
also covered.

Bastien may know better.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: Babel (scheme): Evaluation errors are not shown

2023-01-05 Thread Marc Nieper-Wißkirchen
Despite the unfortunate lack of a maintainer, I hope the (latest
version of the) patch can still be applied as the current behavior of
ob-scheme.el, namely, silencing any evaluation errors is infeasible.

Do you need any FSF copyright assignments from me? (I already
contributed to GCC and Gnulib under such an assignment in the past.)

Thanks,

Marc

Am Mo., 2. Jan. 2023 um 10:52 Uhr schrieb Marc Nieper-Wißkirchen
:
>
> Am Mo., 2. Jan. 2023 um 10:38 Uhr schrieb Ihor Radchenko 
> :
> >
> > Marc Nieper-Wißkirchen  writes:
> >
> > > Fixed.
> >
> > Thanks!
> > Note that your patch does not apply onto main.
>
> Rebased against the latest main.  Please see the appended patch.
>
> >
> > > -   (setq result (if output
> > > +  (let ((err (geiser-eval--retort-error ret)))
> > > +(setq result (cond
> > > +  (err nil)
> >
> > We may still provide output, if any. Even in the case of error. Not sure
> > if it makes sense for ob-scheme though.
>
> I switched the two cases, "err" and "output," in the attached patch.
> For a value result, providing a result in case of an error does not
> make sense.
>
> Thanks for your patience,
>
> Marc



Re: Babel (scheme): Evaluation errors are not shown

2023-01-03 Thread Bastien
Hi Rudolf,

Rudolf Adamkovič  writes:

> So, my use of Scheme drops from 8 hours per day to effectively 0,
> effective today.  As a result, I would like to kindly ask you to revert
> the change, for without actively using something, I cannot maintain it.

Sure, done.

> That said, if my employer changes their mind during the transition from
> Scheme to Fennel and decides to keep the current code base, I will
> re-volunteer.
>
> Thank you for understanding, and I again apologize for the churn!

No problem, I hope you can re-volunteer at some point!   (Or write
ob-fennel.el?)

Thanks,

-- 
 Bastien



Re: Babel (scheme): Evaluation errors are not shown

2023-01-03 Thread Rudolf Adamkovič
Bastien Guerry  writes:

> I just added you as the maintainer of ob-scheme.el.

A sudden turn of events:

My employer have just decided that we will convert all Scheme to Fennel,
a zero-runtime Lisp based on Lua, because it has a better bus factor,
meaning that, in the worst-case, the company can continue with Lua, a
language for which one can find programmers more easily than for Scheme.

So, my use of Scheme drops from 8 hours per day to effectively 0,
effective today.  As a result, I would like to kindly ask you to revert
the change, for without actively using something, I cannot maintain it.

That said, if my employer changes their mind during the transition from
Scheme to Fennel and decides to keep the current code base, I will
re-volunteer.

Thank you for understanding, and I again apologize for the churn!

Rudy
-- 
"Be especially critical of any statement following the word
'obviously.'"
-- Anna Pell Wheeler, 1883-1966

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



Re: Babel (scheme): Evaluation errors are not shown

2023-01-03 Thread Ihor Radchenko
Marc Nieper-Wißkirchen  writes:

>> Thanks!
>> Note that your patch does not apply onto main.
>
> Rebased against the latest main.  Please see the appended patch.

Hmm.
Not sure what is going on here, but I am getting

128 git … am --3way -- 
/tmp/0001-lisp-ob-scheme.el-Do-not-hide-Scheme-evaluation-erro.patch
Applying: lisp/ob-scheme.el: Do not hide Scheme evaluation errors.
Using index info to reconstruct a base tree...
error: patch failed: lisp/ob-scheme.el:194
error: lisp/ob-scheme.el: patch does not apply
error: Did you hand edit your patch?
It does not apply to blobs recorded in its index.
Patch failed at 0001 lisp/ob-scheme.el: Do not hide Scheme evaluation errors.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: Babel (scheme): Evaluation errors are not shown

2023-01-02 Thread Marc Nieper-Wißkirchen
Am Mo., 2. Jan. 2023 um 10:38 Uhr schrieb Ihor Radchenko :
>
> Marc Nieper-Wißkirchen  writes:
>
> > Fixed.
>
> Thanks!
> Note that your patch does not apply onto main.

Rebased against the latest main.  Please see the appended patch.

>
> > -   (setq result (if output
> > +  (let ((err (geiser-eval--retort-error ret)))
> > +(setq result (cond
> > +  (err nil)
>
> We may still provide output, if any. Even in the case of error. Not sure
> if it makes sense for ob-scheme though.

I switched the two cases, "err" and "output," in the attached patch.
For a value result, providing a result in case of an error does not
make sense.

Thanks for your patience,

Marc


0001-lisp-ob-scheme.el-Do-not-hide-Scheme-evaluation-erro.patch
Description: Binary data


Re: Babel (scheme): Evaluation errors are not shown

2023-01-02 Thread Ihor Radchenko
Marc Nieper-Wißkirchen  writes:

> Fixed.

Thanks!
Note that your patch does not apply onto main.

> -   (setq result (if output
> +  (let ((err (geiser-eval--retort-error ret)))
> +(setq result (cond
> +  (err nil)

We may still provide output, if any. Even in the case of error. Not sure
if it makes sense for ob-scheme though.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: Babel (scheme): Evaluation errors are not shown

2023-01-01 Thread Marc Nieper-Wißkirchen
Fixed.

Am So., 1. Jan. 2023 um 14:53 Uhr schrieb Ihor Radchenko :
>
> Marc Nieper-Wißkirchen  writes:
>
> >  (defun org-babel-eval-error-notify (exit-code stderr)
> > -  "Open a buffer to display STDERR and a message with the value of 
> > EXIT-CODE."
> > +  "Open a buffer to display STDERR and a message with the value of 
> > EXIT-CODE.
> > +If EXIT-CODE is nil, suppress the message."
>
> The docstring is not accurate now.
> If EXIT-CODE is nil, the message is not suppressed.
>
> > ...
> > -  (message "Babel evaluation exited with code %S" exit-code))
> > +  (if exit-code
> > +  (message "Babel evaluation exited with code %S" exit-code)
> > +(message "Babel evaluation exited abnormally")))
>
> --
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at .
> Support Org development at ,
> or support my work at 


0001-lisp-ob-scheme.el-Do-not-hide-Scheme-evaluation-erro.patch
Description: Binary data


Re: Babel (scheme): Evaluation errors are not shown

2023-01-01 Thread Ihor Radchenko
Marc Nieper-Wißkirchen  writes:

>  (defun org-babel-eval-error-notify (exit-code stderr)
> -  "Open a buffer to display STDERR and a message with the value of 
> EXIT-CODE."
> +  "Open a buffer to display STDERR and a message with the value of EXIT-CODE.
> +If EXIT-CODE is nil, suppress the message."

The docstring is not accurate now.
If EXIT-CODE is nil, the message is not suppressed.

> ...
> -  (message "Babel evaluation exited with code %S" exit-code))
> +  (if exit-code
> +  (message "Babel evaluation exited with code %S" exit-code)
> +(message "Babel evaluation exited abnormally")))

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: Babel (scheme): Evaluation errors are not shown

2022-12-31 Thread Marc Nieper-Wißkirchen
Done!

Am Sa., 31. Dez. 2022 um 14:24 Uhr schrieb Ihor Radchenko :
>
> Marc Nieper-Wißkirchen  writes:
>
> > Please find the patch file attached to this email.
>
> Thanks!
> I will give some general comments and leave the ob-scheme changes for
> Rudolf.
>
> > Subject: [PATCH] Display evaluation errors for Scheme code blocks.
>
> If you can, please provide changelog entries explaining each change. See
> https://orgmode.org/worg/org-contribute.html#commit-messages
>
> >(let ((buf (get-buffer-create org-babel-error-buffer-name)))
> >  (with-current-buffer buf
> >(goto-char (point-max))
> >(save-excursion
> >  (unless (bolp) (insert "\n"))
> >  (insert stderr)
> > -(insert (format "[ Babel evaluation exited with code %S ]" 
> > exit-code
> > +(when exit-code
> > +  (insert (format "[ Babel evaluation exited with code %S ]" 
> > exit-code)
>
> I think it will be more consistent to do something like
>
> (if exit-code ... (insert " [ Babel evaluation exited abnormally ] "))
>
> --
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at .
> Support Org development at ,
> or support my work at 


0001-lisp-ob-scheme.el-Do-not-hide-Scheme-evaluation-erro.patch
Description: Binary data


Re: Babel (scheme): Evaluation errors are not shown

2022-12-31 Thread Ihor Radchenko
Marc Nieper-Wißkirchen  writes:

> Please find the patch file attached to this email.

Thanks!
I will give some general comments and leave the ob-scheme changes for
Rudolf.

> Subject: [PATCH] Display evaluation errors for Scheme code blocks.

If you can, please provide changelog entries explaining each change. See
https://orgmode.org/worg/org-contribute.html#commit-messages

>(let ((buf (get-buffer-create org-babel-error-buffer-name)))
>  (with-current-buffer buf
>(goto-char (point-max))
>(save-excursion
>  (unless (bolp) (insert "\n"))
>  (insert stderr)
> -(insert (format "[ Babel evaluation exited with code %S ]" 
> exit-code
> +(when exit-code
> +  (insert (format "[ Babel evaluation exited with code %S ]" 
> exit-code)

I think it will be more consistent to do something like

(if exit-code ... (insert " [ Babel evaluation exited abnormally ] "))

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: Babel (scheme): Evaluation errors are not shown

2022-12-31 Thread Marc Nieper-Wißkirchen
Please find the patch file attached to this email.

Thank you,

Marc

Am Sa., 31. Dez. 2022 um 13:07 Uhr schrieb Ihor Radchenko :
>
> Marc Nieper-Wißkirchen  writes:
>
> > Please find attached a version that does not signal an Elisp user
> > error, but calls `org-babel-eval-error-notify' instead.
>
> If you can, could you please send the changes in form of a patch
> instead? It is then easier to review.
> See https://orgmode.org/worg/org-contribute.html#patches (you can just
> attach the patch to your reply).
>
> > To get rid of
> > the display of the arbitrary error code, could we modify
> > `org-babel-eval-error-notify' so that nothing is displayed about an
> > error if the error code is `nil'?
>
> Yes, we can. Feel free to make a patch, updating the docstring according
> to your changes.
>
> --
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at .
> Support Org development at ,
> or support my work at 


0001-Display-evaluation-errors-for-Scheme-code-blocks.patch
Description: Binary data


Re: Babel (scheme): Evaluation errors are not shown

2022-12-31 Thread Ihor Radchenko
Marc Nieper-Wißkirchen  writes:

> Please find attached a version that does not signal an Elisp user
> error, but calls `org-babel-eval-error-notify' instead.

If you can, could you please send the changes in form of a patch
instead? It is then easier to review.
See https://orgmode.org/worg/org-contribute.html#patches (you can just
attach the patch to your reply).

> To get rid of
> the display of the arbitrary error code, could we modify
> `org-babel-eval-error-notify' so that nothing is displayed about an
> error if the error code is `nil'?

Yes, we can. Feel free to make a patch, updating the docstring according
to your changes.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: Babel (scheme): Evaluation errors are not shown

2022-12-31 Thread Marc Nieper-Wißkirchen
Am Sa., 31. Dez. 2022 um 11:19 Uhr schrieb Marc Nieper-Wißkirchen
:
>
> Am Sa., 31. Dez. 2022 um 11:09 Uhr schrieb Marc Nieper-Wißkirchen
> :
> >
> > Am Sa., 31. Dez. 2022 um 10:49 Uhr schrieb Ihor Radchenko 
> > :
> > >
> > > Marc Nieper-Wißkirchen  writes:

[...]

> > >  It is not what we usually do in Org babel. If blocks execution
> > > fails, we display the error in separate buffer and still return the
> > > output available before error has been thrown. See `org-babel-eval' and
> > > `org-babel-eval-error-notify'.
> >
> > I will take a look.
>
> Hmmm... `org-babel-eval-error-notify' assumes that the code was
> evaluated by running an external script.  In the case of the Geiser
> interface to Scheme, the concept of an exit code does not make any
> sense.

Please find attached a version that does not signal an Elisp user
error, but calls `org-babel-eval-error-notify' instead.  To get rid of
the display of the arbitrary error code, could we modify
`org-babel-eval-error-notify' so that nothing is displayed about an
error if the error code is `nil'?


ob-scheme.el
Description: Binary data


Re: Babel (scheme): Evaluation errors are not shown

2022-12-31 Thread Marc Nieper-Wißkirchen
Am Sa., 31. Dez. 2022 um 11:09 Uhr schrieb Marc Nieper-Wißkirchen
:
>
> Am Sa., 31. Dez. 2022 um 10:49 Uhr schrieb Ihor Radchenko 
> :
> >
> > Marc Nieper-Wißkirchen  writes:
> >
> > > I have been talking to jao (from geiser).  The following version of
> > > ob-scheme.el signals an error when executing Scheme code blocks.
> > > Besides two function declarations, the only change is in the function
> > > org-babel-scheme-execute-with-geiser.
> >
> > Do you mean that `org-babel-scheme-execute-with-geiser' throws Elisp
> > error?
>
> This is what it currently does; it packages the Scheme error as an
> Elisp *user* error.
>
> I chose this behavior to mimic what happens when Elisp code blocks
> produce errors.
>
> >  It is not what we usually do in Org babel. If blocks execution
> > fails, we display the error in separate buffer and still return the
> > output available before error has been thrown. See `org-babel-eval' and
> > `org-babel-eval-error-notify'.
>
> I will take a look.

Hmmm... `org-babel-eval-error-notify' assumes that the code was
evaluated by running an external script.  In the case of the Geiser
interface to Scheme, the concept of an exit code does not make any
sense.



Re: Babel (scheme): Evaluation errors are not shown

2022-12-31 Thread Marc Nieper-Wißkirchen
Am Sa., 31. Dez. 2022 um 10:49 Uhr schrieb Ihor Radchenko :
>
> Marc Nieper-Wißkirchen  writes:
>
> > I have been talking to jao (from geiser).  The following version of
> > ob-scheme.el signals an error when executing Scheme code blocks.
> > Besides two function declarations, the only change is in the function
> > org-babel-scheme-execute-with-geiser.
>
> Do you mean that `org-babel-scheme-execute-with-geiser' throws Elisp
> error?

This is what it currently does; it packages the Scheme error as an
Elisp *user* error.

I chose this behavior to mimic what happens when Elisp code blocks
produce errors.

>  It is not what we usually do in Org babel. If blocks execution
> fails, we display the error in separate buffer and still return the
> output available before error has been thrown. See `org-babel-eval' and
> `org-babel-eval-error-notify'.

I will take a look.

Thanks,

Marc

>
> --
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at .
> Support Org development at ,
> or support my work at 



Re: Babel (scheme): Evaluation errors are not shown

2022-12-31 Thread Ihor Radchenko
Marc Nieper-Wißkirchen  writes:

> I have been talking to jao (from geiser).  The following version of
> ob-scheme.el signals an error when executing Scheme code blocks.
> Besides two function declarations, the only change is in the function
> org-babel-scheme-execute-with-geiser.

Do you mean that `org-babel-scheme-execute-with-geiser' throws Elisp
error? It is not what we usually do in Org babel. If blocks execution
fails, we display the error in separate buffer and still return the
output available before error has been thrown. See `org-babel-eval' and
`org-babel-eval-error-notify'.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: Babel (scheme): Evaluation errors are not shown

2022-12-29 Thread Bastien Guerry
Hi Rudolf and Ihor,

Ihor Radchenko  writes:

> Rudolf Adamkovič  writes:
>
>> Ihor Radchenko  writes:
>>
>>> Note that we currently have no maintainer for ob-scheme and hence can
>>> only provide very limited support. New features are hard for us
>>> without experience with scheme and geiser.
>>
>> I volunteer to maintain `ob-scheme'.

I just added you as the maintainer of ob-scheme.el.

You are already in the list of FSF-copyrighted contributors on Worg.

Thank you very much!

-- 
 Bastien



Re: Babel (scheme): Evaluation errors are not shown

2022-12-21 Thread Ihor Radchenko
Rudolf Adamkovič  writes:

> Ihor Radchenko  writes:
>
>> Note that we currently have no maintainer for ob-scheme and hence can
>> only provide very limited support. New features are hard for us
>> without experience with scheme and geiser.
>
> I volunteer to maintain `ob-scheme'.
>
> (I use Scheme and Geiser heavily at work, albeit not via Org.)

CCing Bastien.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: Babel (scheme): Evaluation errors are not shown

2022-12-20 Thread Marc Nieper-Wißkirchen
I have been talking to jao (from geiser).  The following version of
ob-scheme.el signals an error when executing Scheme code blocks.
Besides two function declarations, the only change is in the function
org-babel-scheme-execute-with-geiser.

;;; 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
;; URL: 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 'org-macs)
(org-assert-version)

(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 "ext:geiser-repl" (impl))
(declare-function geiser-mode "ext:geiser-mode" ())
(declare-function geiser-eval-region "ext:geiser-mode"
  (start end &optional and-go raw nomsg))
(declare-function geiser-eval-region/wait "ext:geiser-mode"
  (start end &optional timeout))
(declare-function geiser-repl-exit "ext:geiser-repl" (&optional arg))
(declare-function geiser-eval--retort-output "ext:geiser-eval" (ret))
(declare-function geiser-eval--retort-result-str "ext:geiser-eval" (ret prefix))
(declare-function geiser-eval--retort-error "ext:geiser-eval" (ret))
(declare-function geiser-eval--retort-error-msg "ext:geiser-eval" (err))

(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 (session-name)
  "Look up the scheme buffer for a session; return nil if it doesn't exist."
  (org-babel-scheme-cleanse-repl-map) ; Prune dead sessions
  (gethash session-name org-babel-scheme-repl-map))

(defun org-babel-scheme-set-session-buffer (session-name buffer)
  "Record the scheme buffer used for a given session."
  (puthash session-name buffer org-babel-scheme-repl-map))

(defun org-babel-scheme-get-buffer-impl (buffer)
  "Return the scheme implementation geiser associates with the buffer."
  (with-current-buffer (set-buffer buffer)
geiser-impl--implementation))

(defun org-babel-scheme-get-repl (impl name)
  "Switch to 

Re: Babel (scheme): Evaluation errors are not shown

2022-12-19 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

> Note that we currently have no maintainer for ob-scheme and hence can
> only provide very limited support. New features are hard for us
> without experience with scheme and geiser.

I volunteer to maintain `ob-scheme'.

(I use Scheme and Geiser heavily at work, albeit not via Org.)

Rudy
-- 
"Mathematics takes us still further from what is human into the region
of absolute necessity, to which not only the actual world, but every
possible world, must conform."
-- Bertrand Russell, 1902

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



Re: Babel (scheme): Evaluation errors are not shown

2022-12-18 Thread Ihor Radchenko
Marc Nieper-Wißkirchen  writes:

> When I evaluate erroneous code of an Elisp code block like
>
> #+BEGIN_SRC elisp
> (x)
> #+END_SRC
>
> I see the error message ("Symbol's function definition is void: x") in
> the minibuffer (and in the *Messages* buffer).
>
> This is not the case with Scheme code blocks; evaluating the code block
>
> #+BEGIN_SRC scheme
> (x)
> #+END_SRC
>
> just gives "Code block evaluation complete (took 0.2s)." in the
> minibuffer (and in the *Messages* buffer).
>
> Is this a known error? Or is there a way to enable error messages?

ob-scheme.el relies on geiser library to handle code execution.
I do not know if it is possible to retrieve error messages using geiser
functions. You may check out `org-babel-scheme-execute-with-geiser' and
see if something can be done.

Note that we currently have no maintainer for ob-scheme and hence can
only provide very limited support. New features are hard for us without
experience with scheme and geiser.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Babel (scheme): Evaluation errors are not shown

2022-12-16 Thread Marc Nieper-Wißkirchen
When I evaluate erroneous code of an Elisp code block like

#+BEGIN_SRC elisp
(x)
#+END_SRC

I see the error message ("Symbol's function definition is void: x") in
the minibuffer (and in the *Messages* buffer).

This is not the case with Scheme code blocks; evaluating the code block

#+BEGIN_SRC scheme
(x)
#+END_SRC

just gives "Code block evaluation complete (took 0.2s)." in the
minibuffer (and in the *Messages* buffer).

Is this a known error? Or is there a way to enable error messages?

I am using org 9.6 with geiser 20221205.1417 and geiser-chez
20221027.137 on Emacs 27.1.

Thanks,

Marc