Hi! Ihor Radchenko <yanta...@posteo.net> writes:
> "Christopher M. Miles" <numbch...@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
>From 1a2fa382e7a5925d4b85d90f1fe4ac7c012f81a4 Mon Sep 17 00:00:00 2001 From: Daniel Kraus <dan...@kraus.my> Date: Thu, 27 Oct 2022 16:04:02 +0200 Subject: [PATCH] lisp/ob-clojure.el: Fix header argument :var binding * lisp/ob-clojure.el (org-babel-expand-body:clojure): Always quote the variables passed from org-mode in clojure let binding. When a variable is a table or list, it's value is is "(..data..)" and without quotes, clojure would try to execute the first value as a function. --- lisp/ob-clojure.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/ob-clojure.el b/lisp/ob-clojure.el index 0649469b3..c76a3f013 100644 --- a/lisp/ob-clojure.el +++ b/lisp/ob-clojure.el @@ -132,7 +132,7 @@ or set the `:backend' header argument")))) (format "(let [%s]\n%s)" (mapconcat (lambda (var) - (format "%S %S" (car var) (cdr var))) + (format "%S '%S" (car var) (cdr var))) vars "\n ") body)))))) -- 2.38.1