From mboxrd@z Thu Jan 1 00:00:00 1970 From: Aaron Ecay Subject: [PATCH 01/10] Fix org-babel-R-initiate-session Date: Mon, 1 Apr 2013 01:42:15 -0400 Message-ID: <1364794944-13826-2-git-send-email-aaronecay@gmail.com> References: <1364794944-13826-1-git-send-email-aaronecay@gmail.com> Return-path: Received: from eggs.gnu.org ([208.118.235.92]:37656) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UMXVq-0002iy-Lx for emacs-orgmode@gnu.org; Mon, 01 Apr 2013 01:42:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UMXVo-0000ur-F8 for emacs-orgmode@gnu.org; Mon, 01 Apr 2013 01:42:34 -0400 Received: from mail-qe0-f52.google.com ([209.85.128.52]:42861) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UMXVo-0000un-Be for emacs-orgmode@gnu.org; Mon, 01 Apr 2013 01:42:32 -0400 Received: by mail-qe0-f52.google.com with SMTP id jy17so1042501qeb.25 for ; Sun, 31 Mar 2013 22:42:32 -0700 (PDT) In-Reply-To: <1364794944-13826-1-git-send-email-aaronecay@gmail.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org * 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. --- lisp/ob-R.el | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/lisp/ob-R.el b/lisp/ob-R.el index 9875f81..de9ec5b 100644 --- a/lisp/ob-R.el +++ b/lisp/ob-R.el @@ -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. -- 1.8.2