summaryrefslogtreecommitdiff
path: root/lisp/org/ob-gnuplot.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/org/ob-gnuplot.el')
-rw-r--r--lisp/org/ob-gnuplot.el26
1 files changed, 22 insertions, 4 deletions
diff --git a/lisp/org/ob-gnuplot.el b/lisp/org/ob-gnuplot.el
index 6489c23f570..8c4a5957b99 100644
--- a/lisp/org/ob-gnuplot.el
+++ b/lisp/org/ob-gnuplot.el
@@ -3,6 +3,7 @@
;; Copyright (C) 2009-2021 Free Software Foundation, Inc.
;; Author: Eric Schulte
+;; Maintainer: Ihor Radchenko <yantar92@gmail.com>
;; Keywords: literate programming, reproducible research
;; Homepage: https://orgmode.org
@@ -33,7 +34,7 @@
;;; Requirements:
-;; - gnuplot :: http://www.gnuplot.info/
+;; - gnuplot :: https://www.gnuplot.info/
;;
;; - gnuplot-mode :: you can search the web for the latest active one.
@@ -47,6 +48,8 @@
(declare-function gnuplot-send-string-to-gnuplot "ext:gnuplot-mode" (str txt))
(declare-function gnuplot-send-buffer-to-gnuplot "ext:gnuplot-mode" ())
+(defvar org-babel-temporary-directory)
+
(defvar org-babel-default-header-args:gnuplot
'((:results . "file") (:exports . "results") (:session . nil))
"Default arguments to use when evaluating a gnuplot source block.")
@@ -85,14 +88,29 @@ code."
(cons
(car pair) ;; variable name
(let* ((val (cdr pair)) ;; variable value
- (lp (listp val)))
+ (lp (proper-list-p val)))
(if lp
(org-babel-gnuplot-table-to-data
(let* ((first (car val))
(tablep (or (listp first) (symbolp first))))
(if tablep val (mapcar 'list val)))
(org-babel-temp-file "gnuplot-") params)
- val))))
+ (if (and (stringp val)
+ (file-remote-p val) ;; check if val is a remote file
+ (file-exists-p val)) ;; call to file-exists-p is slow, maybe remove it
+ (let* ((local-name (concat ;; create a unique filename to avoid multiple downloads
+ org-babel-temporary-directory
+ "/gnuplot/"
+ (file-remote-p val 'host)
+ (org-babel-local-file-name val))))
+ (if (and (file-exists-p local-name) ;; only download file if remote is newer
+ (file-newer-than-file-p local-name val))
+ local-name
+ (make-directory (file-name-directory local-name) t)
+ (copy-file val local-name t)
+ ))
+ val
+ )))))
(org-babel--get-vars params))))
(defun org-babel-expand-body:gnuplot (body params)
@@ -272,7 +290,7 @@ Pass PARAMS through to `orgtbl-to-generic' when exporting TABLE."
(orgtbl-to-generic
table
(org-combine-plists
- '(:sep "\t" :fmt org-babel-gnuplot-quote-tsv-field)
+ '(:sep "\t" :fmt org-babel-gnuplot-quote-tsv-field :raw t :backend ascii)
params)))))
data-file)