* allow gnuplot to generate plot in different directories
@ 2017-12-06 15:51 Eric S Fraga
2017-12-06 22:20 ` Nicolas Goaziou
0 siblings, 1 reply; 4+ messages in thread
From: Eric S Fraga @ 2017-12-06 15:51 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1.1: Type: text/plain, Size: 340 bytes --]
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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-allow-gnuplot-to-generate-plots-in-different-directo.patch --]
[-- Type: text/x-diff, Size: 1658 bytes --]
From da418f64fd01958c17402e8c5c3556eb82ba127e Mon Sep 17 00:00:00 2001
From: Eric S Fraga <e.fraga@ucl.ac.uk>
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.
---
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
--- 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)
--
2.15.0
[-- Attachment #1.3: Type: text/plain, Size: 70 bytes --]
--
Eric S Fraga via Emacs 27.0.50, Org release_9.1.3-170-g51234f
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 194 bytes --]
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: allow gnuplot to generate plot in different directories
2017-12-06 15:51 allow gnuplot to generate plot in different directories Eric S Fraga
@ 2017-12-06 22:20 ` Nicolas Goaziou
2017-12-07 6:58 ` Eric S Fraga
0 siblings, 1 reply; 4+ messages in thread
From: Nicolas Goaziou @ 2017-12-06 22:20 UTC (permalink / raw)
To: emacs-orgmode
Hello,
Eric S Fraga <esflists@gmail.com> 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?
> + ;; setting the directory needs to be done first so that
> + ;; subsequent 'output' directive goes to the right place
Nitpick:
;; Setting the directory needs to be done first so that
;; subsequent "output" directive goes to the right place.
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: allow gnuplot to generate plot in different directories
2017-12-06 22:20 ` Nicolas Goaziou
@ 2017-12-07 6:58 ` Eric S Fraga
2017-12-07 13:28 ` Nicolas Goaziou
0 siblings, 1 reply; 4+ messages in thread
From: Eric S Fraga @ 2017-12-07 6:58 UTC (permalink / raw)
To: Nicolas Goaziou; +Cc: emacs-orgmode
[-- Attachment #1.1: Type: text/plain, Size: 962 bytes --]
On Wednesday, 6 Dec 2017 at 23:20, Nicolas Goaziou wrote:
> Hello,
>
> Eric S Fraga <esflists@gmail.com> 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
--
Eric S Fraga via Emacs 27.0.50, Org release_9.1.4-200-g15df8d
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-allow-gnuplot-to-generate-plots-in-different-directo.patch --]
[-- Type: text/x-diff, Size: 1659 bytes --]
From 6857093df26af908d85dfb1e9512f1a838b2ffd7 Mon Sep 17 00:00:00 2001
From: Eric S Fraga <e.fraga@ucl.ac.uk>
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.
---
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
--- 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)
--
2.15.0
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 194 bytes --]
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: allow gnuplot to generate plot in different directories
2017-12-07 6:58 ` Eric S Fraga
@ 2017-12-07 13:28 ` Nicolas Goaziou
0 siblings, 0 replies; 4+ messages in thread
From: Nicolas Goaziou @ 2017-12-07 13:28 UTC (permalink / raw)
To: emacs-orgmode
Hello,
Eric S Fraga <esflists@gmail.com> writes:
> I have no idea what the protocol here is. But, in any case, attached is
> a new patch relative to maint.
Applied. Thank you.
> 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 (.)?
As a rule of thumb, comments that start on a new line (e.g., with ";; "
prefix) are full sentences (capital and full stop). Inline comments
(prefixed with "; ") do not have such requirments.
Regards,
--
Nicolas Goaziou 0x80A93738
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-12-07 13:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-06 15:51 allow gnuplot to generate plot in different directories Eric S Fraga
2017-12-06 22:20 ` Nicolas Goaziou
2017-12-07 6:58 ` Eric S Fraga
2017-12-07 13:28 ` Nicolas Goaziou
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).