Previous `ob-clojure.el` patch implement method is not good enough. Here is a better implementation.
Sorry for this over posting.

On 03/26/2018 09:59 AM, stardiviner wrote:

- support :ns header (as discussed at here https://github.com/clojure-emacs/clojure-mode/pull/465#discussion_r158009538)

- supoort inject CIDER outside of project

- support :varinitialization when :session initialization prepare.


On 03/22/2018 01:49 AM, stardiviner wrote:

Two patches

One is to support ob-clojure.el future coming header argument :ns.

The second is to support jack-in CIDER outside of Clojure project by default. Not no need to ob-clojure project to be created anymore.



>From 8315773aaee24d49996aa26c543cc56f9adc8414 Mon Sep 17 00:00:00 2001
From: Bastien <b...@gnu.org>
Date: Mon, 26 Mar 2018 11:35:21 +0800
Subject: [PATCH] * ob-clojure.el (org-babel-execute:clojure) support :ns
 header argument.

---
 lisp/ob-clojure.el | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/lisp/ob-clojure.el b/lisp/ob-clojure.el
index 890f60ada..5989a254b 100644
--- a/lisp/ob-clojure.el
+++ b/lisp/ob-clojure.el
@@ -83,16 +83,21 @@ If the value is nil, timeout is disabled."
 (defun org-babel-expand-body:clojure (body params)
   "Expand BODY according to PARAMS, return the expanded body."
   (let* ((vars (org-babel--get-vars params))
+	 (ns (cdr (assq :ns params)))
 	 (result-params (cdr (assq :result-params params)))
 	 (print-level nil) (print-length nil)
 	 (body (org-trim
 		(if (null vars) (org-trim body)
-		  (concat "(let ["
-			  (mapconcat
-			   (lambda (var)
-			     (format "%S (quote %S)" (car var) (cdr var)))
-			   vars "\n      ")
-			  "]\n" body ")")))))
+		  (concat
+		   ;; src block specified namespace :ns
+		   "(ns " ns ")"
+		   ;; variables binding
+		   "(let ["
+		   (mapconcat
+		    (lambda (var)
+		      (format "%S (quote %S)" (car var) (cdr var)))
+		    vars "\n      ")
+		   "]\n" body ")")))))
     (if (or (member "code" result-params)
 	    (member "pp" result-params))
 	(format "(clojure.pprint/pprint (do %s))" body)
-- 
2.16.2

Reply via email to