From 6bcbdce94964ad7004d494f26b190fd897afc266 Mon Sep 17 00:00:00 2001 From: Dan Davison Date: Mon, 20 Dec 2010 18:58:59 +0000 Subject: [PATCH] ob-R: Respond to changes in handling of :file header argument ":results graphics" is now required in addition to ":file filename" in order for graphical output to be sent automatically to file. If :file is supplied, but not ":results graphics", then the default behavior obtains: i.e., either "value" or "output" results are written to file, depending on which of those options is in effect. * lisp/ob-R.el (org-babel-R-graphical-output-file): New function returns the name of the output file iff R has been instructed to send graphical output to file by means of the ":results graphics" directive. (org-babel-expand-body:R): Use `org-babel-R-graphical-output-file' when constructing the R code to evaluate, which may be augmented with code implementing the writing of graohical output to file. (org-babel-execute:R): Use `org-babel-R-graphical-output-file' to determine whether R is taking responsibility for writing output to file; if so, this is signalled to ob.el by returning a nil result. --- lisp/ob-R.el | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lisp/ob-R.el b/lisp/ob-R.el index fbb813b3b..43d0fdf1f 100644 --- a/lisp/ob-R.el +++ b/lisp/ob-R.el @@ -184,6 +184,11 @@ 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)))) + (defun org-babel-R-construct-graphics-device-call (out-file params) "Construct the call to the graphics device." (let ((devices