* [PATCH] Fix ob-clojure handling source block variable's value is a org-mode table or list
@ 2022-04-09 13:19 Christopher M. Miles
0 siblings, 0 replies; 13+ messages in thread
From: Christopher M. Miles @ 2022-04-09 13:19 UTC (permalink / raw)
To: Org Mode
[-- Attachment #1.1: Type: text/plain, Size: 499 bytes --]
I bellowing example:
#+begin_src org
,#+NAME: ob-clojure-table-test
| a | b | c |
|---+---+---|
| 1 | 2 | 3 |
,#+NAME: ob-clojure-table-test-2
| a | b | c |
|---+---+---|
| 1 | 2 | 3 |
,#+begin_src clojure :var kk=ob-clojure-table-test :var kk2=ob-clojure-table-test-2 :results output
(println kk2)
(println kk)
,#+end_src
#+end_src
Without this patch, it will report error "class java.lang.ClassCastException" from CIDER.
This patch added if condition to handle this table, list type data.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-ob-clojure.el-Fix-header-argument-var-binding-passed.patch --]
[-- Type: text/x-patch, Size: 2072 bytes --]
From 948e8c1ff2c9ba1d9c0fe26f9bdaa096bef80a9d Mon Sep 17 00:00:00 2001
From: stardiviner <numbchild@gmail.com>
Date: Sat, 9 Apr 2022 21:14:22 +0800
Subject: [PATCH] ob-clojure.el: Fix header argument :var binding passed table
or list data
* lisp/ob-clojure.el (org-babel-expand-body:clojure): Add if condition
to handle source block :var passed org-mode table or list data for
clojure let-binding to avoid java.lang.ClassCastException.
---
lisp/ob-clojure.el | 25 ++++++++++++++++++-------
1 file changed, 18 insertions(+), 7 deletions(-)
diff --git a/lisp/ob-clojure.el b/lisp/ob-clojure.el
index 5a44b6487..e6614b2d9 100644
--- a/lisp/ob-clojure.el
+++ b/lisp/ob-clojure.el
@@ -101,13 +101,24 @@
(and (cdr (assq :ns params)) (format "(ns %s)\n" ns))
;; 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)))
+ (format "(let [%s]\n%s)"
+ (mapconcat
+ (lambda (var)
+ (format "%S '%S" (car var) (cadr var)))
+ vars
+ "\n ")
+ body)
+ ;; else, the header argument variable's value is not a list.
+ (format "(let [%s]\n%s)"
+ (mapconcat
+ (lambda (var)
+ (format "%S %S" (car var) (cdr var)))
+ vars
+ "\n ")
+ body)
+ ))))))
(if (or (member "code" result-params)
(member "pp" result-params))
(format "(clojure.pprint/pprint (do %s))" body)
--
2.35.1
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.3: 0001-ob-clojure.el-Fix-header-argument-var-binding-passed.patch --]
[-- Type: text/x-patch, Size: 2072 bytes --]
From 948e8c1ff2c9ba1d9c0fe26f9bdaa096bef80a9d Mon Sep 17 00:00:00 2001
From: stardiviner <numbchild@gmail.com>
Date: Sat, 9 Apr 2022 21:14:22 +0800
Subject: [PATCH] ob-clojure.el: Fix header argument :var binding passed table
or list data
* lisp/ob-clojure.el (org-babel-expand-body:clojure): Add if condition
to handle source block :var passed org-mode table or list data for
clojure let-binding to avoid java.lang.ClassCastException.
---
lisp/ob-clojure.el | 25 ++++++++++++++++++-------
1 file changed, 18 insertions(+), 7 deletions(-)
diff --git a/lisp/ob-clojure.el b/lisp/ob-clojure.el
index 5a44b6487..e6614b2d9 100644
--- a/lisp/ob-clojure.el
+++ b/lisp/ob-clojure.el
@@ -101,13 +101,24 @@
(and (cdr (assq :ns params)) (format "(ns %s)\n" ns))
;; 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)))
+ (format "(let [%s]\n%s)"
+ (mapconcat
+ (lambda (var)
+ (format "%S '%S" (car var) (cadr var)))
+ vars
+ "\n ")
+ body)
+ ;; else, the header argument variable's value is not a list.
+ (format "(let [%s]\n%s)"
+ (mapconcat
+ (lambda (var)
+ (format "%S %S" (car var) (cdr var)))
+ vars
+ "\n ")
+ body)
+ ))))))
(if (or (member "code" result-params)
(member "pp" result-params))
(format "(clojure.pprint/pprint (do %s))" body)
--
2.35.1
[-- Attachment #1.4: Type: text/plain, Size: 255 bytes --]
--
[ 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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]
^ permalink raw reply related [flat|nested] 13+ messages in thread
[parent not found: <62520bbc.1c69fb81.d855b.549fSMTPIN_ADDED_BROKEN@mx.google.com>]
* Re: [PATCH] Fix ob-clojure handling source block variable's value is a org-mode table or list
[not found] <62520bbc.1c69fb81.d855b.549fSMTPIN_ADDED_BROKEN@mx.google.com>
@ 2022-10-26 7:09 ` Ihor Radchenko
2022-10-27 14:09 ` Daniel Kraus
0 siblings, 1 reply; 13+ messages in thread
From: Ihor Radchenko @ 2022-10-26 7:09 UTC (permalink / raw)
To: numbchild, Bastien; +Cc: Org Mode
"Christopher M. Miles" <numbchild@gmail.com> writes:
> I bellowing example:
>
> #+begin_src org
> ,#+NAME: ob-clojure-table-test
> | a | b | c |
> |---+---+---|
> | 1 | 2 | 3 |
>
> ,#+NAME: ob-clojure-table-test-2
> | a | b | c |
> |---+---+---|
> | 1 | 2 | 3 |
>
> ,#+begin_src clojure :var kk=ob-clojure-table-test :var kk2=ob-clojure-table-test-2 :results output
> (println kk2)
> (println kk)
> ,#+end_src
>
> #+end_src
>
> 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.
> ;; 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?
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] Fix ob-clojure handling source block variable's value is a org-mode table or list
2022-10-26 7:09 ` Ihor Radchenko
@ 2022-10-27 14:09 ` Daniel Kraus
2022-10-28 3:56 ` Ihor Radchenko
2022-10-28 8:51 ` Bastien Guerry
0 siblings, 2 replies; 13+ messages in thread
From: Daniel Kraus @ 2022-10-27 14:09 UTC (permalink / raw)
To: Ihor Radchenko; +Cc: numbchild, Bastien, emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 1634 bytes --]
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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-lisp-ob-clojure.el-Fix-header-argument-var-binding.patch --]
[-- Type: text/x-patch, Size: 999 bytes --]
From 1a2fa382e7a5925d4b85d90f1fe4ac7c012f81a4 Mon Sep 17 00:00:00 2001
From: Daniel Kraus <daniel@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
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH] Fix ob-clojure handling source block variable's value is a org-mode table or list
2022-10-27 14:09 ` Daniel Kraus
@ 2022-10-28 3:56 ` Ihor Radchenko
2022-10-28 8:51 ` Bastien Guerry
1 sibling, 0 replies; 13+ messages in thread
From: Ihor Radchenko @ 2022-10-28 3:56 UTC (permalink / raw)
To: Daniel Kraus; +Cc: numbchild, Bastien, emacs-orgmode
Daniel Kraus <daniel@kraus.my> writes:
> 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.
Thanks!
> 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..)"
*is is
Otherwise, feel free to push.
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] Fix ob-clojure handling source block variable's value is a org-mode table or list
2022-10-27 14:09 ` Daniel Kraus
2022-10-28 3:56 ` Ihor Radchenko
@ 2022-10-28 8:51 ` Bastien Guerry
2022-10-28 9:09 ` Daniel Kraus
1 sibling, 1 reply; 13+ messages in thread
From: Bastien Guerry @ 2022-10-28 8:51 UTC (permalink / raw)
To: Daniel Kraus; +Cc: Ihor Radchenko, numbchild, emacs-orgmode
Hi Daniel,
Daniel Kraus <daniel@kraus.my> writes:
> 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.
For now `org-babel-clojure-backend' is nil.
I suggest to set it to babashka by default: babashka is stable and
well established now, it is by far the most efficient way to run
Clojure code. Also, it is particularily suitable for Babel use.
What do you think?
--
Bastien
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] Fix ob-clojure handling source block variable's value is a org-mode table or list
2022-10-28 8:51 ` Bastien Guerry
@ 2022-10-28 9:09 ` Daniel Kraus
2022-10-28 10:22 ` Bastien
0 siblings, 1 reply; 13+ messages in thread
From: Daniel Kraus @ 2022-10-28 9:09 UTC (permalink / raw)
To: Bastien Guerry; +Cc: Ihor Radchenko, numbchild, emacs-orgmode
Hi!
Bastien Guerry <bzg@gnu.org> writes:
> For now `org-babel-clojure-backend' is nil.
>
> I suggest to set it to babashka by default: babashka is stable and
> well established now, it is by far the most efficient way to run
> Clojure code. Also, it is particularily suitable for Babel use.
>
> What do you think?
Sounds good.
I would set it to (and (executable-find "bb") 'babashka) so it's still nil
when babashka is installed?
Or we could even test more available backends like
(cond
((executable-find "bb") 'babashka)
((executable-find "nbb") 'nbb)
((featurep 'cider) 'cider)
((featurep 'inf-clojure) 'inf-clojure)
((featurep 'slime) 'slime))
Or is that too much "magic" in that on some systems the default is bb
and in others it's cider etc?
Cheers,
Daniel
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] Fix ob-clojure handling source block variable's value is a org-mode table or list
2022-10-28 9:09 ` Daniel Kraus
@ 2022-10-28 10:22 ` Bastien
2022-10-28 21:09 ` Daniel Kraus
0 siblings, 1 reply; 13+ messages in thread
From: Bastien @ 2022-10-28 10:22 UTC (permalink / raw)
To: Daniel Kraus; +Cc: Ihor Radchenko, numbchild, emacs-orgmode
Hi Daniel,
Daniel Kraus <daniel@kraus.my> writes:
> I would set it to (and (executable-find "bb") 'babashka) so it's still nil
> when babashka is installed?
(You mean "not installed", right?)
> Or we could even test more available backends like
>
> (cond
> ((executable-find "bb") 'babashka)
> ((executable-find "nbb") 'nbb)
> ((featurep 'cider) 'cider)
> ((featurep 'inf-clojure) 'inf-clojure)
> ((featurep 'slime) 'slime))
>
> Or is that too much "magic" in that on some systems the default is bb
> and in others it's cider etc?
I think this is acceptable magic: perhaps we should first check what
is done in other Babel languages and align with their level of magic
for guessing the correct executable -- but I suspect Clojure is a bit
special here, in that it has a lot of different options.
Thanks for taking care of this,
--
Bastien
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] Fix ob-clojure handling source block variable's value is a org-mode table or list
2022-10-28 10:22 ` Bastien
@ 2022-10-28 21:09 ` Daniel Kraus
2022-10-29 8:08 ` Bastien
0 siblings, 1 reply; 13+ messages in thread
From: Daniel Kraus @ 2022-10-28 21:09 UTC (permalink / raw)
To: Bastien; +Cc: Ihor Radchenko, numbchild, emacs-orgmode
Bastien <bzg@gnu.org> writes:
> Daniel Kraus <daniel@kraus.my> writes:
>> I would set it to (and (executable-find "bb") 'babashka) so it's still nil
>> when babashka is installed?
> (You mean "not installed", right?)
Of course.
>> Or we could even test more available backends like
>>
>> (cond
>> ((executable-find "bb") 'babashka)
>> ((executable-find "nbb") 'nbb)
>> ((featurep 'cider) 'cider)
>> ((featurep 'inf-clojure) 'inf-clojure)
>> ((featurep 'slime) 'slime))
>>
>> Or is that too much "magic" in that on some systems the default is bb
>> and in others it's cider etc?
>
> I think this is acceptable magic: perhaps we should first check what
> is done in other Babel languages and align with their level of magic
> for guessing the correct executable -- but I suspect Clojure is a bit
> special here, in that it has a lot of different options.
I looked around a bit but couldn't find another babel package with a
similar problems, i.e. that some backends are completely different
and not just changing the name of the executable.
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.
Cheers,
Daniel
^ permalink raw reply [flat|nested] 13+ messages in thread
[parent not found: <m2lewez8zh.fsf@numbchild>]
* Re: [PATCH] Fix ob-clojure handling source block variable's value is a org-mode table or list
[not found] <m2lewez8zh.fsf@numbchild>
@ 2022-09-19 4:23 ` Christopher M. Miles
2022-10-29 4:19 ` Christopher M. Miles
1 sibling, 0 replies; 13+ messages in thread
From: Christopher M. Miles @ 2022-09-19 4:23 UTC (permalink / raw)
To: Org Mode; +Cc: Bastien Guerry
[-- Attachment #1: Type: text/plain, Size: 3212 bytes --]
Ping Bastien Guerry.
"Christopher M. Miles" <numbchild@gmail.com> writes:
> [[PGP Signed Part:Undecided]]
>
> I bellowing example:
>
> #+begin_src org
> ,#+NAME: ob-clojure-table-test
> | a | b | c |
> |---+---+---|
> | 1 | 2 | 3 |
>
> ,#+NAME: ob-clojure-table-test-2
> | a | b | c |
> |---+---+---|
> | 1 | 2 | 3 |
>
> ,#+begin_src clojure :var kk=ob-clojure-table-test :var kk2=ob-clojure-table-test-2 :results output
> (println kk2)
> (println kk)
> ,#+end_src
>
> #+end_src
>
> Without this patch, it will report error "class java.lang.ClassCastException" from CIDER.
>
> This patch added if condition to handle this table, list type data.
>
> From 948e8c1ff2c9ba1d9c0fe26f9bdaa096bef80a9d Mon Sep 17 00:00:00 2001
> From: stardiviner <numbchild@gmail.com>
> Date: Sat, 9 Apr 2022 21:14:22 +0800
> Subject: [PATCH] ob-clojure.el: Fix header argument :var binding passed table
> or list data
>
> * lisp/ob-clojure.el (org-babel-expand-body:clojure): Add if condition
> to handle source block :var passed org-mode table or list data for
> clojure let-binding to avoid java.lang.ClassCastException.
> ---
> lisp/ob-clojure.el | 25 ++++++++++++++++++-------
> 1 file changed, 18 insertions(+), 7 deletions(-)
>
> diff --git a/lisp/ob-clojure.el b/lisp/ob-clojure.el
> index 5a44b6487..e6614b2d9 100644
> --- a/lisp/ob-clojure.el
> +++ b/lisp/ob-clojure.el
> @@ -101,13 +101,24 @@
> (and (cdr (assq :ns params)) (format "(ns %s)\n" ns))
> ;; 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)))
> + (format "(let [%s]\n%s)"
> + (mapconcat
> + (lambda (var)
> + (format "%S '%S" (car var) (cadr var)))
> + vars
> + "\n ")
> + body)
> + ;; else, the header argument variable's value is not a list.
> + (format "(let [%s]\n%s)"
> + (mapconcat
> + (lambda (var)
> + (format "%S %S" (car var) (cdr var)))
> + vars
> + "\n ")
> + body)
> + ))))))
> (if (or (member "code" result-params)
> (member "pp" result-params))
> (format "(clojure.pprint/pprint (do %s))" body)
> --
> 2.35.1
>
> [5. text/x-patch; 0001-ob-clojure.el-Fix-header-argument-var-binding-passed.patch]...
--
[ 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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] Fix ob-clojure handling source block variable's value is a org-mode table or list
[not found] <m2lewez8zh.fsf@numbchild>
2022-09-19 4:23 ` Christopher M. Miles
@ 2022-10-29 4:19 ` Christopher M. Miles
2022-10-29 5:56 ` Ihor Radchenko
1 sibling, 1 reply; 13+ messages in thread
From: Christopher M. Miles @ 2022-10-29 4:19 UTC (permalink / raw)
To: Org Mode
[-- Attachment #1: Type: text/plain, Size: 3229 bytes --]
Any review comments about this patch?
"Christopher M. Miles" <numbchild@gmail.com> writes:
> [[PGP Signed Part:Undecided]]
>
> I bellowing example:
>
> #+begin_src org
> ,#+NAME: ob-clojure-table-test
> | a | b | c |
> |---+---+---|
> | 1 | 2 | 3 |
>
> ,#+NAME: ob-clojure-table-test-2
> | a | b | c |
> |---+---+---|
> | 1 | 2 | 3 |
>
> ,#+begin_src clojure :var kk=ob-clojure-table-test :var kk2=ob-clojure-table-test-2 :results output
> (println kk2)
> (println kk)
> ,#+end_src
>
> #+end_src
>
> Without this patch, it will report error "class java.lang.ClassCastException" from CIDER.
>
> This patch added if condition to handle this table, list type data.
>
> From 948e8c1ff2c9ba1d9c0fe26f9bdaa096bef80a9d Mon Sep 17 00:00:00 2001
> From: stardiviner <numbchild@gmail.com>
> Date: Sat, 9 Apr 2022 21:14:22 +0800
> Subject: [PATCH] ob-clojure.el: Fix header argument :var binding passed table
> or list data
>
> * lisp/ob-clojure.el (org-babel-expand-body:clojure): Add if condition
> to handle source block :var passed org-mode table or list data for
> clojure let-binding to avoid java.lang.ClassCastException.
> ---
> lisp/ob-clojure.el | 25 ++++++++++++++++++-------
> 1 file changed, 18 insertions(+), 7 deletions(-)
>
> diff --git a/lisp/ob-clojure.el b/lisp/ob-clojure.el
> index 5a44b6487..e6614b2d9 100644
> --- a/lisp/ob-clojure.el
> +++ b/lisp/ob-clojure.el
> @@ -101,13 +101,24 @@
> (and (cdr (assq :ns params)) (format "(ns %s)\n" ns))
> ;; 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)))
> + (format "(let [%s]\n%s)"
> + (mapconcat
> + (lambda (var)
> + (format "%S '%S" (car var) (cadr var)))
> + vars
> + "\n ")
> + body)
> + ;; else, the header argument variable's value is not a list.
> + (format "(let [%s]\n%s)"
> + (mapconcat
> + (lambda (var)
> + (format "%S %S" (car var) (cdr var)))
> + vars
> + "\n ")
> + body)
> + ))))))
> (if (or (member "code" result-params)
> (member "pp" result-params))
> (format "(clojure.pprint/pprint (do %s))" body)
> --
> 2.35.1
>
> [5. text/x-patch; 0001-ob-clojure.el-Fix-header-argument-var-binding-passed.patch]...
--
[ 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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] Fix ob-clojure handling source block variable's value is a org-mode table or list
2022-10-29 4:19 ` Christopher M. Miles
@ 2022-10-29 5:56 ` Ihor Radchenko
2022-10-29 11:18 ` Daniel Kraus
0 siblings, 1 reply; 13+ messages in thread
From: Ihor Radchenko @ 2022-10-29 5:56 UTC (permalink / raw)
To: numbchild; +Cc: Org Mode
"Christopher M. Miles" <numbchild@gmail.com> writes:
> Any review comments about this patch?
I have sent the following comment shortly after your followup:
"Christopher M. Miles" <numbchild@gmail.com> writes:
> + ;; variable's value is a list from org-mode passed table or list.
> + (if (listp (cdr (car vars)))
> ...
> + (format "(let [%s]\n%s)"
> + (mapconcat
> + (lambda (var)
> + (format "%S '%S" (car var) (cdr var)))
> + vars
> + "\n ")
Do I miss something, or you only test the first variable assignment here?
What if there are multiple assignments (:var a=X,b=Y)?
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2022-10-29 11:22 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-09 13:19 [PATCH] Fix ob-clojure handling source block variable's value is a org-mode table or list Christopher M. Miles
[not found] <62520bbc.1c69fb81.d855b.549fSMTPIN_ADDED_BROKEN@mx.google.com>
2022-10-26 7:09 ` Ihor Radchenko
2022-10-27 14:09 ` Daniel Kraus
2022-10-28 3:56 ` Ihor Radchenko
2022-10-28 8:51 ` Bastien Guerry
2022-10-28 9:09 ` Daniel Kraus
2022-10-28 10:22 ` Bastien
2022-10-28 21:09 ` Daniel Kraus
2022-10-29 8:08 ` Bastien
[not found] <m2lewez8zh.fsf@numbchild>
2022-09-19 4:23 ` Christopher M. Miles
2022-10-29 4:19 ` Christopher M. Miles
2022-10-29 5:56 ` Ihor Radchenko
2022-10-29 11:18 ` Daniel Kraus
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).