emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Christopher M. Miles" <numbchild@gmail.com>
To: Ihor Radchenko <yantar92@gmail.com>
Cc: numbchild@gmail.com, Chris Clark <cfclrk@gmail.com>,
	emacs-orgmode@gnu.org
Subject: Re: [PATCH] (v2) Fix void variable error `cider-buffer-ns` when specifying :backend header argument
Date: Wed, 12 Oct 2022 17:29:08 +0800	[thread overview]
Message-ID: <m2o7uhjsoi.fsf@numbchild@gmail.com> (raw)
In-Reply-To: <87o7uhshkn.fsf@localhost>


[-- 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 --]

  reply	other threads:[~2022-10-12  9:32 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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           ` Christopher M. Miles [this message]
     [not found]           ` <6346892e.050a0220.a2480.498fSMTPIN_ADDED_BROKEN@mx.google.com>
2022-10-13  2:56             ` [PATCH] (v2) " Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2o7uhjsoi.fsf@numbchild@gmail.com \
    --to=numbchild@gmail.com \
    --cc=cfclrk@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=yantar92@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).