From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dan Davison Subject: Re: org-babel with R, scrolling an inferior ESS process Date: Tue, 16 Feb 2010 21:24:14 -0500 Message-ID: <87sk90vbu9.fsf@stats.ox.ac.uk> References: <4B7AC106.5050109@ccbr.umn.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NhZaU-0003kR-LV for emacs-orgmode@gnu.org; Tue, 16 Feb 2010 21:24:26 -0500 Received: from [140.186.70.92] (port=49844 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NhZaS-0003jJ-DB for emacs-orgmode@gnu.org; Tue, 16 Feb 2010 21:24:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1NhZaR-000896-4w for emacs-orgmode@gnu.org; Tue, 16 Feb 2010 21:24:24 -0500 Received: from markov.stats.ox.ac.uk ([163.1.210.1]:52796) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NhZaQ-000890-UT for emacs-orgmode@gnu.org; Tue, 16 Feb 2010 21:24:23 -0500 In-Reply-To: <4B7AC106.5050109@ccbr.umn.edu> (Erik Iverson's message of "Tue, 16 Feb 2010 10:00:06 -0600") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Erik Iverson Cc: emacs-orgmode@gnu.org Hi Erik, [...] > * Identity function > #+begin_src R :session :results output silent > test <- function(x) { > x > } > test(3) > #+end_src > > If I use C-c ' to open an R code buffer and C-c C-c, I see the same > behavior as in ESS. However, when I do C-c C-c on the code block *in > the test.org buffer*, the code is sent to the *R* buffer, but it does > not scroll. In the *R* buffer, once I do scroll to the bottom, I see > the following: > >> > test <- function(x) { > x > } > test(3) > 'org_babel_R_eoe' > >> test <- function(x) { > + x > + } >> test(3) > [1] 3 >> 'org_babel_R_eoe' > [1] "org_babel_R_eoe" > > Can anyone > 1) replicate that you don't see the scrolling, even with the > comint-scroll-to-bottom-on-output variable set to 't'? Yes, this has been on my todo list for a while! Definitely time to fix it. > 2) suggest a way to get the *R* buffer to scroll to the bottom when I > execute a source block from an org-mode file to a running *R* session? It seems to be fixable by changing a couple of save-window-excursions into save-excursions (patch below). I haven't thought of anything that this will break, but in any case I suspect that Eric S. will apply the correct fix to the main git repo soon. As for the 'org_babel_R_eoe' stuff, that is org-babel internals that ideally would not be exposed to the user. I suspect that it is possible to remove it from the comint buffer -- Eric S. is definitely best placed to comment on the best way of doing that. I'm sure this is obvious to you, but while we're on the topic: the reason that the org-babel R comint evaluation behaviour differs from ESS is because org-babel required a common mechanism that would work for all the supported languages; we were aware all along that ESS had already done an excellent job of doing that for R (plus some other languages). Please do let us know of any other improvements we can make to using org-babel with ESS. Good integration with ESS has been one of our aims from the beginning. Dan --8<---------------cut here---------------start------------->8--- commit d84c426027653a41ad02992d06d7c151d26d1f4b Author: Dan Davison Date: Tue Feb 16 21:08:09 2010 -0500 babel: allow point to move to end of comint buffer diff --git a/contrib/babel/lisp/langs/org-babel-R.el b/contrib/babel/lisp/langs/org-babel-R.el index 1fe2826..c3f9e19 100644 --- a/contrib/babel/lisp/langs/org-babel-R.el +++ b/contrib/babel/lisp/langs/org-babel-R.el @@ -39,7 +39,7 @@ "Execute a block of R code with org-babel. This function is called by `org-babel-execute-src-block'." (message "executing R source code block...") - (save-window-excursion + (save-excursion (let* ((processed-params (org-babel-process-params params)) (result-type (fourth processed-params)) (session (org-babel-R-initiate-session (first processed-params))) diff --git a/contrib/babel/lisp/org-babel-comint.el b/contrib/babel/lisp/org-babel-comint.el index d65f054..e693a40 100644 --- a/contrib/babel/lisp/org-babel-comint.el +++ b/contrib/babel/lisp/org-babel-comint.el @@ -45,7 +45,7 @@ body inside the protection of `save-window-excursion' and `save-match-data'." (declare (indent 1)) - `(save-window-excursion + `(save-excursion (save-match-data (unless (org-babel-comint-buffer-livep ,buffer) (error (format "buffer %s doesn't exist or has no process" ,buffer))) --8<---------------cut here---------------end--------------->8--- > > I am surprised by this behavior since I just assumed comint-mode > should do the right thing, so I'm not sure where the issue is! Even if > this can't be changed, I think org-babel is going to be a great use to > me, thank you! > > Best Regards, > Erik Iverson > > > _______________________________________________ > Emacs-orgmode mailing list > Please use `Reply All' to send replies to the list. > Emacs-orgmode@gnu.org > http://lists.gnu.org/mailman/listinfo/emacs-orgmode