Created
September 25, 2016 07:44
-
-
Save LaloHao/e0320e8bfd6dc7a1a5226ba69c5fd9b5 to your computer and use it in GitHub Desktop.
Quick modification to ob-spice.el from Tiago Weber
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (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