* [PATCH] Updated patch, fixed data structure for table
[not found] <m2lewez8zh.fsf@numbchild>
@ 2022-04-09 22:40 ` Christopher M. Miles
2022-09-19 4:23 ` [PATCH] Fix ob-clojure handling source block variable's value is a org-mode table or list Christopher M. Miles
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: Christopher M. Miles @ 2022-04-09 22:40 UTC (permalink / raw)
To: Org Mode
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.1: 0001-ob-clojure.el-Fix-header-argument-var-binding-passed.patch --]
[-- Type: text/x-patch, Size: 2071 bytes --]
From 87c17465241b44030945391c6d036b44799a7694 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..adcd99a7a 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) (cdr 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.2: Type: text/plain, Size: 257 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] 7+ 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-04-09 22:40 ` [PATCH] Updated patch, fixed data structure for table Christopher M. Miles
@ 2022-09-19 4:23 ` Christopher M. Miles
[not found] ` <62520bbb.1c69fb81.678b3.5ceaSMTPIN_ADDED_BROKEN@mx.google.com>
2022-10-29 4:19 ` [PATCH] Fix ob-clojure handling source block variable's value is a org-mode table or list Christopher M. Miles
3 siblings, 0 replies; 7+ 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] 7+ messages in thread
* Re: [PATCH] Updated patch, fixed data structure for table
[not found] ` <62520bbb.1c69fb81.678b3.5ceaSMTPIN_ADDED_BROKEN@mx.google.com>
@ 2022-09-20 13:32 ` Ihor Radchenko
0 siblings, 0 replies; 7+ messages in thread
From: Ihor Radchenko @ 2022-09-20 13:32 UTC (permalink / raw)
To: numbchild; +Cc: Org Mode
"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,
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] 7+ 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>
` (2 preceding siblings ...)
[not found] ` <62520bbb.1c69fb81.678b3.5ceaSMTPIN_ADDED_BROKEN@mx.google.com>
@ 2022-10-29 4:19 ` Christopher M. Miles
2022-10-29 5:56 ` Ihor Radchenko
3 siblings, 1 reply; 7+ 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] 7+ 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 ` [PATCH] Fix ob-clojure handling source block variable's value is a org-mode table or list Christopher M. Miles
@ 2022-10-29 5:56 ` Ihor Radchenko
2022-10-29 11:18 ` Daniel Kraus
0 siblings, 1 reply; 7+ 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] 7+ messages in thread
* Re: [PATCH] Fix ob-clojure handling source block variable's value is a org-mode table or list
2022-10-29 5:56 ` Ihor Radchenko
@ 2022-10-29 11:18 ` Daniel Kraus
2022-10-29 14:38 ` [CLOSED] " Christopher M. Miles
0 siblings, 1 reply; 7+ messages in thread
From: Daniel Kraus @ 2022-10-29 11:18 UTC (permalink / raw)
To: Ihor Radchenko; +Cc: numbchild, emacs-orgmode
Hi
Ihor Radchenko <yantar92@posteo.net> writes:
> "Christopher M. Miles" <numbchild@gmail.com> writes:
>> Any review comments about this patch?
> I have sent the following comment shortly after your followup:
I even made another post after that, suggesting that the if condition
is not even needed. Simply always quoting seems to work and is also the
way it's done in `ob-lisp.el`.
See https://list.orgmode.org/orgmode/874jvp9wsg.fsf@kraus.my/
This simple patch is also already installed. Can you test if that works for you?
And in case you missed it, I made another reply for you bug report
about inline comments.
Check https://list.orgmode.org/orgmode/878rl1a1e0.fsf@kraus.my/
Thanks,
Daniel
^ permalink raw reply [flat|nested] 7+ messages in thread
* [CLOSED] Re: [PATCH] Fix ob-clojure handling source block variable's value is a org-mode table or list
2022-10-29 11:18 ` Daniel Kraus
@ 2022-10-29 14:38 ` Christopher M. Miles
0 siblings, 0 replies; 7+ messages in thread
From: Christopher M. Miles @ 2022-10-29 14:38 UTC (permalink / raw)
To: Daniel Kraus; +Cc: Ihor Radchenko, numbchild, emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 1196 bytes --]
Daniel Kraus <daniel@kraus.my> writes:
> Hi
>
> Ihor Radchenko <yantar92@posteo.net> writes:
>> "Christopher M. Miles" <numbchild@gmail.com> writes:
>>> Any review comments about this patch?
>> I have sent the following comment shortly after your followup:
>
> I even made another post after that, suggesting that the if condition
> is not even needed. Simply always quoting seems to work and is also the
> way it's done in `ob-lisp.el`.
> See https://list.orgmode.org/orgmode/874jvp9wsg.fsf@kraus.my/
>
> This simple patch is also already installed. Can you test if that works for you?
>
> And in case you missed it, I made another reply for you bug report
> about inline comments.
> Check https://list.orgmode.org/orgmode/878rl1a1e0.fsf@kraus.my/
>
> Thanks,
> Daniel
Indeed, your solution is better. Sorry that I have not realized your
patch. Thanks for notify me again. Closed this thread now.
--
[ 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] 7+ messages in thread
end of thread, other threads:[~2022-10-29 14:40 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <m2lewez8zh.fsf@numbchild>
2022-04-09 22:40 ` [PATCH] Updated patch, fixed data structure for table Christopher M. Miles
2022-09-19 4:23 ` [PATCH] Fix ob-clojure handling source block variable's value is a org-mode table or list Christopher M. Miles
[not found] ` <62520bbb.1c69fb81.678b3.5ceaSMTPIN_ADDED_BROKEN@mx.google.com>
2022-09-20 13:32 ` [PATCH] Updated patch, fixed data structure for table Ihor Radchenko
2022-10-29 4:19 ` [PATCH] Fix ob-clojure handling source block variable's value is a org-mode table or list Christopher M. Miles
2022-10-29 5:56 ` Ihor Radchenko
2022-10-29 11:18 ` Daniel Kraus
2022-10-29 14:38 ` [CLOSED] " Christopher M. Miles
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).