From 85dc35656df4678c06e2e5704caf60b7b46a557b Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Mon, 20 Jul 2009 13:33:53 -0600 Subject: [PATCH] DONE gnuplot sessions --- lisp/langs/org-babel-gnuplot.el | 18 ++++++++++++------ org-babel.org | 17 +++++++++++++++-- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/lisp/langs/org-babel-gnuplot.el b/lisp/langs/org-babel-gnuplot.el index 8f74f780c..267e9f52c 100644 --- a/lisp/langs/org-babel-gnuplot.el +++ b/lisp/langs/org-babel-gnuplot.el @@ -42,7 +42,8 @@ (add-to-list 'org-babel-tangle-langs '("gnuplot" "gnuplot")) -(defvar org-babel-default-header-args:gnuplot '((:results . "file") (:exports . "results")) +(defvar org-babel-default-header-args:gnuplot + '((:results . "file") (:exports . "results") (:session . nil)) "Default arguments to use when evaluating a gnuplot source block.") (defvar org-babel-gnuplot-timestamp-fmt nil) @@ -112,10 +113,16 @@ called by `org-babel-execute-src-block' via multiple-value-bind." (lambda (pair) (format "%s = \"%s\"" (car pair) (cdr pair))) vars "\n")) ;; evaluate the code body with gnuplot - (with-temp-buffer - (insert (concat body "\n")) - (gnuplot-mode) - (gnuplot-send-buffer-to-gnuplot)) + (if (string= session "none") + (let ((script-file (make-temp-file "org-babel-gnuplot-script"))) + (with-temp-file script-file + (insert (concat body "\n"))) + (message "gnuplot \"%s\"" script-file) + (message (shell-command-to-string (format "gnuplot \"%s\"" script-file)))) + (with-temp-buffer + (insert (concat body "\n")) + (gnuplot-mode) + (gnuplot-send-buffer-to-gnuplot))) out-file))) (defun org-babel-prep-session:gnuplot (session params) @@ -156,7 +163,6 @@ then create. Return the initialized session. The current "Export TABLE to DATA-FILE in a format readable by gnuplot. Pass PARAMS through to `orgtbl-to-generic' when exporting TABLE." (with-temp-file data-file - (message "table = %S" table) (make-local-variable 'org-babel-gnuplot-timestamp-fmt) (setq org-babel-gnuplot-timestamp-fmt (or (plist-get params :timefmt) diff --git a/org-babel.org b/org-babel.org index 9330663aa..dbc6daa3f 100644 --- a/org-babel.org +++ b/org-babel.org @@ -2266,7 +2266,7 @@ This could probably be added to [[file:lisp/org-babel-script.el][org-babel-scrip #+resname: implementing-ditaa [[file:blue.png][blue.png]] -*** STARTED gnuplot [6/8] +*** STARTED gnuplot [7/8] (see [[* file result types][file result types]]) #+PLOT: title:"Citas" ind:1 deps:(3) type:2d with:histograms set:"yrange [0:]" @@ -2355,10 +2355,23 @@ These should all be in place by now. #+end_src -**** STARTED gnuplot sessions +**** DONE gnuplot sessions Working on this, we won't support multiple sessions as `gnuplot-mode' isn't setup for such things. +Also we can't display results with the default :none session, so for +gnuplot we really want the default behavior to be :default, and to +only run a :none session when explicitly specified. + +#+srcname: implementing-gnuplot-sessions +#+begin_src gnuplot :var data=gnuplot-data :session none :file session.png +set title "Implementing Gnuplot Sessions" +plot data using 1:2 with lines +#+end_src + +#+resname: +[[file:session.png][session.png]] + **** TODO gnuplot LoB functionality maybe some of this helper driven plotting functionality should be