From mboxrd@z Thu Jan 1 00:00:00 1970 From: stardiviner Subject: Re: [PATCH] ob-clojure.el support :ns header argument Date: Mon, 26 Mar 2018 12:38:54 +0800 Message-ID: <2e8bf589-83e4-4b95-0df5-874c92c18d28@gmail.com> References: <4d7d38a2-4a7b-c22a-3d5c-fc05a99aabb8@gmail.com> <7ab04864-666d-b84b-b9ea-6a26868f5cdd@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------56174C1BB15DF4F416568C62" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:47235) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f0Jua-0000Ph-Ql for emacs-orgmode@gnu.org; Mon, 26 Mar 2018 00:39:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f0JuW-0004va-GZ for emacs-orgmode@gnu.org; Mon, 26 Mar 2018 00:39:12 -0400 Received: from mail-pf0-x234.google.com ([2607:f8b0:400e:c00::234]:45843) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f0JuN-0004sx-SL for emacs-orgmode@gnu.org; Mon, 26 Mar 2018 00:39:08 -0400 Received: by mail-pf0-x234.google.com with SMTP id l27so7078499pfk.12 for ; Sun, 25 Mar 2018 21:38:59 -0700 (PDT) Received: from [0.0.0.0] ([119.28.89.243]) by smtp.gmail.com with ESMTPSA id s78sm28780188pfa.161.2018.03.25.21.38.56 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 25 Mar 2018 21:38:57 -0700 (PDT) In-Reply-To: <7ab04864-666d-b84b-b9ea-6a26868f5cdd@gmail.com> Content-Language: en-US List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: org-mode This is a multi-part message in MIME format. --------------56174C1BB15DF4F416568C62 Content-Type: multipart/alternative; boundary="------------D284186124AD74488EA51288" --------------D284186124AD74488EA51288 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit 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. >> > --------------D284186124AD74488EA51288 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 7bit 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 :var initialization 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.



--------------D284186124AD74488EA51288-- --------------56174C1BB15DF4F416568C62 Content-Type: text/x-patch; name="0001-ob-clojure.el-org-babel-execute-clojure-support-ns-h.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-ob-clojure.el-org-babel-execute-clojure-support-ns-h.pa"; filename*1="tch" >From 8315773aaee24d49996aa26c543cc56f9adc8414 Mon Sep 17 00:00:00 2001 From: Bastien 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 --------------56174C1BB15DF4F416568C62--