* org-babel with R, scrolling an inferior ESS process
@ 2010-02-16 16:00 Erik Iverson
2010-02-17 2:24 ` Dan Davison
0 siblings, 1 reply; 4+ messages in thread
From: Erik Iverson @ 2010-02-16 16:00 UTC (permalink / raw)
To: emacs-orgmode
Hello,
I have been a happy user of ESS with R for years. Recently, I've begun
to use org-mode for a lot of things, so of course I am interested in
org-babel. I checked out a version of org-mode yesterday (2-15-2010)
from git.
Using just ESS, I would write a source file, test.R, and define a
function in it, say
#identity function
test <- function(x) {
x
}
test(3)
I could then type C-c C-c (coincidentally, and happily, this is the ESS
keybinding used to send a block of code to the inferior *R* process) to
send the above lines to the running *R* process, and the output would
show up in the *R* buffer, and scroll to the bottom of the *R* buffer
since I have set
(setq comint-scroll-to-bottom-on-output t)
in my .emacs.
However, now I hope to write a file, test.org, and write something like:
* 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'?
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?
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: org-babel with R, scrolling an inferior ESS process
2010-02-16 16:00 org-babel with R, scrolling an inferior ESS process Erik Iverson
@ 2010-02-17 2:24 ` Dan Davison
2010-02-18 15:37 ` Erik Iverson
0 siblings, 1 reply; 4+ messages in thread
From: Dan Davison @ 2010-02-17 2:24 UTC (permalink / raw)
To: Erik Iverson; +Cc: emacs-orgmode
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 <davison@stats.ox.ac.uk>
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: org-babel with R, scrolling an inferior ESS process
2010-02-17 2:24 ` Dan Davison
@ 2010-02-18 15:37 ` Erik Iverson
2010-02-18 17:39 ` Eric Schulte
0 siblings, 1 reply; 4+ messages in thread
From: Erik Iverson @ 2010-02-18 15:37 UTC (permalink / raw)
To: Dan Davison; +Cc: emacs-orgmode
Hello,
<snip>
>> 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.
Great, I'd be happy to test out the code when it's ready!
>
>> 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.
>
That would be great, too!
> 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.
I will let you know as I continue using it. The ultimate improvement
IMO would be some sort of good multi-mode support, so that things
between #+begin_src/#+end_src would be fontified according to their
mode. And when I, for example, move into an R source section in my
org-mode buffer, all ESS key bindings would work.
I have read a couple recent threads about getting functionality like
this via two-mode-mode for instance, but they have some quirks that make
it unusable for me. Are you and Eric working on anything like this? I
have been investigating different options and will let you know if I
find anything promising!
Thanks!
Erik
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: org-babel with R, scrolling an inferior ESS process
2010-02-18 15:37 ` Erik Iverson
@ 2010-02-18 17:39 ` Eric Schulte
0 siblings, 0 replies; 4+ messages in thread
From: Eric Schulte @ 2010-02-18 17:39 UTC (permalink / raw)
To: Erik Iverson; +Cc: Dan Davison, emacs-orgmode
Erik Iverson <eriki@ccbr.umn.edu> writes:
[...]
>> 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.
>
> I will let you know as I continue using it. The ultimate improvement
> IMO would be some sort of good multi-mode support, so that things
> between #+begin_src/#+end_src would be fontified according to their
> mode. And when I, for example, move into an R source section in my
> org-mode buffer, all ESS key bindings would work.
>
> I have read a couple recent threads about getting functionality like
> this via two-mode-mode for instance, but they have some quirks that
> make it unusable for me. Are you and Eric working on anything like
> this? I have been investigating different options and will let you
> know if I find anything promising!
>
Hi Erik,
This is a very popular feature request, but as far as I know it is not
possible due to limitations ingrained fairly deep into the core of
Emacs. To my knowledge the best such mode for embedding multiple major
modes in a single buffer is MuMaMo-mode [1] which has been applied to
source-code blocks in Org-mode buffers [2], but as mentioned in that
thread, it's far from stable.
Best -- Eric
>
> Thanks!
> Erik
Footnotes:
[1] http://www.emacswiki.org/cgi-bin/wiki/MuMaMo
[2] http://article.gmane.org/gmane.emacs.orgmode/8112/match=mumamo
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-02-18 17:39 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-16 16:00 org-babel with R, scrolling an inferior ESS process Erik Iverson
2010-02-17 2:24 ` Dan Davison
2010-02-18 15:37 ` Erik Iverson
2010-02-18 17:39 ` Eric Schulte
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).