From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric S Fraga Subject: Re: allow gnuplot to generate plot in different directories Date: Thu, 07 Dec 2017 06:58:29 +0000 Message-ID: <87o9nbausq.fsf@gmail.com> References: <87shcn7t2r.fsf@gmail.com> <87tvx3o5v8.fsf@nicolasgoaziou.fr> 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]:37490) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eMq8h-0006b7-7f for emacs-orgmode@gnu.org; Thu, 07 Dec 2017 01:58:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eMq8e-0008Cp-6b for emacs-orgmode@gnu.org; Thu, 07 Dec 2017 01:58:35 -0500 Received: from mail-wr0-x232.google.com ([2a00:1450:400c:c0c::232]:38416) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eMq8d-0008Bv-U0 for emacs-orgmode@gnu.org; Thu, 07 Dec 2017 01:58:32 -0500 Received: by mail-wr0-x232.google.com with SMTP id o2so6306002wro.5 for ; Wed, 06 Dec 2017 22:58:31 -0800 (PST) In-Reply-To: <87tvx3o5v8.fsf@nicolasgoaziou.fr> (Nicolas Goaziou's message of "Wed, 06 Dec 2017 23:20:59 +0100") 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: Nicolas Goaziou Cc: emacs-orgmode@gnu.org --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Wednesday, 6 Dec 2017 at 23:20, Nicolas Goaziou wrote: > Hello, > > Eric S Fraga writes: > >> 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. > > Thank you. Shouldn't it go in maint? I have no idea what the protocol here is. But, in any case, attached is a new patch relative to maint. > >> + ;; setting the directory needs to be done first so that >> + ;; subsequent 'output' directive goes to the right place > > Nitpick: I hate upper case (an RSI thing... ;-)) but okay. also noting that the previous comment started with lower case. and should single sentence comments end with a full stop (.)? Thanks, eric =2D-=20 Eric S Fraga via Emacs 27.0.50, Org release_9.1.4-200-g15df8d --=-=-= 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=206857093df26af908d85dfb1e9512f1a838b2ffd7 Mon Sep 17 00:00:00 2001 From: Eric S Fraga Date: Thu, 7 Dec 2017 06:56:41 +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..241f1d3a4 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: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EARECAB0WIQSPXCedOQfhSlwpVw3IkZPY//z2fQUCWijmlQAKCRDIkZPY//z2 fZjeAKCITzSTQMJ/0odjFe7d+iAxZBLnOgCcD/ByKT/jGKuF4j1C2dheFvLSNKQ= =mXq0 -----END PGP SIGNATURE----- --==-=-=--