emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Fix ob-clojure handling source block variable's value is a o


From: Daniel Kraus
Subject: Re: [PATCH] Fix ob-clojure handling source block variable's value is a org-mode table or list
Date: Thu, 27 Oct 2022 16:09:34 +0200

Hi!

Ihor Radchenko <yantar92@posteo.net> writes:

> "Christopher M. Miles" <numbchild@gmail.com> writes:
>> Without this patch, it will report error "class 
>> java.lang.ClassCastException" from CIDER.
>
> Bastien, could you please take a look? I was unable to setup clojure dev
> environment on my machine for testing. So, I am not able to confirm if
> the issue exists.

Just in case you want to play around with Clojure, installing babashka
(https://github.com/babashka/babashka) is a single binary and very simple to 
install.

>>               ;; Variables binding.
>>               (if (null vars) (org-trim body)
>> -               (format "(let [%s]\n%s)"
>> -                       (mapconcat
>> -                        (lambda (var)
>> -                          (format "%S %S" (car var) (cdr var)))
>> -                        vars
>> -                        "\n      ")
>> -                       body))))))
>> +                   ;; variable's value is a list from org-mode passed table 
>> or list.
>> +               (if (listp (cdr (car vars)))
>
> This test is fishy. It only tests for the first variable assignment.
> What if you have multiple vars some being tables and some not?

I looked at `ob-lisp.el` and simply always quoting seems to be working.
See attached patch and here's my test (based from Chrisophers example):

--cut--

#+NAME: ob-clojure-table-test
| a | b | c |
|---+---+---|
| 1 | 2 | 3 |

#+NAME: ob-clojure-table-test-2
| a | b | c |
|---+---+---|
| 1 | 2 | 3 |
| 4 | 5 | 6 |

#+begin_src clojure :var v1=42 :var v2="foobar" :var v3=ob-clojure-table-test 
:var v4=ob-clojure-table-test-2 :results output
(prn (+ v1 5))
(prn v2)
(prn v3)
(prn v4)
#+end_src

#+RESULTS:
: 47
: "foobar"
: ((1 2 3))
: ((1 2 3) (4 5 6))

--cut--

Cheers,
  Daniel

Attachment: 0001-lisp-ob-clojure.el-Fix-header-argument-var-binding.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]