Org-mode mailing list
 help / color / mirror / Atom feed
From: Ferdinand Pieper <>
Subject: [PATCH] ob-gnuplot: handle remote input files
Date: Tue, 29 Sep 2020 19:00:58 +0200
Message-ID: <> (raw)

[-- Attachment #1: Type: text/plain, Size: 597 bytes --]

When passing a remote file like "/ssh:myserver:/myfile.txt" to a gnuplot block as variable the gnuplot process can not access the remote data.

An example:

--8<---------------cut here---------------start------------->8---
#+begin_src gnuplot :var data="/ssh:myserver:/myfile.txt"
plot data u 1:2
--8<---------------cut here---------------end--------------->8---

Attached is a patch, which instead downloads remote files to a unique path and passes this new path to gnuplot.

Please let me know if there's something to improve regarding the commit message or patch formatting.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ob-gnuplot-Download-remote-input-files.patch --]
[-- Type: text/x-diff, Size: 1466 bytes --]

From 4f9f98ed8f48754eeff09b8de51734bc8521bb6a Mon Sep 17 00:00:00 2001
From: fpi <>
Date: Tue, 29 Sep 2020 18:43:07 +0200
Subject: [PATCH] ob-gnuplot: Download remote input files

* lisp/ob-gnuplot.el (org-babel-gnuplot-process-vars): When variables
point to remote files download them and use a local copy instead.
 lisp/ob-gnuplot.el | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/lisp/ob-gnuplot.el b/lisp/ob-gnuplot.el
index 62ab04d94..820929c84 100644
--- a/lisp/ob-gnuplot.el
+++ b/lisp/ob-gnuplot.el
@@ -92,7 +92,21 @@ code."
 		      (tablep (or (listp first) (symbolp first))))
 		 (if tablep val (mapcar 'list val)))
 	       (org-babel-temp-file "gnuplot-") params)
-	  val))))
+	    (if (and (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)
+				(file-local-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)

             reply	other threads:[~2020-09-29 17:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-29 17:00 Ferdinand Pieper [this message]
2020-10-24 12:15 ` Bastien
2020-10-25 16:53   ` Ferdinand Pieper
2020-10-27  9:55     ` Bastien

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Org-mode mailing list

This inbox may be cloned and mirrored by anyone:

	git clone --mirror list/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 list list/ \
	public-inbox-index list

Example config snippet for mirrors.
Newsgroups are available over NNTP:

AGPL code for this site: git clone