Re: Auto detect ob-clojure backend (was: [PATCH] Fix ob-clojure handling source block variable's value is a org-mode table or list)

2022-10-30 Thread Christopher M. Miles

Daniel Kraus  writes:

> Ihor Radchenko  writes:
>
>> Daniel Kraus  writes:
>>
>>> +(defcustom org-babel-clojure-backend (cond
>>> +  ((executable-find "bb") 'babashka)
>>> +  ((executable-find "nbb") 'nbb)
>>> +  ((featurep 'cider) 'cider)
>>> +  ((featurep 'inf-clojure) 
>>> 'inf-clojure)
>>> +  ((featurep 'slime) 'slime)
>>> + (t nil))
>>
>> What if users have, say, cider installed and also babashka executable?
>> Will it be expected to use babashka?
>
> Yes. The only thing that makes me slightly hesitant is that e.g.
> someone doesn't have `bb` installed. Executes clojure source blocks
> which are then evaluated in, let's say cider.
> Then they install `bb` and the next time they start Emacs, the same
> source block on re-evaluation would be executed with babashka.
>
> I think this is still the best out of the box experience as it
> "just works" for most users without having to customise something
> and if they want it fixed, they can pin it to a certain backend.
>
> What's your opinion?
>
> Cheers,
>   Daniel

I vote for use Clojure CLI like bb as default backend. Keeping defcustom
option for user to setting default backend is fine.

-- 

[ stardiviner ]
I try to make every word tell the meaning that I want to express without 
misunderstanding.

Blog: https://stardiviner.github.io/
IRC(libera.chat, freenode): stardiviner, Matrix: stardiviner
GPG: F09F650D7D674819892591401B5DF1C95AE89AC3


signature.asc
Description: PGP signature


Re: Auto detect ob-clojure backend (was: [PATCH] Fix ob-clojure handling source block variable's value is a org-mode table or list)

2022-10-30 Thread Daniel Kraus


Tim Cross  writes:

> I think bb is a much better solution from a babel perspective and would
> love to see it as the default, even when you have both bb and cider
> installed.

I just installed the patch. So if you have `bb` in your path, ob-clojure
should use babashka as default and only fall back to cider when it's not.

Currently it looks for bb, and then next `nbb` before cider.
Now I realise that nbb shouldn't even be in that list at all but instead
should be the default for `org-babel-execute:clojurescript`.

> I stopped using clojure in org because it was way too fragile -
> depending heavily on cider features which often changed. However, now we
> have babashka and nbb, I'm thinking about using org again with
> clojure.

Happy to hear feedback if you have any :)

> I recall looking at the babel code for clojure some time back to see if
> it could be made simpler and more reliable. However, there wasn't much
> that could be improved on given the design of cider and its focus on
> interactive clojure development.

I agree, cider is a pretty heavy library.
And I feel that if you have already "jacked in" in cider, you simply
eval straight from you clj(s) code instead of using org babel.
(Maybe in combination with clerk or something if you want it more literal)

> I then thought using something like the
> Clojure CLI tools might be the way to go.

I think I'll add a backend for the Clojure CLI tools.
Should be similar simple as bb and nbb with slower startup time,
but you would get a JVM Clojure for it.

> Now I feel that babashka for clojure and nbb for clojurescript
> might be the right answer.

Agree. bb default for Clojure and nbb for ClojureScript.

Thanks,
  Daniel



Re: Auto detect ob-clojure backend (was: [PATCH] Fix ob-clojure handling source block variable's value is a org-mode table or list)

2022-10-30 Thread Tim Cross


Daniel Kraus  writes:

> Ihor Radchenko  writes:
>
>> Daniel Kraus  writes:
>>
>>> +(defcustom org-babel-clojure-backend (cond
>>> +  ((executable-find "bb") 'babashka)
>>> +  ((executable-find "nbb") 'nbb)
>>> +  ((featurep 'cider) 'cider)
>>> +  ((featurep 'inf-clojure) 
>>> 'inf-clojure)
>>> +  ((featurep 'slime) 'slime)
>>> + (t nil))
>>
>> What if users have, say, cider installed and also babashka executable?
>> Will it be expected to use babashka?
>
> Yes. The only thing that makes me slightly hesitant is that e.g.
> someone doesn't have `bb` installed. Executes clojure source blocks
> which are then evaluated in, let's say cider.
> Then they install `bb` and the next time they start Emacs, the same
> source block on re-evaluation would be executed with babashka.
>
> I think this is still the best out of the box experience as it
> "just works" for most users without having to customise something
> and if they want it fixed, they can pin it to a certain backend.
>
> What's your opinion?
>
> Cheers,
>   Daniel

Just chime in with my 2 cents.

I think bb is a much better solution from a babel perspective and would
love to see it as the default, even when you have both bb and cider
installed.

I stopped using clojure in org because it was way too fragile -
depending heavily on cider features which often changed. However, now we
have babashka and nbb, I'm thinking about using org again with clojure.

I recall looking at the babel code for clojure some time back to see if
it could be made simpler and more reliable. However, there wasn't much
that could be improved on given the design of cider and its focus on
interactive clojure development. I then thought using something like the
Clojure CLI tools might be the way to go. Now I feel that babashka for
clojure and nbb for clojurescript might be the right answer. 



Re: Auto detect ob-clojure backend

2022-10-30 Thread Bastien Guerry
Ihor Radchenko  writes:

>> What's your opinion?
>
> I agree.

+1 (FWIW)

-- 
 Bastien



Re: Auto detect ob-clojure backend (was: [PATCH] Fix ob-clojure handling source block variable's value is a org-mode table or list)

2022-10-30 Thread Ihor Radchenko
Daniel Kraus  writes:

>> What if users have, say, cider installed and also babashka executable?
>> Will it be expected to use babashka?
>
> Yes. The only thing that makes me slightly hesitant is that e.g.
> someone doesn't have `bb` installed. Executes clojure source blocks
> which are then evaluated in, let's say cider.
> Then they install `bb` and the next time they start Emacs, the same
> source block on re-evaluation would be executed with babashka.
>
> I think this is still the best out of the box experience as it
> "just works" for most users without having to customise something
> and if they want it fixed, they can pin it to a certain backend.
>
> What's your opinion?

I agree.

Though if you want to go really fancy, you can utilize org-persist to
store the customization value in persistent cache (org-persist-register),
load it back (org-persist-read), and re-use when the cached backend can
be enabled.

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



Re: Auto detect ob-clojure backend (was: [PATCH] Fix ob-clojure handling source block variable's value is a org-mode table or list)

2022-10-30 Thread Daniel Kraus


Ihor Radchenko  writes:

> Daniel Kraus  writes:
>
>> +(defcustom org-babel-clojure-backend (cond
>> +  ((executable-find "bb") 'babashka)
>> +  ((executable-find "nbb") 'nbb)
>> +  ((featurep 'cider) 'cider)
>> +  ((featurep 'inf-clojure) 'inf-clojure)
>> +  ((featurep 'slime) 'slime)
>> +  (t nil))
>
> What if users have, say, cider installed and also babashka executable?
> Will it be expected to use babashka?

Yes. The only thing that makes me slightly hesitant is that e.g.
someone doesn't have `bb` installed. Executes clojure source blocks
which are then evaluated in, let's say cider.
Then they install `bb` and the next time they start Emacs, the same
source block on re-evaluation would be executed with babashka.

I think this is still the best out of the box experience as it
"just works" for most users without having to customise something
and if they want it fixed, they can pin it to a certain backend.

What's your opinion?

Cheers,
  Daniel



Re: Auto detect ob-clojure backend (was: [PATCH] Fix ob-clojure handling source block variable's value is a org-mode table or list)

2022-10-30 Thread Ihor Radchenko
Daniel Kraus  writes:

> Bastien  writes:
>
>> Daniel Kraus  writes:
>>
>>> I think I'll go with the big `cond` above to auto-detect what's
>>> installed. That's probably the best out-of-the-box experience.
>> Indeed, thank you!
>
> I would push the attached patch.

> +(defcustom org-babel-clojure-backend (cond
> +  ((executable-find "bb") 'babashka)
> +  ((executable-find "nbb") 'nbb)
> +  ((featurep 'cider) 'cider)
> +  ((featurep 'inf-clojure) 'inf-clojure)
> +  ((featurep 'slime) 'slime)
> +   (t nil))

What if users have, say, cider installed and also babashka executable? 
Will it be expected to use babashka?

> I'm not sure about the `:package-version` keyword in defcustom.
> I want to say that the default value changed.
> Should I do it this way? Is `(Org . "9.6")` correct as it's unreleased?

Yes. 9.6 is the next release - our main branch is labeled Org 9.6-pre.
So, using 9.6 is correct.

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



Auto detect ob-clojure backend (was: [PATCH] Fix ob-clojure handling source block variable's value is a org-mode table or list)

2022-10-30 Thread Daniel Kraus

Bastien  writes:

> Daniel Kraus  writes:
>
>> I think I'll go with the big `cond` above to auto-detect what's
>> installed. That's probably the best out-of-the-box experience.
> Indeed, thank you!

I would push the attached patch.
I'm not sure about the `:package-version` keyword in defcustom.
I want to say that the default value changed.
Should I do it this way? Is `(Org . "9.6")` correct as it's unreleased?

Thanks,
  Daniel
>From bd68ece99ce411439db87cd19e44ffbc49677ae3 Mon Sep 17 00:00:00 2001
From: Daniel Kraus 
Date: Sat, 29 Oct 2022 23:20:06 +0200
Subject: [PATCH] ob-clojure.el: Auto detect backend

* lisp/ob-clojure.el (org-babel-clojure-backend): Set the backend
to an available cli program or elisp package.
---
 lisp/ob-clojure.el | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/lisp/ob-clojure.el b/lisp/ob-clojure.el
index 5654d5208..25f1c78a6 100644
--- a/lisp/ob-clojure.el
+++ b/lisp/ob-clojure.el
@@ -76,9 +76,16 @@
 (defvar org-babel-default-header-args:clojurescript '())
 (defvar org-babel-header-args:clojurescript '((package . :any)))
 
-(defcustom org-babel-clojure-backend nil
+(defcustom org-babel-clojure-backend (cond
+  ((executable-find "bb") 'babashka)
+  ((executable-find "nbb") 'nbb)
+  ((featurep 'cider) 'cider)
+  ((featurep 'inf-clojure) 'inf-clojure)
+  ((featurep 'slime) 'slime)
+  (t nil))
   "Backend used to evaluate Clojure code blocks."
   :group 'org-babel
+  :package-version '(Org . "9.6")
   :type '(choice
 	  (const :tag "inf-clojure" inf-clojure)
 	  (const :tag "cider" cider)
-- 
2.38.1