summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric S Fraga <e.fraga@ucl.ac.uk>2017-12-07 06:56:41 +0000
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2017-12-07 14:20:06 +0100
commit1187538a212112708993b44e6b814f1a70e9f6ce (patch)
tree18211274696683947f10b9a921faad9c338782c2
parentb570175d7628bb47b00948b3e23ff93c215d38ee (diff)
downloadorg-mode-1187538a212112708993b44e6b814f1a70e9f6ce.tar.gz
Allow gnuplot to generate plots in different directories
* lisp/ob-gnuplot.el (org-babel-expand-body:gnuplot) if the Org buffer is associated with a file, direct gnuplot to change to the directory for that file.
-rw-r--r--lisp/ob-gnuplot.el7
1 files changed, 6 insertions, 1 deletions
diff --git a/lisp/ob-gnuplot.el b/lisp/ob-gnuplot.el
index b0743f6..241f1d3 100644
--- a/lisp/ob-gnuplot.el
+++ b/lisp/ob-gnuplot.el
@@ -116,6 +116,8 @@ code."
(timefmt (cdr (assq :timefmt params)))
(time-ind (or (cdr (assq :timeind params))
(when timefmt 1)))
+ (directory (and (buffer-file-name)
+ (file-name-directory (buffer-file-name))))
(add-to-body (lambda (text) (setq body (concat text "\n" body)))))
;; append header argument settings to body
(when title (funcall add-to-body (format "set title '%s'" title)))
@@ -161,7 +163,10 @@ code."
(format "\\$%s" (car pair)) (cdr pair) body)))
vars)
(when prologue (funcall add-to-body prologue))
- (when epilogue (setq body (concat body "\n" epilogue))))
+ (when epilogue (setq body (concat body "\n" epilogue)))
+ ;; Setting the directory needs to be done first so that
+ ;; subsequent 'output' directive goes to the right place.
+ (when directory (funcall add-to-body (format "cd '%s'" directory))))
body))
(defun org-babel-execute:gnuplot (body params)