[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: |
Christopher M. Miles |
Subject: |
Re: [PATCH] Fix ob-clojure handling source block variable's value is a org-mode table or list |
Date: |
Sat, 29 Oct 2022 12:19:39 +0800 |
User-agent: |
mu4e 1.8.10; emacs 29.0.50 |
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
signature.asc
Description: PGP signature
- Re: [PATCH] Fix ob-clojure handling source block variable's value is a org-mode table or list, (continued)
- Re: [PATCH] Fix ob-clojure handling source block variable's value is a org-mode table or list, Daniel Kraus, 2022/10/28
- Re: [PATCH] Fix ob-clojure handling source block variable's value is a org-mode table or list, Bastien, 2022/10/29
- Auto detect ob-clojure backend (was: [PATCH] Fix ob-clojure handling source block variable's value is a org-mode table or list), Daniel Kraus, 2022/10/30
- Re: Auto detect ob-clojure backend (was: [PATCH] Fix ob-clojure handling source block variable's value is a org-mode table or list), Ihor Radchenko, 2022/10/30
- Re: Auto detect ob-clojure backend (was: [PATCH] Fix ob-clojure handling source block variable's value is a org-mode table or list), Daniel Kraus, 2022/10/30
- Re: Auto detect ob-clojure backend (was: [PATCH] Fix ob-clojure handling source block variable's value is a org-mode table or list), Ihor Radchenko, 2022/10/30
- Re: Auto detect ob-clojure backend, Bastien Guerry, 2022/10/30
- Re: Auto detect ob-clojure backend (was: [PATCH] Fix ob-clojure handling source block variable's value is a org-mode table or list), Tim Cross, 2022/10/30
- Re: Auto detect ob-clojure backend (was: [PATCH] Fix ob-clojure handling source block variable's value is a org-mode table or list), Daniel Kraus, 2022/10/30
- Re: Auto detect ob-clojure backend (was: [PATCH] Fix ob-clojure handling source block variable's value is a org-mode table or list), Christopher M. Miles, 2022/10/30
Re: [PATCH] Fix ob-clojure handling source block variable's value is a org-mode table or list,
Christopher M. Miles <=