Skip to content

Instantly share code, notes, and snippets.

@LaloHao
Created September 25, 2016 07:44
Show Gist options
  • Select an option

  • Save LaloHao/e0320e8bfd6dc7a1a5226ba69c5fd9b5 to your computer and use it in GitHub Desktop.

Select an option

Save LaloHao/e0320e8bfd6dc7a1a5226ba69c5fd9b5 to your computer and use it in GitHub Desktop.
Quick modification to ob-spice.el from Tiago Weber
(defun org-babel-execute:spice (body params)
"Execute BODY with specified PARAMS."
(let ((body (org-babel-expand-body:spice body params))
(vars (mapcar #'cdr (org-babel-get-header params :var)))
textfile
imagefile
raw
result)
(org-babel-eval "ngspice " body)
(mapc (lambda (pair)
(when (string= (car pair) "file")
(setq textfile (concat (cdr pair) ""))
(setq imagefile (concat (cdr pair) ".png"))))
vars)
(when (file-readable-p textfile)
(progn
(setq raw (with-temp-buffer (insert-file-contents textfile) (buffer-string)))
(setq raw (replace-regexp-in-string "\n" "" raw))
(setq result (split-string raw ","))))
(when (file-readable-p imagefile)
(add-to-list 'result (concat '"[[file:./" imagefile "]]") t))
result))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment