[ESS] Automatically scroll the process buffer when sending a command?

Dan Bolser dmb at mrc-dunn.cam.ac.uk
Fri Oct 20 11:05:52 CEST 2006


Martin Maechler wrote:
>>>>>> "Dan" == Dan Bolser <dmb at mrc-dunn.cam.ac.uk>
>>>>>>     on Thu, 05 Oct 2006 20:05:50 +0200 writes:
>>>>>>             
>
>     Dan> Richard M. Heiberger wrote:
>     >> I think you are looking for
>     >> comint-scroll-show-maximum-output
>     >> and related functions
>
>     Dan> Well... I tried the following...
>
>
>     Dan> (add-hook 'ess-mode-hook
>     Dan>   (setq comint-scroll-to-bottom-on-input t)
>     Dan>   (setq comint-scroll-show-maximum-output t))
>
>     Dan> Which does set the value of these variables in the 'local *R* buffer', 
>     Dan> however, there being set appears to have no effect.
>
> yes, it has to be done differently.
>
> If I google "maechler comint-scroll-to-bottom-on-input",
> the first three hits all seem to contain the solution.
>   

For completeness I thought I would post the 'answer' here (along with a 
slightly more helpful email title).

I found that doing the following nearly gave the solution that I was 
craving (I put this in the "~/.emacs" file, so it is read every time I 
invoke emacs);

----------------------------------------------------------------------------------------------------------
(eval-after-load
   "comint"
   '(progn
;;
;; This was the code from the examples I found,
;;
      (setq comint-scroll-to-bottom-on-output 'others)
    ;;=default: (setq comint-scroll-to-bottom-on-input nil)
;;
;; which causes the R 'process buffer' to scroll when you send a command.
;; The next line...
;;
      (setq comint-scroll-show-maximum-output t)
;;
;; Causes that process buffer to scroll so as to show the maximum output
;; resulting from the command you sent.
;;
;; Easy when you know how eh?
;;
      )
   )
----------------------------------------------------------------------------------------------------------



However, my hacked function (earlier in this thread) made use of code 
somewhere under "ess-eval-line-and-step" to ensure that an 'R process 
buffer' *appeared if necessary* when a command was sent. I find this 
very useful, as you can often loose sight of the process buffer during 
the course of a normal emacs session. When I send a function, naturally 
I want to see the output, and I expect the 'process buffer' to be visible.

I think the important code under "ess-eval-line-and-step" is...

(save-excursion
    (end-of-line)
    (let ((end (point)))
      (beginning-of-line)
      ;; go to end of process buffer so user can see result
      (ess-eval-linewise (buffer-substring (point) end)
                         invisibly 'eob (or even-empty ess-eval-empty))))


The code under ess-eval-linewise is too complex for me to look at right 
now - I naively just run
"ess-eval-line-and-step" with 'null' input to get the desired effect 
described above.

So I am nearly there!!!

I think forcing the appearance of the 'process buffer' should be an 
option and should have consistent results for all "ess-eval-*" functions 
(I forgot to mention that I almost exclusively use 
"ess-eval-function-or-paragraph-and-step", which does not behave like 
"ess-eval-line-and-step" in this regard).


Cheers.


P.S. Is there any (practical) difference between;

comint-scroll-to-bottom-on-output ; and
comint-scroll-to-bottom-on-input   ; ?







> I think we (ESS core) should add these details to the offical
> ESS manual.
> But since I'll be vacationing for a week from tomorrow,
> I don't have the time just now.
>
> BTW, everyone, patches to 
>      https://svn.r-project.org/ESS/trunk/doc/ess.texi
> are very welcome...
>
> Regards,
> Martin
>




More information about the ESS-help mailing list