diff options
author | fpi | 2018-04-13 22:21:49 +0200 |
---|---|---|
committer | fpi | 2018-04-13 22:21:49 +0200 |
commit | 3b31552784c4778afd531a8b5dae0d7272abec7a (patch) | |
tree | 4e39c510fedffa377514f8fa0a474bcb1de7b79f | |
parent | Proper session naming for blocks without :session arg (diff) |
Added cd into proper working dir & support for :dir flag
-rw-r--r-- | ob-spice.org | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/ob-spice.org b/ob-spice.org index 6ebfaf9..fecfba4 100644 --- a/ob-spice.org +++ b/ob-spice.org @@ -39,10 +39,10 @@ - option to return content of generated gnuplot .plt for easy use with :post {generic gnuplot block} - Full .plt or just data points? -** [0/5] Flags +** [1/5] Flags *** NEXT [#C] :netlist Name of src block to include for netlist -*** NEXT [#B] :dir +*** DONE [#B] :dir working directory to start ngspice in *** NEXT [#B] :file? default filename to use for @@ -77,14 +77,20 @@ use batch mode #+BEGIN_SRC emacs-lisp (defvar org-babel-spice-command "ngspice" "Name of command to use for executing ngspice.") - (defun org-babel-spice-initiate-session (&optional session _params) + (defun org-babel-spice-initiate-session (&optional session dir _params) "Initiate a ngspice session. - Create comint buffer SESSION running ngspice." - ;; set default-directory to start process in other than current dir - (make-comint sessionname org-babel-spice-command))) - + Create comint buffer SESSION running ngspice starting in + default-directory or DIR if specified." (let* ((sessionname (if (or (not session) (string= session "none")) "spice" session)) + (session (make-comint sessionname org-babel-spice-command))) + (if (and dir (string-match "^/" dir)) + ;; absolute dir + (comint-simple-send session (format "cd %s" dir)) + ;; relative dir + (comint-simple-send session (format "cd %s%s" default-directory (or dir "")))) + session + )) (defun org-babel-prep-session:spice (session params) "Prepare SESSION according to header arguments in PARAMS." (let ((session (org-babel-spice-initiate-session session)) @@ -207,7 +213,8 @@ Access with ~$x[0]~ or ~$x[2-len]~. (result-params (cdr (assq :result-params params))) (result-type (cdr (assq :result-type params))) (session (org-babel-spice-initiate-session - (cdr (assq :session params)))) + (cdr (assq :session params)) + (cdr (assq :dir params)))) (vars (org-babel--get-vars params)) (no-source (cdr (assq :no-source params))) (break-index (if (string-match "^ *\.end *$" body) |