From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric S Fraga Subject: allow gnuplot to generate plot in different directories Date: Wed, 06 Dec 2017 15:51:40 +0000 Message-ID: <87shcn7t2r.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:55194) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eMbzB-0008Ki-By for emacs-orgmode@gnu.org; Wed, 06 Dec 2017 10:51:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eMbz6-0004nc-4Z for emacs-orgmode@gnu.org; Wed, 06 Dec 2017 10:51:49 -0500 Received: from mail-wm0-x22a.google.com ([2a00:1450:400c:c09::22a]:41055) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eMbz5-0004m8-RM for emacs-orgmode@gnu.org; Wed, 06 Dec 2017 10:51:44 -0500 Received: by mail-wm0-x22a.google.com with SMTP id g75so8129533wme.0 for ; Wed, 06 Dec 2017 07:51:43 -0800 (PST) Received: from t3610 ([2.31.141.225]) by smtp.gmail.com with ESMTPSA id f69sm3348233wmi.46.2017.12.06.07.51.41 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 06 Dec 2017 07:51:41 -0800 (PST) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain Nicolas, attached is a patch (relative to master from a few minutes ago) which allows gnuplot babel blocks to send the output to the right directory. I have tested this with both buffers associated with actual files and buffers not associated with any file. Your suggestion for getting the directory name worked just fine. Thanks, eric --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-allow-gnuplot-to-generate-plots-in-different-directo.patch Content-Transfer-Encoding: quoted-printable From=20da418f64fd01958c17402e8c5c3556eb82ba127e Mon Sep 17 00:00:00 2001 From: Eric S Fraga Date: Wed, 6 Dec 2017 15:48:12 +0000 Subject: [PATCH] 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. =2D-- lisp/ob-gnuplot.el | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lisp/ob-gnuplot.el b/lisp/ob-gnuplot.el index b0743f604..856efe13a 100644 =2D-- 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)) =2D (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)) =20 (defun org-babel-execute:gnuplot (body params) =2D-=20 2.15.0 --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable =2D-=20 Eric S Fraga via Emacs 27.0.50, Org release_9.1.3-170-g51234f --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iFwEARECAB0WIQSPXCedOQfhSlwpVw3IkZPY//z2fQUCWigSDAAKCRDIkZPY//z2 fXTiAJsETBI+CaYjFsbpUmOC9Ec/zZb4YgCY/156P9ko+h2S8qKSByccVAJWUQ== =JOzF -----END PGP SIGNATURE----- --==-=-=--