Re: patch: ob-clojure improvements

2021-02-03 Thread Christopher Miles
<#secure method=pgpmime mode=sign>

You're right, seems now need to wait for Ag Ibragimov.

Tim Cross  writes:

OK. As the patch is over 6 months old, it would be good if the original author 
can confirm it is still the latest version and if not, re-send the most recent 
version.

Christopher Miles  writes:

<#!secure method=pgpmime mode=sign>

I checked this thread, seems the original first email of thread contains the 
patch. And it's not merged into Org git yet.

Tim Cross  writes:

OK, will push it up the todo list. Where can I get the latest version of the 
patch or has it been added into the org git repo?

Christopher Miles  writes:

<#!!secure method=pgpmime mode=sign>

Hi, Tim, popup this thread to request review. 

Tim Cross  writes:

I am also interested in ob-clojure and ob-clojurescript improvements. However, 
right now, I'm a tad busy and haven't had time to review what has been done. 
Hopefully, can make some time in the next month or so.

Tim

stardiviner  writes:

agzam.ibragi...@gmail.com writes:

There seems to be a bit of lack of interest for these things. But I'm sure some 
people (myself included) would love to see these kinds of improvements.

Yes, I rarely saw Clojurians in this mailing list.

As I said before, I have never participated in contributing to Org source, some 
guidance would be appreciated.

Org Mode has contribution guide here 
http://orgmode.org/worg/org-contribute.html#patches

Should I keep building it and posting patches? Should I try to go 
incrementally, one small change at a time, or should I just get everything 
working first? If it turns out to be a bigger work, should I ask for permission 
to work in a branch and get access to pushing things to it? Maybe things just 
move slowly, because obviously you can't force maintainers to drop everything 
and concentrate effort to get your things in. Maybe I just have to be a little 
bit more patient?

I think a complete work contains many patches should be better, Also write 
testing if necessary.

I remember ob-clojure.el code are mostly reviewed by Bastien Guerry. I included 
him in Cc: in this email.

On Sat, Jun 20, 2020 at 1:23 AM stardiviner  wrote:

Glad to see your patch, really useful in some cases. Thanks.

Ag Ibragimov  writes:

Hi everyone, here's my attempt to add clojure CLI and babashka support for 
ob-clojure.el - Adds a header parameter to override org-babel-clojure-backend - 
Adds :args param (right now only used for clojure-cli)

I have tested it with these minimal cases:

#+beginsrc clojure :backend clj-cli :args "-Sdeps '{:deps {inflections 
{:mvn/version \"0.13.2\"}}}'" (use 'inflections.core) (plural "word") #+endsrc

#+beginsrc clojure :backend babashka :results output (range 10) #+endsrc

Please let me know what you think. Any advice is appreciated, since I have 
never contributed before. Thank you.

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

Blog: https://stardiviner.github.io/ IRC(freenode): stardiviner, Matrix: 
stardiviner GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
s
-- 
[ stardiviner ]
   I try to make every word tell the meaning that I want to express.

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


Re: patch: ob-clojure improvements

2021-02-02 Thread Tim Cross


OK. As the patch is over 6 months old, it would be good if the original
author can confirm it is still the latest version and if not, re-send
the most recent version.

Christopher Miles  writes:

> <#secure method=pgpmime mode=sign>
>
> I checked this thread, seems the original first email of thread contains the 
> patch. And it's not merged into Org git yet.
>
> Tim Cross  writes:
>
> OK, will push it up the todo list. Where can I get the latest version of the 
> patch or has it been added into the org git repo?
>
> Christopher Miles  writes:
>
> <#!secure method=pgpmime mode=sign>
>
> Hi, Tim, popup this thread to request review. 
>
> Tim Cross  writes:
>
> I am also interested in ob-clojure and ob-clojurescript improvements. 
> However, right now, I'm a tad busy and haven't had time to review what has 
> been done. Hopefully, can make some time in the next month or so.
>
> Tim
>
> stardiviner  writes:
>
> agzam.ibragi...@gmail.com writes:
>
> There seems to be a bit of lack of interest for these things. But I'm sure 
> some people (myself included) would love to see these kinds of improvements.
>
> Yes, I rarely saw Clojurians in this mailing list.
>
> As I said before, I have never participated in contributing to Org source, 
> some guidance would be appreciated.
>
> Org Mode has contribution guide here 
> http://orgmode.org/worg/org-contribute.html#patches
>
> Should I keep building it and posting patches? Should I try to go 
> incrementally, one small change at a time, or should I just get everything 
> working first? If it turns out to be a bigger work, should I ask for 
> permission to work in a branch and get access to pushing things to it? Maybe 
> things just move slowly, because obviously you can't force maintainers to 
> drop everything and concentrate effort to get your things in. Maybe I just 
> have to be a little bit more patient?
>
> I think a complete work contains many patches should be better, Also write 
> testing if necessary.
>
> I remember ob-clojure.el code are mostly reviewed by Bastien Guerry. I 
> included him in Cc: in this email.
>
> On Sat, Jun 20, 2020 at 1:23 AM stardiviner  wrote:
>
> Glad to see your patch, really useful in some cases. Thanks.
>
> Ag Ibragimov  writes:
>
> Hi everyone, here's my attempt to add clojure CLI and babashka support for 
> ob-clojure.el - Adds a header parameter to override org-babel-clojure-backend 
> - Adds :args param (right now only used for clojure-cli)
>
> I have tested it with these minimal cases:
>
> #+beginsrc clojure :backend clj-cli :args "-Sdeps '{:deps {inflections 
> {:mvn/version \"0.13.2\"}}}'" (use 'inflections.core) (plural "word") #+endsrc
>
> #+beginsrc clojure :backend babashka :results output (range 10) #+endsrc
>
> Please let me know what you think. Any advice is appreciated, since I have 
> never contributed before. Thank you.
>
> – [ stardiviner ] I try to make every word tell the meaning that I want to 
> express.
>
> Blog: https://stardiviner.github.io/ IRC(freenode): stardiviner, Matrix: 
> stardiviner GPG: F09F650D7D674819892591401B5DF1C95AE89AC3


--
Tim Cross



Re: patch: ob-clojure improvements

2021-02-02 Thread Christopher Miles
<#secure method=pgpmime mode=sign>

I checked this thread, seems the original first email of thread contains the 
patch. And it's not merged into Org git yet.

Tim Cross  writes:

OK, will push it up the todo list. Where can I get the latest version of the 
patch or has it been added into the org git repo?

Christopher Miles  writes:

<#!secure method=pgpmime mode=sign>

Hi, Tim, popup this thread to request review. 

Tim Cross  writes:

I am also interested in ob-clojure and ob-clojurescript improvements. However, 
right now, I'm a tad busy and haven't had time to review what has been done. 
Hopefully, can make some time in the next month or so.

Tim

stardiviner  writes:

agzam.ibragi...@gmail.com writes:

There seems to be a bit of lack of interest for these things. But I'm sure some 
people (myself included) would love to see these kinds of improvements.

Yes, I rarely saw Clojurians in this mailing list.

As I said before, I have never participated in contributing to Org source, some 
guidance would be appreciated.

Org Mode has contribution guide here 
http://orgmode.org/worg/org-contribute.html#patches

Should I keep building it and posting patches? Should I try to go 
incrementally, one small change at a time, or should I just get everything 
working first? If it turns out to be a bigger work, should I ask for permission 
to work in a branch and get access to pushing things to it? Maybe things just 
move slowly, because obviously you can't force maintainers to drop everything 
and concentrate effort to get your things in. Maybe I just have to be a little 
bit more patient?

I think a complete work contains many patches should be better, Also write 
testing if necessary.

I remember ob-clojure.el code are mostly reviewed by Bastien Guerry. I included 
him in Cc: in this email.

On Sat, Jun 20, 2020 at 1:23 AM stardiviner  wrote:

Glad to see your patch, really useful in some cases. Thanks.

Ag Ibragimov  writes:

Hi everyone, here's my attempt to add clojure CLI and babashka support for 
ob-clojure.el - Adds a header parameter to override org-babel-clojure-backend - 
Adds :args param (right now only used for clojure-cli)

I have tested it with these minimal cases:

#+beginsrc clojure :backend clj-cli :args "-Sdeps '{:deps {inflections 
{:mvn/version \"0.13.2\"}}}'" (use 'inflections.core) (plural "word") #+endsrc

#+beginsrc clojure :backend babashka :results output (range 10) #+endsrc

Please let me know what you think. Any advice is appreciated, since I have 
never contributed before. Thank you.

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

Blog: https://stardiviner.github.io/ IRC(freenode): stardiviner, Matrix: 
stardiviner GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
-- 
[ stardiviner ]
   I try to make every word tell the meaning that I want to express.

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


Re: patch: ob-clojure improvements

2021-02-02 Thread Tim Cross


OK, will push it up the todo list. Where can I get the latest version of
the patch or has it been added into the org git repo?

Christopher Miles  writes:

> <#secure method=pgpmime mode=sign>
>
> Hi, Tim, popup this thread to request review. 
>
> Tim Cross  writes:
>
> I am also interested in ob-clojure and ob-clojurescript improvements. 
> However, right now, I'm a tad busy and haven't had time to review what has 
> been done. Hopefully, can make some time in the next month or so.
>
> Tim
>
> stardiviner  writes:
>
> agzam.ibragi...@gmail.com writes:
>
> There seems to be a bit of lack of interest for these things. But I'm sure 
> some people (myself included) would love to see these kinds of improvements.
>
> Yes, I rarely saw Clojurians in this mailing list.
>
> As I said before, I have never participated in contributing to Org source, 
> some guidance would be appreciated.
>
> Org Mode has contribution guide here 
> http://orgmode.org/worg/org-contribute.html#patches
>
> Should I keep building it and posting patches? Should I try to go 
> incrementally, one small change at a time, or should I just get everything 
> working first? If it turns out to be a bigger work, should I ask for 
> permission to work in a branch and get access to pushing things to it? Maybe 
> things just move slowly, because obviously you can't force maintainers to 
> drop everything and concentrate effort to get your things in. Maybe I just 
> have to be a little bit more patient?
>
> I think a complete work contains many patches should be better, Also write 
> testing if necessary.
>
> I remember ob-clojure.el code are mostly reviewed by Bastien Guerry. I 
> included him in Cc: in this email.
>
> On Sat, Jun 20, 2020 at 1:23 AM stardiviner  wrote:
>
> Glad to see your patch, really useful in some cases. Thanks.
>
> Ag Ibragimov  writes:
>
> Hi everyone, here's my attempt to add clojure CLI and babashka support
> for ob-clojure.el
> - Adds a header parameter to override org-babel-clojure-backend - Adds :args 
> param (right now only used for clojure-cli)
>
> I have tested it with these minimal cases:
>
> #+beginsrc clojure :backend clj-cli :args "-Sdeps '{:deps {inflections
> {:mvn/version \"0.13.2\"}}}'"
> (use 'inflections.core) (plural "word") #+endsrc
>
> #+beginsrc clojure :backend babashka :results output (range 10) #+endsrc
>
> Please let me know what you think. Any advice is appreciated, since I
> have never contributed before. Thank you.
>
> – [ stardiviner ] I try to make every word tell the meaning that I want to 
> express.
>
> Blog: https://stardiviner.github.io/ IRC(freenode): stardiviner, Matrix: 
> stardiviner GPG: F09F650D7D674819892591401B5DF1C95AE89AC3


--
Tim Cross



Re: patch: ob-clojure improvements

2021-02-02 Thread Christopher Miles
<#secure method=pgpmime mode=sign>

Hi, Tim, popup this thread to request review. 

Tim Cross  writes:

I am also interested in ob-clojure and ob-clojurescript improvements. However, 
right now, I'm a tad busy and haven't had time to review what has been done. 
Hopefully, can make some time in the next month or so.

Tim

stardiviner  writes:

agzam.ibragi...@gmail.com writes:

There seems to be a bit of lack of interest for these things. But I'm sure some 
people (myself included) would love to see these kinds of improvements.

Yes, I rarely saw Clojurians in this mailing list.

As I said before, I have never participated in contributing to Org source, some 
guidance would be appreciated.

Org Mode has contribution guide here 
http://orgmode.org/worg/org-contribute.html#patches

Should I keep building it and posting patches? Should I try to go 
incrementally, one small change at a time, or should I just get everything 
working first? If it turns out to be a bigger work, should I ask for permission 
to work in a branch and get access to pushing things to it? Maybe things just 
move slowly, because obviously you can't force maintainers to drop everything 
and concentrate effort to get your things in. Maybe I just have to be a little 
bit more patient?

I think a complete work contains many patches should be better, Also write 
testing if necessary.

I remember ob-clojure.el code are mostly reviewed by Bastien Guerry. I included 
him in Cc: in this email.

On Sat, Jun 20, 2020 at 1:23 AM stardiviner  wrote:

Glad to see your patch, really useful in some cases. Thanks.

Ag Ibragimov  writes:

Hi everyone, here's my attempt to add clojure CLI and babashka support
for ob-clojure.el
- Adds a header parameter to override org-babel-clojure-backend - Adds :args 
param (right now only used for clojure-cli)

I have tested it with these minimal cases:

#+beginsrc clojure :backend clj-cli :args "-Sdeps '{:deps {inflections
{:mvn/version \"0.13.2\"}}}'"
(use 'inflections.core) (plural "word") #+endsrc

#+beginsrc clojure :backend babashka :results output (range 10) #+endsrc

Please let me know what you think. Any advice is appreciated, since I
have never contributed before. Thank you.

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

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

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

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


Re: patch: ob-clojure improvements

2020-10-09 Thread General discussions about Org-mode.

Nice work, I did some testing here...

* Comment: Should babashka be added as an option for custom?

(defcustom org-babel-clojure-backend nil
  "Backend used to evaluate Clojure code blocks."
  :group 'org-babel
  :type '(choice
  (const :tag "inf-clojure" inf-clojure)
  (const :tag "cider" cider)
  (const :tag "slime" slime)
  (const :tag "Not configured yet" nil)))

* I wonder if there’s something wrong here?

... Inside ‘ob-clojure-eval-with-cider’

(push (or (nrepl-dict-get response "root-ex")
(nrepl-dict-get response "ex")
(nrepl-dict-get
 response (if (or (member "output" result-params)
  (member "pp" result-params))
  "out"
"value")))
result0)

That didn’t work for me, using an instance of Cider *connected to
babashka*.  But it did work when I swapped "value" and "out"!

- Testing code and inspecting with edebug:

#+begin_src clojure :backend cider :results output
  (range 10)
#+end_src

* Lastly, the documentation and implementation have drifted apart...?

https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-clojure.html

Ag Ibragimov writes:

Hi everyone, here's my attempt to add clojure CLI and babashka support 
for ob-clojure.el


- Adds a header parameter to override org-babel-clojure-backend
- Adds :args param (right now only used for clojure-cli)

I have tested it with these minimal cases:

#+begin_src clojure :backend clj-cli :args "-Sdeps '{:deps {inflections 
{:mvn/version \"0.13.2\"}}}'"

  (use 'inflections.core)
  (plural "word")
#+end_src

#+begin_src clojure :backend babashka :results output
  (range 10)
#+end_src

Please let me know what you think. Any advice is appreciated, since I 
have never contributed before. Thank you.




Re: patch: ob-clojure improvements

2020-09-04 Thread Bastien
Hi Agzam,

agzam.ibragi...@gmail.com writes:

> There seems to be a bit of lack of interest for these things. But I'm
> sure some people (myself included) would love to see these kinds of
> improvements. 

I'm very interested in improvements to ob-clojure*.el, thanks for the
work you did on it and sorry for the delay in replying.

I will have a look after 9.4 is released.

Best,

-- 
 Bastien



Re: patch: ob-clojure improvements

2020-07-02 Thread Tim Cross


I am also interested in ob-clojure and ob-clojurescript improvements.
However, right now, I'm a tad busy and haven't had time to review what
has been done. Hopefully, can make some time in the next month or so.

Tim

stardiviner  writes:

> agzam.ibragi...@gmail.com writes:
>
>> There seems to be a bit of lack of interest for these things. But I'm sure
>> some people (myself included) would love to see these kinds of
>> improvements.
>
> Yes, I rarely saw Clojurians in this mailing list.
>
>> As I said before, I have never participated in contributing
>> to Org source, some guidance would be appreciated.
>
> Org Mode has contribution guide here 
> http://orgmode.org/worg/org-contribute.html#patches
>
>> Should I keep building it and posting patches? Should I try to go
>> incrementally, one small change at a time, or should I just get everything
>> working first? If it turns out to be a bigger work, should I ask for
>> permission to work in a branch and get access to pushing things to it? Maybe
>> things just move slowly, because obviously you can't force maintainers to 
>> drop
>> everything and concentrate effort to get your things in. Maybe I just have to
>> be a little bit more patient?
>
> I think a complete work contains many patches should be better, Also write 
> testing if necessary.
>
> I remember ob-clojure.el code are mostly reviewed by Bastien Guerry. I 
> included him in Cc: in this email.
>
>> On Sat, Jun 20, 2020 at 1:23 AM stardiviner  wrote:
>>
>>>
>>> Glad to see your patch, really useful in some cases. Thanks.
>>>
>>> Ag Ibragimov  writes:
>>>
>>> > Hi everyone, here's my attempt to add clojure CLI and babashka support
>>> for ob-clojure.el
>>> >
>>> > - Adds a header parameter to override org-babel-clojure-backend
>>> > - Adds :args param (right now only used for clojure-cli)
>>> >
>>> > I have tested it with these minimal cases:
>>> >
>>> > #+begin_src clojure :backend clj-cli :args "-Sdeps '{:deps {inflections
>>> {:mvn/version \"0.13.2\"}}}'"
>>> >   (use 'inflections.core)
>>> >   (plural "word")
>>> > #+end_src
>>> >
>>> > #+begin_src clojure :backend babashka :results output
>>> >   (range 10)
>>> > #+end_src
>>> >
>>> > Please let me know what you think. Any advice is appreciated, since I
>>> have never contributed before. Thank you.
>>>
>>>
>>> --
>>> [ stardiviner ]
>>>I try to make every word tell the meaning that I want to express.
>>>
>>>Blog: https://stardiviner.github.io/
>>>IRC(freenode): stardiviner, Matrix: stardiviner
>>>GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
>>>


-- 
Tim Cross



Re: patch: ob-clojure improvements

2020-07-02 Thread stardiviner


agzam.ibragi...@gmail.com writes:

> There seems to be a bit of lack of interest for these things. But I'm sure
> some people (myself included) would love to see these kinds of
> improvements.

Yes, I rarely saw Clojurians in this mailing list.

> As I said before, I have never participated in contributing
> to Org source, some guidance would be appreciated.

Org Mode has contribution guide here 
http://orgmode.org/worg/org-contribute.html#patches

> Should I keep building it and posting patches? Should I try to go
> incrementally, one small change at a time, or should I just get everything
> working first? If it turns out to be a bigger work, should I ask for
> permission to work in a branch and get access to pushing things to it? Maybe
> things just move slowly, because obviously you can't force maintainers to drop
> everything and concentrate effort to get your things in. Maybe I just have to
> be a little bit more patient?

I think a complete work contains many patches should be better, Also write 
testing if necessary.

I remember ob-clojure.el code are mostly reviewed by Bastien Guerry. I included 
him in Cc: in this email.

> On Sat, Jun 20, 2020 at 1:23 AM stardiviner  wrote:
>
>>
>> Glad to see your patch, really useful in some cases. Thanks.
>>
>> Ag Ibragimov  writes:
>>
>> > Hi everyone, here's my attempt to add clojure CLI and babashka support
>> for ob-clojure.el
>> >
>> > - Adds a header parameter to override org-babel-clojure-backend
>> > - Adds :args param (right now only used for clojure-cli)
>> >
>> > I have tested it with these minimal cases:
>> >
>> > #+begin_src clojure :backend clj-cli :args "-Sdeps '{:deps {inflections
>> {:mvn/version \"0.13.2\"}}}'"
>> >   (use 'inflections.core)
>> >   (plural "word")
>> > #+end_src
>> >
>> > #+begin_src clojure :backend babashka :results output
>> >   (range 10)
>> > #+end_src
>> >
>> > Please let me know what you think. Any advice is appreciated, since I
>> have never contributed before. Thank you.
>>
>>
>> --
>> [ stardiviner ]
>>I try to make every word tell the meaning that I want to express.
>>
>>Blog: https://stardiviner.github.io/
>>IRC(freenode): stardiviner, Matrix: stardiviner
>>GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
>>


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

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



Re: patch: ob-clojure improvements

2020-07-02 Thread agzam . ibragimov
There seems to be a bit of lack of interest for these things. But I'm sure
some people (myself included) would love to see these kinds of
improvements. As I said before, I have never participated in contributing
to Org source, some guidance would be appreciated. Should I keep building
it and posting patches? Should I try to go incrementally, one small change
at a time, or should I just get everything working first? If it turns out
to be a bigger work, should I ask for permission to work in a branch and
get access to pushing things to it?
Maybe things just move slowly, because obviously you can't force
maintainers to drop everything and concentrate effort to get your things
in. Maybe I just have to be a little bit more patient?

On Sat, Jun 20, 2020 at 1:23 AM stardiviner  wrote:

>
> Glad to see your patch, really useful in some cases. Thanks.
>
> Ag Ibragimov  writes:
>
> > Hi everyone, here's my attempt to add clojure CLI and babashka support
> for ob-clojure.el
> >
> > - Adds a header parameter to override org-babel-clojure-backend
> > - Adds :args param (right now only used for clojure-cli)
> >
> > I have tested it with these minimal cases:
> >
> > #+begin_src clojure :backend clj-cli :args "-Sdeps '{:deps {inflections
> {:mvn/version \"0.13.2\"}}}'"
> >   (use 'inflections.core)
> >   (plural "word")
> > #+end_src
> >
> > #+begin_src clojure :backend babashka :results output
> >   (range 10)
> > #+end_src
> >
> > Please let me know what you think. Any advice is appreciated, since I
> have never contributed before. Thank you.
>
>
> --
> [ stardiviner ]
>I try to make every word tell the meaning that I want to express.
>
>Blog: https://stardiviner.github.io/
>IRC(freenode): stardiviner, Matrix: stardiviner
>GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
>


-- 
Regards,
Ag.


Re: patch: ob-clojure improvements

2020-06-20 Thread stardiviner


Glad to see your patch, really useful in some cases. Thanks.

Ag Ibragimov  writes:

> Hi everyone, here's my attempt to add clojure CLI and babashka support for 
> ob-clojure.el
>
> - Adds a header parameter to override org-babel-clojure-backend
> - Adds :args param (right now only used for clojure-cli)
>
> I have tested it with these minimal cases:
>
> #+begin_src clojure :backend clj-cli :args "-Sdeps '{:deps {inflections 
> {:mvn/version \"0.13.2\"}}}'"
>   (use 'inflections.core)
>   (plural "word")
> #+end_src
>
> #+begin_src clojure :backend babashka :results output
>   (range 10)
> #+end_src
>
> Please let me know what you think. Any advice is appreciated, since I have 
> never contributed before. Thank you.


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

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



patch: ob-clojure improvements

2020-06-20 Thread Ag Ibragimov

Hi everyone, here's my attempt to add clojure CLI and babashka support for 
ob-clojure.el

- Adds a header parameter to override org-babel-clojure-backend
- Adds :args param (right now only used for clojure-cli)

I have tested it with these minimal cases:

#+begin_src clojure :backend clj-cli :args "-Sdeps '{:deps {inflections {:mvn/version 
\"0.13.2\"}}}'"
 (use 'inflections.core)
 (plural "word")
#+end_src

#+begin_src clojure :backend babashka :results output
 (range 10)
#+end_src

Please let me know what you think. Any advice is appreciated, since I have 
never contributed before. Thank you.

diff --git a/lisp/ob-clojure.el b/lisp/ob-clojure.el
index 299a326e4..4e79a2c24 100644
--- a/lisp/ob-clojure.el
+++ b/lisp/ob-clojure.el
@@ -61,7 +61,13 @@ (add-to-list 'org-babel-tangle-lang-exts '("clojure" . "clj"))
 (add-to-list 'org-babel-tangle-lang-exts '("clojurescript" . "cljs"))
 
 (defvar org-babel-default-header-args:clojure '())
-(defvar org-babel-header-args:clojure '((ns . :any) (package . :any)))
+
+(defvar org-babel-header-args:clojure
+  '((ns . :any)
+(package . :any)
+(backend . ((inf-clojure cider slime clj-cli babashka)))
+(args . :any)))
+
 (defvar org-babel-default-header-args:clojurescript '())
 (defvar org-babel-header-args:clojurescript '((package . :any)))
 
@@ -224,25 +230,47 @@ (defun ob-clojure-eval-with-slime (expanded params)
,(buffer-substring-no-properties (point-min) (point-max)))
  (cdr (assq :package params)
 
+(defun ob-clojure-eval-with-babashka (expanded params)
+  "Evaluate EXPANDED code block with PARAMS using babashka."
+  (let ((exe (executable-find "bb")))
+(unless exe (user-error "babashka CLI (bb) not found."))
+(org-babel-execute:shell
+ (format "%s -e %S" exe expanded) params)))
+
+(defun ob-clojure-eval-with-clj-cli (expanded params)
+  "Evaluate EXPANDED code block with PARAMS using clojure-cli."
+  (let* ((args (cdr (assq :args params)))
+	 (exe (executable-find "clj")))
+(unless exe (user-error "clj CLI tool not found."))
+(org-babel-execute:shell
+ (format "%s %s -e %S" exe args expanded) params)))
+
 (defun org-babel-execute:clojure (body params)
   "Execute a block of Clojure code with Babel."
-  (unless org-babel-clojure-backend
-(user-error "You need to customize org-babel-clojure-backend"))
-  (let* ((expanded (org-babel-expand-body:clojure body params))
-	 (result-params (cdr (assq :result-params params)))
-	 result)
-(setq result
-	  (cond
-	   ((eq org-babel-clojure-backend 'inf-clojure)
-	(ob-clojure-eval-with-inf-clojure expanded params))
-	   ((eq org-babel-clojure-backend 'cider)
-	(ob-clojure-eval-with-cider expanded params))
-	   ((eq org-babel-clojure-backend 'slime)
-	(ob-clojure-eval-with-slime expanded params
-(org-babel-result-cond result-params
-  result
-  (condition-case nil (org-babel-script-escape result)
-	(error result)
+  (let* ((backend-override (cdr (assq :backend params)))
+	 (org-babel-clojure-backend
+	  (cond (backend-override (intern backend-override))
+		(org-babel-clojure-backend org-babel-clojure-backend)
+		(t (user-error "You need to customize org-babel-clojure-backend")
+(let* ((expanded (org-babel-expand-body:clojure body params))
+	   (result-params (cdr (assq :result-params params)))
+	   result)
+  (setq result
+	(cond
+	 ((eq org-babel-clojure-backend 'inf-clojure)
+	  (ob-clojure-eval-with-inf-clojure expanded params))
+	 ((eq org-babel-clojure-backend 'cider)
+	  (ob-clojure-eval-with-cider expanded params))
+	 ((eq org-babel-clojure-backend 'slime)
+	  (ob-clojure-eval-with-slime expanded params))
+	 ((eq org-babel-clojure-backend 'babashka)
+	  (ob-clojure-eval-with-babashka expanded params))
+	 ((eq org-babel-clojure-backend 'clj-cli)
+	  (ob-clojure-eval-with-clj-cli expanded params
+  (org-babel-result-cond result-params
+	result
+	(condition-case nil (org-babel-script-escape result)
+	  (error result))
 
 (defun org-babel-execute:clojurescript (body params)
   "Evaluate BODY with PARAMS as ClojureScript code."