[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: org-babel guile source block bug in handling multiple values

From: Zelphir Kaltstahl
Subject: Re: org-babel guile source block bug in handling multiple values
Date: Fri, 10 Mar 2023 10:45:21 +0000

On 3/9/23 14:11, Ihor Radchenko wrote:
Zelphir Kaltstahl <zelphirkaltstahl@posteo.de> writes:

OK, to wrap up (ha!), I want to ask:

(q1) What is a rationale, if any, behind the let-wrapping?
It makes sense in ob-emacs-lisp to not litter global Emacs state.
In other ob-* lisp backends, I am not sure.
I am CCing Daniel, the maintainer of ob-clojure (we have no active
maintainer for ob-scheme now). Maybe, Daniel has some useful insight.

(q2) Any chances of that changing to (define ...)?
This sounds reasonable.

(q3) How could I change my org-mode's code to not  let-wrap, and instead use 
(define ...)?
See `org-babel-expand-body:scheme'. You can re-define it for a quick
temporary fix.

Thanks for the hint!

Here is my fix for my init.el:

;; Redefine/override org-babel-expand-body:scheme to avoid
;; let-wrapping with :var header args in source blocks.

(defun xiaolong/org-babel-format-vars (vars)
  "Format :var header arguments given as VARS."
  (mapconcat (lambda (var)
               (format "(define %s %S)" (car var) (cdr var)))

(eval-after-load "org"
  '(defun org-babel-expand-body:scheme (body params)
     "Expand BODY according to PARAMS, return the expanded body."
     (let ((vars (org-babel--get-vars params))
           (prepends (cdr (assq :prologue params)))
           (postpends (cdr (assq :epilogue params))))
       (concat (and prepends (concat prepends "\n"))
               (if (null vars)
                 (concat (xiaolong/org-babel-format-vars vars) body))
               (and postpends (concat "\n" postpends))))))

That was simpler than I expected and the first time I overrode anything of org-mode =)


repositories: https://notabug.org/ZelphirKaltstahl

reply via email to

[Prev in Thread] Current Thread [Next in Thread]