Fix org-babel-R-initiate-session

* lisp/ob-R.el (org-babel-R-initiate-session): handle case where the
  session buffer exists, but does not have a live process

If the session buffer exists, but the user has exited the R process
manually, then the (R) command will create a new buffer, then try to
rename it over the old buffer, causing an error.  The right thing to do
is to start R within the existing buffer.
This commit is contained in:
Aaron Ecay 2013-04-01 01:42:15 -04:00 committed by Eric Schulte
parent 2f39a704cf
commit fe98647f14
1 changed files with 12 additions and 8 deletions

View File

@ -209,14 +209,18 @@ This function is called by `org-babel-execute-src-block'."
(if (org-babel-comint-buffer-livep session)
session
(save-window-excursion
(require 'ess) (R)
(rename-buffer
(if (bufferp session)
(buffer-name session)
(if (stringp session)
session
(buffer-name))))
(current-buffer))))))
(save-excursion
(when (get-buffer session)
;; Session buffer exists, but with dead process
(set-buffer session))
(require 'ess) (R)
(rename-buffer
(if (bufferp session)
(buffer-name session)
(if (stringp session)
session
(buffer-name))))
(current-buffer)))))))
(defun org-babel-R-associate-session (session)
"Associate R code buffer with an R session.