1
0
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-11-28 07:44:49 +00:00

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.
This commit is contained in:
Aaron Ecay 2014-04-22 14:54:55 -04:00
parent c7dff7105b
commit 935b69e065
4 changed files with 13 additions and 21 deletions

View File

@ -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")

View File

@ -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:

View File

@ -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)

View File

@ -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)