I have attached the patch file, created against the latest main branch. On Thu, Oct 17, 2024 at 11:28 PM Ihor Radchenko <yanta...@posteo.net> wrote:
> Anoop GR <anoopem...@gmail.com> writes: > > >> > >> I guess that we may leave the comments intact if the code block does not > >> have :var. > >> > > > > I moved the comment stripping code in org-babel-expand-body:clojure to > > follow the above idea:- > > ... > > The code look reasonable. > Would you be interested to convert it into a patch? > See https://orgmode.org/worg/org-contribute.html > > -- > 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> >
From c5d656c10c78a1738d3daf50a0dc0a46ebf3fd3e Mon Sep 17 00:00:00 2001 From: Anoop G R <anoopem...@gmail.com> Date: Fri, 18 Oct 2024 15:30:54 +0530 Subject: [PATCH] ob-clojure.el: Fix comments getting deleted on tangling of clojure source blocks * lisp/ob-clojure.el (org-babel-expand-body:clojure): Leave the comments intact if the code block does not have :var. Reported-by: "Anoop G R" <anoopem...@gmail.com> Link: https://list.orgmode.org/874j5azk2p.fsf@localhost/T/#t TINYCHANGE --- lisp/ob-clojure.el | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lisp/ob-clojure.el b/lisp/ob-clojure.el index 98a66d1..fdb0a75 100644 --- a/lisp/ob-clojure.el +++ b/lisp/ob-clojure.el @@ -155,21 +155,21 @@ or set the `:backend' header argument")))) (result-params (cdr (assq :result-params params))) (print-level nil) (print-length nil) - ;; Remove comments, they break (let [...] ...) bindings - (body (replace-regexp-in-string "^[ ]*;+.*$" "" body)) (body (org-trim (concat ;; Source block specified namespace :ns. (and (cdr (assq :ns params)) (format "(ns %s)\n" ns)) ;; Variables binding. (if (null vars) (org-trim body) - (format "(let [%s]\n%s)" + ;; Remove comments, they break (let [...] ...) bindings + (let ((body (replace-regexp-in-string "^[ ]*;+.*$" "" body))) + (format "(let [%s]\n%s)" (mapconcat (lambda (var) (format "%S '%S" (car var) (cdr var))) vars "\n ") - body)))))) + body))))))) ;; If the result param is set to "output" we don't have to do ;; anything special and just let the backend handle everything (if (member "output" result-params) -- 2.34.1