What I'm trying to achieve is very simple: take a source block, write it to a temp file, pass the file name as an argument to an executable which will run it, and then include the output in the #RESULTS
block. The snippet below seems close, but when I try to execute the code block the executable (nim
) complains that it expected a file name so I guess it passes the block body via stdin
instead of temp file:
(defun org-babel-execute:nim (body params)
"Execute a block of Nim code with org-babel."
(message "executing Nim source code block")
(org-babel-eval "nim r " body))
Second attempt, based on @NickD's comment and org-babel-execute:dot
:
(defun org-babel-execute:nim (body params)
"Execute a block of Nim code with org-babel."
(message "executing Nim source code block")
(let* (in-file (org-babel-temp-file "nim-")))
(with-temp-file in-file
(insert body))
(org-babel-eval (format "nim r %s" (org-babel-process-file-name in-file))))
When trying to execute a code block, getting "Symbol's value as variable is void: in-file"
org-babel-execute:dot
which does something very similar to what you are trying to do.let*
is wrong, it doesn't bindin-file
to anything and the following code should be in its body instead. This is absolutely not Org's fault.