From b20ef32b9ac0bf0e6dcc5d348ed0883b82495894 Mon Sep 17 00:00:00 2001 From: Achim Gratz Date: Sun, 23 Sep 2012 11:07:18 +0200 Subject: [PATCH] do not set variables belonging to ESS MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * lisp/ob-R.el (org-babel-R-initiate-session): Protect against use of unbound variable `ess-ask-for-ess-directory´. The default for this variable is true, so act accordingly if it is found unbound. * lisp/ob-R.el: Remove initialization with `nil´ from `ess-ask-for-ess-directory´ and `ess-local-process-name´. Remove second declaration for `ess-local-process-name´. * testing/lisp/test-ob-R.el (test-ob-R/simple-session): Bind `ess-ask-for-ess-directory´ to nil to facilitate batch testing. --- lisp/ob-R.el | 8 ++++---- testing/lisp/test-ob-R.el | 7 ++++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/lisp/ob-R.el b/lisp/ob-R.el index 361428d92..3dedb3936 100644 --- a/lisp/ob-R.el +++ b/lisp/ob-R.el @@ -76,7 +76,7 @@ :version "24.1" :type 'string) -(defvar ess-local-process-name) +(defvar ess-local-process-name) ; dynamically scoped (defun org-babel-edit-prep:R (info) (let ((session (cdr (assoc :session (nth 2 info))))) (when (and session (string-match "^\\*\\(.+?\\)\\*$" session)) @@ -201,13 +201,14 @@ This function is called by `org-babel-execute-src-block'." name file header row-names max)))) (format "%s <- %s" name (org-babel-R-quote-tsv-field value)))) -(defvar ess-ask-for-ess-directory nil) +(defvar ess-ask-for-ess-directory) ; dynamically scoped (defun org-babel-R-initiate-session (session params) "If there is not a current R process then create one." (unless (string= session "none") (let ((session (or session "*R*")) (ess-ask-for-ess-directory - (and ess-ask-for-ess-directory (not (cdr (assoc :dir params)))))) + (and (and (boundp 'ess-ask-for-ess-directory) ess-ask-for-ess-directory) + (not (cdr (assoc :dir params)))))) (if (org-babel-comint-buffer-livep session) session (save-window-excursion @@ -220,7 +221,6 @@ This function is called by `org-babel-execute-src-block'." (buffer-name)))) (current-buffer)))))) -(defvar ess-local-process-name nil) (defun org-babel-R-associate-session (session) "Associate R code buffer with an R session. Make SESSION be the inferior ESS process associated with the diff --git a/testing/lisp/test-ob-R.el b/testing/lisp/test-ob-R.el index 0ebf4d9b4..aec4dd035 100644 --- a/testing/lisp/test-ob-R.el +++ b/testing/lisp/test-ob-R.el @@ -14,9 +14,10 @@ (signal 'missing-test-dependency "Support for R code blocks")) (ert-deftest test-ob-R/simple-session () - (org-test-with-temp-text - "#+begin_src R :session R\n paste(\"Yep!\")\n#+end_src\n" - (should (string= "Yep!" (org-babel-execute-src-block))))) + (let ((ess-ask-for-ess-directory nil)) + (org-test-with-temp-text + "#+begin_src R :session R\n paste(\"Yep!\")\n#+end_src\n" + (should (string= "Yep!" (org-babel-execute-src-block)))))) (ert-deftest test-ob-R/colnames-yes-header-argument () (org-test-with-temp-text "#+name: eg -- 2.11.4.GIT