Преглед на файлове

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.
Aaron Ecay преди 11 години
родител
ревизия
935b69e065
променени са 4 файла, в които са добавени 13 реда и са изтрити 21 реда
  1. 2 7
      lisp/ob-R.el
  2. 7 0
      lisp/ob-core.el
  3. 1 6
      lisp/ob-maxima.el
  4. 3 8
      lisp/ob-octave.el

+ 2 - 7
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")

+ 7 - 0
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:

+ 1 - 6
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)

+ 3 - 8
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)