summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Ecay <aaronecay@gmail.com>2014-04-22 14:54:55 -0400
committerAaron Ecay <aaronecay@gmail.com>2014-04-22 15:31:15 -0400
commit935b69e0659653ac3e17a3c2132c7499abc2dc57 (patch)
tree21dc0015f6e346e93f6837269faea1253df6d587
parentc7dff7105b417a0cd6d05504121f83f3bc2c0cb4 (diff)
downloadorg-mode-935b69e0659653ac3e17a3c2132c7499abc2dc57.tar.gz
Replace org-babel-*-graphical-output-file with generic version
* lisp/ob-core.el (org-babel-graphical-output-file): New generic function. * lisp/ob-R.el (org-babel-R-graphical-output-file): Delete specific version. (org-babel-expand-body:R): Use generic version. * lisp/ob-maxima.el (org-babel-maxima-graphical-output-file): Delete specific version. (org-babel-maxima-expand): Use generic version. * lisp/ob-octave.el (org-babel-octave-graphical-output-file): Delete specific version (org-babel-execute:octave): Use generic version.
-rw-r--r--lisp/ob-R.el9
-rw-r--r--lisp/ob-core.el7
-rw-r--r--lisp/ob-maxima.el7
-rw-r--r--lisp/ob-octave.el11
4 files changed, 13 insertions, 21 deletions
diff --git a/lisp/ob-R.el b/lisp/ob-R.el
index 780d99f..1c71e04 100644
--- a/lisp/ob-R.el
+++ b/lisp/ob-R.el
@@ -96,7 +96,7 @@ this variable.")
(defun org-babel-expand-body:R (body params &optional graphics-file)
"Expand BODY according to PARAMS, return the expanded body."
(let ((graphics-file
- (or graphics-file (org-babel-R-graphical-output-file params))))
+ (or graphics-file (org-babel-graphical-output-file params))))
(mapconcat #'identity
(append
(when (cdr (assoc :prologue params))
@@ -117,7 +117,7 @@ This function is called by `org-babel-execute-src-block'."
(cdr (assoc :session params)) params))
(colnames-p (cdr (assoc :colnames params)))
(rownames-p (cdr (assoc :rownames params)))
- (graphics-file (org-babel-R-graphical-output-file params))
+ (graphics-file (org-babel-graphical-output-file params))
(full-body
(let ((inside
(list (org-babel-expand-body:R body params graphics-file))))
@@ -251,11 +251,6 @@ current code buffer."
(process-name (get-buffer-process session)))
(ess-make-buffer-current))
-(defun org-babel-R-graphical-output-file (params)
- "Name of file to which R should send graphical output."
- (and (member "graphics" (cdr (assq :result-params params)))
- (cdr (assq :file params))))
-
(defvar org-babel-R-graphics-devices
'((:bmp "bmp" "filename")
(:jpg "jpeg" "filename")
diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index d80ea4c..1348f04 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -2890,6 +2890,13 @@ For the format of SAFE-LIST, see `org-babel-safe-header-args'."
(member (cdr pair) (cdr entry)))
(t nil)))))))
+
+;;; Used by backends: R, Maxima, Octave.
+(defun org-babel-graphical-output-file (params)
+ "File where a babel block should send graphical output, per PARAMS."
+ (and (member "graphics" (cdr (assq :result-params params)))
+ (cdr (assq :file params))))
+
(provide 'ob-core)
;; Local variables:
diff --git a/lisp/ob-maxima.el b/lisp/ob-maxima.el
index 7435f1d..5d4ec18 100644
--- a/lisp/ob-maxima.el
+++ b/lisp/ob-maxima.el
@@ -52,7 +52,7 @@
(mapconcat 'identity
(list
;; graphic output
- (let ((graphic-file (org-babel-maxima-graphical-output-file params)))
+ (let ((graphic-file (org-babel-graphical-output-file params)))
(if graphic-file
(format
"set_plot_option ([gnuplot_term, png]); set_plot_option ([gnuplot_out_file, %S]);"
@@ -113,11 +113,6 @@ of the same value."
(format "%S: %s$" var
(org-babel-maxima-elisp-to-maxima val))))
-(defun org-babel-maxima-graphical-output-file (params)
- "Name of file to which maxima should send graphical output."
- (and (member "graphics" (cdr (assq :result-params params)))
- (cdr (assq :file params))))
-
(defun org-babel-maxima-elisp-to-maxima (val)
"Return a string of maxima code which evaluates to VAL."
(if (listp val)
diff --git a/lisp/ob-octave.el b/lisp/ob-octave.el
index 8cc66b6..1e6102c 100644
--- a/lisp/ob-octave.el
+++ b/lisp/ob-octave.el
@@ -84,16 +84,16 @@ end")
body params (org-babel-variable-assignments:octave params)))
(result (org-babel-octave-evaluate
session
- (if (org-babel-octave-graphical-output-file params)
+ (if (org-babel-graphical-output-file params)
(mapconcat 'identity
(list
"set (0, \"defaultfigurevisible\", \"off\");"
full-body
- (format "print -dpng %s" (org-babel-octave-graphical-output-file params)))
+ (format "print -dpng %s" (org-babel-graphical-output-file params)))
"\n")
full-body)
result-type matlabp)))
- (if (org-babel-octave-graphical-output-file params)
+ (if (org-babel-graphical-output-file params)
nil
(org-babel-reassemble-table
result
@@ -268,11 +268,6 @@ This removes initial blank and comment lines and then calls
(match-string 1 string)
string))
-(defun org-babel-octave-graphical-output-file (params)
- "Name of file to which maxima should send graphical output."
- (and (member "graphics" (cdr (assq :result-params params)))
- (cdr (assq :file params))))
-
(provide 'ob-octave)