hurrja / ob-asymptote

Org Babel functions for Asymptote evaluation
GNU General Public License v3.0
3 stars 3 forks source link

output file name doubles extension #1

Open badkey opened 4 months ago

badkey commented 4 months ago

Using ob-asymptote a for a file img/dot.pnp

SRC asymptote :file img/dot.png 
dot((0,0));
#+END_SRC

a file img/dot.png.png was created instead. This might be due to some recent changes in asy. Adding file-name-sans-extension to the command line creation changed its file naming behaviour accordingly.

​ (defun org-babel-execute:asymptote (body params)
"Execute a block of Asymptote code.
This function is called by `org-babel-execute-src-block'."
(let* ((out-file (cdr (assq :file params)))
(format (or (file-name-extension out-file)
"pdf"))
(cmdline (cdr (assq :cmdline params)))
(in-file (org-babel-temp-file "asymptote-"))
(cmd
(concat "asy "
(if out-file
(concat
"-globalwrite -f " format
" -o " (org-babel-process-file-name (file-name-sans-extension out-file)))
"-V")
" " cmdline
" " (org-babel-process-file-name in-file))))
(with-temp-file in-file
(insert (org-babel-expand-body:generic
body params
(org-babel-variable-assignments:asymptote params))))
(message cmd) (shell-command cmd)
nil)) ;; signal that output has already been written to file 

org-version is 9.6.15 asy-version is 2.87

mat90hub commented 3 months ago

I did a pull request proposing a correction for this.