* Add 'backend' header arg to clojure code blocks @ 2022-10-08 10:24 Chris Clark 2022-10-08 12:43 ` Christopher M. Miles 2022-10-09 7:42 ` Ihor Radchenko 0 siblings, 2 replies; 9+ messages in thread From: Chris Clark @ 2022-10-08 10:24 UTC (permalink / raw) To: emacs-orgmode [-- Attachment #1.1: Type: text/plain, Size: 479 bytes --] This is my first attempt to contribute to org-mode; please let me know if I'm doing something wrong. Attached is a patch to incorporate some of the changes that were originally presented by Ag Ibragimov here: https://list.orgmode.org/m2y2oimdjf.fsf@gmail.com/. I've been using these changes locally for a long time, and I'm hoping others might benefit! For example: #+header: :backend babashka #+begin_src clojure (range 3) #+end_src #+RESULTS: : (0 1 2) [-- Attachment #1.2: Type: text/html, Size: 722 bytes --] [-- Attachment #2: 0001-ob-clojure.el-Add-a-backend-header-arg-to-clojure-co.patch --] [-- Type: application/octet-stream, Size: 3619 bytes --] From cc72dcac3075be76e3edcfee75c887272e48698c Mon Sep 17 00:00:00 2001 From: Chris Clark <cfclrk@gmail.com> Date: Sat, 8 Oct 2022 05:41:20 -0400 Subject: [PATCH] ob-clojure.el: Add a 'backend' header arg to clojure code blocks * ob-clojure.el (org-babel-header-args:clojure, org-babel-execute:clojure): Add a 'backend' header arg that can override the configured `org-babel-clojure-backend`. --- lisp/ob-clojure.el | 53 ++++++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 23 deletions(-) diff --git a/lisp/ob-clojure.el b/lisp/ob-clojure.el index dc72eb049..24a5ab34a 100644 --- a/lisp/ob-clojure.el +++ b/lisp/ob-clojure.el @@ -68,7 +68,10 @@ (add-to-list 'org-babel-tangle-lang-exts '("clojurescript" . "cljs")) (defvar org-babel-default-header-args:clojure '()) -(defvar org-babel-header-args:clojure '((ns . :any) (package . :any))) +(defvar org-babel-header-args:clojure + '((ns . :any) + (package . :any) + (backend . ((inf-clojure cider slime babashka nbb))))) (defvar org-babel-default-header-args:clojurescript '()) (defvar org-babel-header-args:clojurescript '((package . :any))) @@ -253,28 +256,32 @@ ""))) (defun org-babel-execute:clojure (body params) - "Execute a block of Clojure code with Babel." - (unless org-babel-clojure-backend - (user-error "You need to customize org-babel-clojure-backend")) - (let* ((expanded (org-babel-expand-body:clojure body params)) - (result-params (cdr (assq :result-params params))) - result) - (setq result - (cond - ((eq org-babel-clojure-backend 'inf-clojure) - (ob-clojure-eval-with-inf-clojure expanded params)) - ((eq org-babel-clojure-backend 'babashka) - (ob-clojure-eval-with-babashka ob-clojure-babashka-command expanded)) - ((eq org-babel-clojure-backend 'nbb) - (ob-clojure-eval-with-babashka ob-clojure-nbb-command expanded)) - ((eq org-babel-clojure-backend 'cider) - (ob-clojure-eval-with-cider expanded params)) - ((eq org-babel-clojure-backend 'slime) - (ob-clojure-eval-with-slime expanded params)))) - (org-babel-result-cond result-params - result - (condition-case nil (org-babel-script-escape result) - (error result))))) + "Execute the BODY block of Clojure code with PARAMS using Babel." + (let* ((backend-override (cdr (assq :backend params))) + (org-babel-clojure-backend + (cond + (backend-override (intern backend-override)) + (org-babel-clojure-backend org-babel-clojure-backend) + (t (user-error "You need to customize org-babel-clojure-backend"))))) + (let* ((expanded (org-babel-expand-body:clojure body params)) + (result-params (cdr (assq :result-params params))) + result) + (setq result + (cond + ((eq org-babel-clojure-backend 'inf-clojure) + (ob-clojure-eval-with-inf-clojure expanded params)) + ((eq org-babel-clojure-backend 'babashka) + (ob-clojure-eval-with-babashka ob-clojure-babashka-command expanded)) + ((eq org-babel-clojure-backend 'nbb) + (ob-clojure-eval-with-babashka ob-clojure-nbb-command expanded)) + ((eq org-babel-clojure-backend 'cider) + (ob-clojure-eval-with-cider expanded params)) + ((eq org-babel-clojure-backend 'slime) + (ob-clojure-eval-with-slime expanded params)))) + (org-babel-result-cond result-params + result + (condition-case nil (org-babel-script-escape result) + (error result)))))) (defun org-babel-execute:clojurescript (body params) "Evaluate BODY with PARAMS as ClojureScript code." -- 2.38.0 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: Add 'backend' header arg to clojure code blocks 2022-10-08 10:24 Add 'backend' header arg to clojure code blocks Chris Clark @ 2022-10-08 12:43 ` Christopher M. Miles 2022-10-09 7:42 ` Ihor Radchenko 1 sibling, 0 replies; 9+ messages in thread From: Christopher M. Miles @ 2022-10-08 12:43 UTC (permalink / raw) To: Chris Clark; +Cc: emacs-orgmode [-- Attachment #1: Type: text/plain, Size: 931 bytes --] +1 Chris Clark <cfclrk@gmail.com> writes: > This is my first attempt to contribute to org-mode; please let me know if I'm doing something wrong. > > Attached is a patch to incorporate some of the changes that were originally presented by Ag Ibragimov > here: https://list.orgmode.org/m2y2oimdjf.fsf@gmail.com/. I've been using these changes locally for a long > time, and I'm hoping others might benefit! > > For example: > > #+header: :backend babashka > #+begin_src clojure > (range 3) > #+end_src > > #+RESULTS: > : (0 1 2) > > [6. text/x-patch; 0001-ob-clojure.el-Add-a-backend-header-arg-to-clojure-co.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 [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 487 bytes --] ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Add 'backend' header arg to clojure code blocks 2022-10-08 10:24 Add 'backend' header arg to clojure code blocks Chris Clark 2022-10-08 12:43 ` Christopher M. Miles @ 2022-10-09 7:42 ` Ihor Radchenko 2022-10-09 15:34 ` Chris Clark 1 sibling, 1 reply; 9+ messages in thread From: Ihor Radchenko @ 2022-10-09 7:42 UTC (permalink / raw) To: Chris Clark; +Cc: emacs-orgmode Chris Clark <cfclrk@gmail.com> writes: > This is my first attempt to contribute to org-mode; please let me know if > I'm doing something wrong. Thanks a lot! Contributions are always welcome. Please also add a mention and/or example to the ob-clojure documentation https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-clojure.html (The source repository is https://git.sr.ht/~bzg/worg ) Also, you need to add an etc/ORG-NEWS entry about the new header argument. And I have few minor comments on the patch itself. > From cc72dcac3075be76e3edcfee75c887272e48698c Mon Sep 17 00:00:00 2001 > From: Chris Clark <cfclrk@gmail.com> > Date: Sat, 8 Oct 2022 05:41:20 -0400 > Subject: [PATCH] ob-clojure.el: Add a 'backend' header arg to clojure code blocks ^:backend > * ob-clojure.el (org-babel-header-args:clojure, > org-babel-execute:clojure): Add a 'backend' header arg that can ^:backend > override the configured `org-babel-clojure-backend`. ^' (by convention, we quote like `symbol' using `' pair). Also, unless you have FSF copyright assignment, we need you to add TINYCHANGE at the end of the commit message. See https://orgmode.org/worg/org-contribute.html#first-patch > + (t (user-error "You need to customize org-babel-clojure-backend"))))) While we are here, can as well quote `org-babel-clojure-backend'. Or may even add "or set `:backend' header argument". -- 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> ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Add 'backend' header arg to clojure code blocks 2022-10-09 7:42 ` Ihor Radchenko @ 2022-10-09 15:34 ` Chris Clark 2022-10-11 2:55 ` Ihor Radchenko 0 siblings, 1 reply; 9+ messages in thread From: Chris Clark @ 2022-10-09 15:34 UTC (permalink / raw) To: Ihor Radchenko; +Cc: emacs-orgmode [-- Attachment #1.1: Type: text/plain, Size: 2043 bytes --] Thank you for the great feedback! Here are some updated patches. Attached are two patches: one for org mode, and a corresponding one for worg. On Sun, Oct 9, 2022 at 3:42 AM Ihor Radchenko <yantar92@gmail.com> wrote: > Chris Clark <cfclrk@gmail.com> writes: > > > This is my first attempt to contribute to org-mode; please let me know if > > I'm doing something wrong. > > Thanks a lot! Contributions are always welcome. > > Please also add a mention and/or example to the ob-clojure documentation > https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-clojure.html > (The source repository is https://git.sr.ht/~bzg/worg ) > > Also, you need to add an etc/ORG-NEWS entry about the new header > argument. > > And I have few minor comments on the patch itself. > > > From cc72dcac3075be76e3edcfee75c887272e48698c Mon Sep 17 00:00:00 2001 > > From: Chris Clark <cfclrk@gmail.com> > > Date: Sat, 8 Oct 2022 05:41:20 -0400 > > Subject: [PATCH] ob-clojure.el: Add a 'backend' header arg to clojure > code blocks > ^:backend > > * ob-clojure.el (org-babel-header-args:clojure, > > org-babel-execute:clojure): Add a 'backend' header arg that can > ^:backend > > override the configured `org-babel-clojure-backend`. > ^' > (by convention, we quote like `symbol' using `' pair). > > > Also, unless you have FSF copyright assignment, we need you to add > TINYCHANGE at the end of the commit message. See > https://orgmode.org/worg/org-contribute.html#first-patch > > > + (t (user-error "You need to customize > org-babel-clojure-backend"))))) > > While we are here, can as well quote `org-babel-clojure-backend'. > > Or may even add "or set `:backend' header argument". > > -- > 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> > [-- Attachment #1.2: Type: text/html, Size: 3414 bytes --] [-- Attachment #2: 0001-ob-clojure.el-Add-a-backend-header-arg-to-clojure-co.patch --] [-- Type: application/octet-stream, Size: 4395 bytes --] From 669dc16a851fdab017e162c74c1cbf050ef429f4 Mon Sep 17 00:00:00 2001 From: Chris Clark <cfclrk@gmail.com> Date: Sat, 8 Oct 2022 05:41:20 -0400 Subject: [PATCH] ob-clojure.el: Add a :backend header arg to clojure code blocks * ob-clojure.el (org-babel-header-args:clojure, org-babel-execute:clojure): Add a :backend header arg that can override the configured `org-babel-clojure-backend'. TINYCHANGE --- etc/ORG-NEWS | 9 ++++++++ lisp/ob-clojure.el | 54 ++++++++++++++++++++++++++-------------------- 2 files changed, 40 insertions(+), 23 deletions(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 34ec09927..c18c03725 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -314,6 +314,15 @@ This provides a proper counterpart to ~org-babel-pre-tangle-hook~, as per-tangle-destination. ~org-babel-tangle-finished-hook~ is just run once after the post tangle hooks. +*** New =:backend= header argument for clojure code blocks + +The =:backend= header argument on clojure code blocks can override the +value of ~org-babel-clojure-backend~. For example: + +#+begin_src clojure :backend babashka +(range 2) +#+end_src + ** New options *** New custom settings =org-icalendar-scheduled-summary-prefix= and =org-icalendar-deadline-summary-prefix= diff --git a/lisp/ob-clojure.el b/lisp/ob-clojure.el index dc72eb049..d6f860e98 100644 --- a/lisp/ob-clojure.el +++ b/lisp/ob-clojure.el @@ -68,7 +68,10 @@ (add-to-list 'org-babel-tangle-lang-exts '("clojurescript" . "cljs")) (defvar org-babel-default-header-args:clojure '()) -(defvar org-babel-header-args:clojure '((ns . :any) (package . :any))) +(defvar org-babel-header-args:clojure + '((ns . :any) + (package . :any) + (backend . ((inf-clojure cider slime babashka nbb))))) (defvar org-babel-default-header-args:clojurescript '()) (defvar org-babel-header-args:clojurescript '((package . :any))) @@ -253,28 +256,33 @@ ""))) (defun org-babel-execute:clojure (body params) - "Execute a block of Clojure code with Babel." - (unless org-babel-clojure-backend - (user-error "You need to customize org-babel-clojure-backend")) - (let* ((expanded (org-babel-expand-body:clojure body params)) - (result-params (cdr (assq :result-params params))) - result) - (setq result - (cond - ((eq org-babel-clojure-backend 'inf-clojure) - (ob-clojure-eval-with-inf-clojure expanded params)) - ((eq org-babel-clojure-backend 'babashka) - (ob-clojure-eval-with-babashka ob-clojure-babashka-command expanded)) - ((eq org-babel-clojure-backend 'nbb) - (ob-clojure-eval-with-babashka ob-clojure-nbb-command expanded)) - ((eq org-babel-clojure-backend 'cider) - (ob-clojure-eval-with-cider expanded params)) - ((eq org-babel-clojure-backend 'slime) - (ob-clojure-eval-with-slime expanded params)))) - (org-babel-result-cond result-params - result - (condition-case nil (org-babel-script-escape result) - (error result))))) + "Execute the BODY block of Clojure code with PARAMS using Babel." + (let* ((backend-override (cdr (assq :backend params))) + (org-babel-clojure-backend + (cond + (backend-override (intern backend-override)) + (org-babel-clojure-backend org-babel-clojure-backend) + (t (user-error "You need to customize `org-babel-clojure-backend' +or set the `:backend' header argument"))))) + (let* ((expanded (org-babel-expand-body:clojure body params)) + (result-params (cdr (assq :result-params params))) + result) + (setq result + (cond + ((eq org-babel-clojure-backend 'inf-clojure) + (ob-clojure-eval-with-inf-clojure expanded params)) + ((eq org-babel-clojure-backend 'babashka) + (ob-clojure-eval-with-babashka ob-clojure-babashka-command expanded)) + ((eq org-babel-clojure-backend 'nbb) + (ob-clojure-eval-with-babashka ob-clojure-nbb-command expanded)) + ((eq org-babel-clojure-backend 'cider) + (ob-clojure-eval-with-cider expanded params)) + ((eq org-babel-clojure-backend 'slime) + (ob-clojure-eval-with-slime expanded params)))) + (org-babel-result-cond result-params + result + (condition-case nil (org-babel-script-escape result) + (error result)))))) (defun org-babel-execute:clojurescript (body params) "Evaluate BODY with PARAMS as ClojureScript code." -- 2.38.0 [-- Attachment #3: 0001-ob-doc-clojure.org-Add-example-of-backend-header-arg.patch --] [-- Type: application/octet-stream, Size: 1116 bytes --] From 439a0567e6a195f8a492b9bd1128bdf2fac96f31 Mon Sep 17 00:00:00 2001 From: Chris Clark <cfclrk@gmail.com> Date: Sun, 9 Oct 2022 10:49:07 -0400 Subject: [PATCH] ob-doc-clojure.org: Add example of :backend header arg --- org-contrib/babel/languages/ob-doc-clojure.org | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/org-contrib/babel/languages/ob-doc-clojure.org b/org-contrib/babel/languages/ob-doc-clojure.org index a577d9b2..818cfef7 100644 --- a/org-contrib/babel/languages/ob-doc-clojure.org +++ b/org-contrib/babel/languages/ob-doc-clojure.org @@ -305,6 +305,21 @@ this dir variable in Clojure to construct a correct path. ,#+end_src #+end_src +* Evaluating with babashka + +You can also evaluate a Clojure code block using [[https://github.com/babashka/babashka][babashka]] (assuming +you have it installed). To do so, either customize +~org-babel-clojure-backend~ or use the ~:backend~ header argument. For +example: + +#+begin_example +,#+begin_src clojure :backend babashka + (range 3) +,#+end_src + +,#+RESULTS: +: (0 1 2) +#+end_example * Additional Examples -- 2.38.0 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: Add 'backend' header arg to clojure code blocks 2022-10-09 15:34 ` Chris Clark @ 2022-10-11 2:55 ` Ihor Radchenko 2022-10-12 0:40 ` [PATCH] Fix void variable error `cider-buffer-ns` when specifying :backend header argument Christopher M. Miles [not found] ` <63460e17.050a0220.1ff7f.4bdeSMTPIN_ADDED_BROKEN@mx.google.com> 0 siblings, 2 replies; 9+ messages in thread From: Ihor Radchenko @ 2022-10-11 2:55 UTC (permalink / raw) To: Chris Clark; +Cc: emacs-orgmode Chris Clark <cfclrk@gmail.com> writes: > Thank you for the great feedback! Here are some updated patches. > > Attached are two patches: one for org mode, and a corresponding one for > worg. Thanks! Applied onto main in Org and onto master in Worg. https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=4d07df718b36bf8af51241c0ab4c1d338fd936c1 https://git.sr.ht/~bzg/worg/commit/b6310ac155b62cb9051b0c647f58d355a61d042a I have added a changelog message to the Worg commit. I also added you to the contributor list in https://orgmode.org/worg/contributors.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> ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH] Fix void variable error `cider-buffer-ns` when specifying :backend header argument 2022-10-11 2:55 ` Ihor Radchenko @ 2022-10-12 0:40 ` Christopher M. Miles [not found] ` <63460e17.050a0220.1ff7f.4bdeSMTPIN_ADDED_BROKEN@mx.google.com> 1 sibling, 0 replies; 9+ messages in thread From: Christopher M. Miles @ 2022-10-12 0:40 UTC (permalink / raw) To: Ihor Radchenko; +Cc: Chris Clark, emacs-orgmode [-- Attachment #1.1: Type: text/plain, Size: 280 bytes --] After updated to latest commit, I found error, Reproduce: When I specified the `:backend` header argument: #+begin_src clojure :backend babashka (+ 2 4) #+end_src I got error: #+begin_example void variable: cider-buffer-ns #+end_example Here is the patch fix upper issue. [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1.2: 0001-lisp-ob-clojure.el-Fix-backend-override-not-work-wit.patch --] [-- Type: text/x-patch, Size: 1283 bytes --] From 245fc50b2eae115144c83ad97c1f9490f525b062 Mon Sep 17 00:00:00 2001 From: stardiviner <numbchild@gmail.com> Date: Wed, 12 Oct 2022 08:32:50 +0800 Subject: [PATCH] lisp/ob-clojure.el: Fix :backend override not work with `org-babel-clojure-backend' * lisp/ob-clojure.el (org-babel-expand-body:clojure): When The source block specified header argument :backend, the global option `org-babel-clojure-backend' value is default 'cider, the `cider-buffer-ns` is not void error. --- lisp/ob-clojure.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lisp/ob-clojure.el b/lisp/ob-clojure.el index d6f860e98..a6a463b83 100644 --- a/lisp/ob-clojure.el +++ b/lisp/ob-clojure.el @@ -104,8 +104,10 @@ (defun org-babel-expand-body:clojure (body params) "Expand BODY according to PARAMS, return the expanded body." (let* ((vars (org-babel--get-vars params)) + (backend-override (cdr (assq :backend params))) (ns (or (cdr (assq :ns params)) - (if (eq org-babel-clojure-backend 'cider) + (if (and (not backend-override) + (eq org-babel-clojure-backend 'cider)) (or cider-buffer-ns (let ((repl-buf (cider-current-connection))) (and repl-buf (buffer-local-value -- 2.37.2 [-- Attachment #1.3: Type: text/plain, Size: 267 bytes --] -- [ 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 [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 487 bytes --] ^ permalink raw reply related [flat|nested] 9+ messages in thread
[parent not found: <63460e17.050a0220.1ff7f.4bdeSMTPIN_ADDED_BROKEN@mx.google.com>]
* Re: [PATCH] Fix void variable error `cider-buffer-ns` when specifying :backend header argument [not found] ` <63460e17.050a0220.1ff7f.4bdeSMTPIN_ADDED_BROKEN@mx.google.com> @ 2022-10-12 6:04 ` Ihor Radchenko 2022-10-12 9:29 ` [PATCH] (v2) " Christopher M. Miles [not found] ` <6346892e.050a0220.a2480.498fSMTPIN_ADDED_BROKEN@mx.google.com> 0 siblings, 2 replies; 9+ messages in thread From: Ihor Radchenko @ 2022-10-12 6:04 UTC (permalink / raw) To: numbchild; +Cc: Chris Clark, emacs-orgmode "Christopher M. Miles" <numbchild@gmail.com> writes: > After updated to latest commit, I found error, > > Reproduce: > > When I specified the `:backend` header argument: > > #+begin_src clojure :backend babashka > (+ 2 4) > #+end_src > > I got error: > > #+begin_example > void variable: cider-buffer-ns > #+end_example Thanks for reporting! > Here is the patch fix upper issue. > > (let* ((vars (org-babel--get-vars params)) > + (backend-override (cdr (assq :backend params))) > (ns (or (cdr (assq :ns params)) > - (if (eq org-babel-clojure-backend 'cider) > + (if (and (not backend-override) > + (eq org-babel-clojure-backend 'cider)) > (or cider-buffer-ns > (let ((repl-buf (cider-current-connection))) > (and repl-buf (buffer-local-value What if backend-override is 'cider? I suggest to let-bind (org-babel-clojure-backend (cond (backend-override (intern backend-override)) (org-babel-clojure-backend org-babel-clojure-backend) (t (user-error "You need to customize `org-babel-clojure-backend' or set the `:backend' header argument")))) Just like in `org-babel-execute:clojure'. -- 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> ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] (v2) Fix void variable error `cider-buffer-ns` when specifying :backend header argument 2022-10-12 6:04 ` Ihor Radchenko @ 2022-10-12 9:29 ` Christopher M. Miles [not found] ` <6346892e.050a0220.a2480.498fSMTPIN_ADDED_BROKEN@mx.google.com> 1 sibling, 0 replies; 9+ messages in thread From: Christopher M. Miles @ 2022-10-12 9:29 UTC (permalink / raw) To: Ihor Radchenko; +Cc: numbchild, Chris Clark, emacs-orgmode [-- Attachment #1.1: Type: text/plain, Size: 1322 bytes --] Ihor Radchenko <yantar92@gmail.com> writes: > "Christopher M. Miles" <numbchild@gmail.com> writes: > >> After updated to latest commit, I found error, >> >> Reproduce: >> >> When I specified the `:backend` header argument: >> >> #+begin_src clojure :backend babashka >> (+ 2 4) >> #+end_src >> >> I got error: >> >> #+begin_example >> void variable: cider-buffer-ns >> #+end_example > > Thanks for reporting! > >> Here is the patch fix upper issue. >> >> (let* ((vars (org-babel--get-vars params)) >> + (backend-override (cdr (assq :backend params))) >> (ns (or (cdr (assq :ns params)) >> - (if (eq org-babel-clojure-backend 'cider) >> + (if (and (not backend-override) >> + (eq org-babel-clojure-backend 'cider)) >> (or cider-buffer-ns >> (let ((repl-buf (cider-current-connection))) >> (and repl-buf (buffer-local-value > > What if backend-override is 'cider? > I suggest to let-bind > (org-babel-clojure-backend > (cond > (backend-override (intern backend-override)) > (org-babel-clojure-backend org-babel-clojure-backend) > (t (user-error "You need to customize `org-babel-clojure-backend' > or set the `:backend' header argument")))) > > Just like in `org-babel-execute:clojure'. You're right, updated now. [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1.2: 0001-lisp-ob-clojure.el-Fix-backend-override-not-work-wit.patch --] [-- Type: text/x-patch, Size: 1379 bytes --] From 1ecdcc596c8447fcf96ff400f544c0adc680c8fc Mon Sep 17 00:00:00 2001 From: stardiviner <numbchild@gmail.com> Date: Wed, 12 Oct 2022 17:27:58 +0800 Subject: [PATCH] lisp/ob-clojure.el: Fix :backend override not work with `org-babel-clojure-backend' * lisp/ob-clojure.el (org-babel-expand-body:clojure): When The source block specified header argument :backend, the global option `org-babel-clojure-backend' value is default 'cider, the `cider-buffer-ns` is not void error. --- lisp/ob-clojure.el | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lisp/ob-clojure.el b/lisp/ob-clojure.el index d6f860e98..0649469b3 100644 --- a/lisp/ob-clojure.el +++ b/lisp/ob-clojure.el @@ -104,6 +104,13 @@ (defun org-babel-expand-body:clojure (body params) "Expand BODY according to PARAMS, return the expanded body." (let* ((vars (org-babel--get-vars params)) + (backend-override (cdr (assq :backend params))) + (org-babel-clojure-backend + (cond + (backend-override (intern backend-override)) + (org-babel-clojure-backend org-babel-clojure-backend) + (t (user-error "You need to customize `org-babel-clojure-backend' +or set the `:backend' header argument")))) (ns (or (cdr (assq :ns params)) (if (eq org-babel-clojure-backend 'cider) (or cider-buffer-ns -- 2.37.2 [-- Attachment #1.3: Type: text/plain, Size: 267 bytes --] -- [ 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 [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 487 bytes --] ^ permalink raw reply related [flat|nested] 9+ messages in thread
[parent not found: <6346892e.050a0220.a2480.498fSMTPIN_ADDED_BROKEN@mx.google.com>]
* Re: [PATCH] (v2) Fix void variable error `cider-buffer-ns` when specifying :backend header argument [not found] ` <6346892e.050a0220.a2480.498fSMTPIN_ADDED_BROKEN@mx.google.com> @ 2022-10-13 2:56 ` Ihor Radchenko 0 siblings, 0 replies; 9+ messages in thread From: Ihor Radchenko @ 2022-10-13 2:56 UTC (permalink / raw) To: Christopher M. Miles; +Cc: Chris Clark, emacs-orgmode "Christopher M. Miles" <numbchild@gmail.com> writes: > From 1ecdcc596c8447fcf96ff400f544c0adc680c8fc Mon Sep 17 00:00:00 2001 > From: stardiviner <numbchild@gmail.com> > Date: Wed, 12 Oct 2022 17:27:58 +0800 > Subject: [PATCH] lisp/ob-clojure.el: Fix :backend override not work with > `org-babel-clojure-backend' Thanks! Applied onto main. https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=601ce688d5a51db7f1a5262063512f13b581bdc4 -- 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> ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2022-10-13 2:56 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2022-10-08 10:24 Add 'backend' header arg to clojure code blocks Chris Clark 2022-10-08 12:43 ` Christopher M. Miles 2022-10-09 7:42 ` Ihor Radchenko 2022-10-09 15:34 ` Chris Clark 2022-10-11 2:55 ` Ihor Radchenko 2022-10-12 0:40 ` [PATCH] Fix void variable error `cider-buffer-ns` when specifying :backend header argument Christopher M. Miles [not found] ` <63460e17.050a0220.1ff7f.4bdeSMTPIN_ADDED_BROKEN@mx.google.com> 2022-10-12 6:04 ` Ihor Radchenko 2022-10-12 9:29 ` [PATCH] (v2) " Christopher M. Miles [not found] ` <6346892e.050a0220.a2480.498fSMTPIN_ADDED_BROKEN@mx.google.com> 2022-10-13 2:56 ` Ihor Radchenko
Code repositories for project(s) associated with this external index https://git.savannah.gnu.org/cgit/emacs.git https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.