Ihor Radchenko <yanta...@gmail.com> writes:

> "Christopher M. Miles" <numbch...@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.

From 1ecdcc596c8447fcf96ff400f544c0adc680c8fc Mon Sep 17 00:00:00 2001
From: stardiviner <numbch...@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

-- 

[ 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: signature.asc
Description: PGP signature

Reply via email to