From: "Christopher M. Miles" <numbchild@gmail.com>
To: Org Mode <emacs-orgmode@gnu.org>
Subject: [PATCH] Updated patch, fixed data structure for table
Date: Sun, 10 Apr 2022 06:40:31 +0800 [thread overview]
Message-ID: <m2h771zxp5.fsf@numbchild@gmail.com> (raw)
In-Reply-To: <m2lewez8zh.fsf@numbchild>
[-- 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 --]
next parent reply other threads:[~2022-04-09 22:42 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <m2lewez8zh.fsf@numbchild>
2022-04-09 22:40 ` Christopher M. Miles [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m2h771zxp5.fsf@numbchild@gmail.com \
--to=numbchild@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).