[ESS] keybinding for (ess-eval-paragraph) and more
Dan Bolser
dmb at mrc-dunn.cam.ac.uk
Fri Mar 17 14:51:21 CET 2006
Martin Maechler wrote:
>>>>>>"Dan" == Dan Bolser <dmb at mrc-dunn.cam.ac.uk>
>>>>>> on Fri, 17 Mar 2006 10:20:55 +0000 writes:
>
>
> Dan> I thought I would post this code in the case that anyone finds it
> Dan> useful, or can offer some improvements. I use sql-mode all the time, so
> Dan> I find this function 'missing' from ess...
>
>
> Dan> (defun ess-eval-paragraph ()
> Dan> (interactive)
> Dan> (mark-paragraph)
> Dan> (call-interactively 'ess-eval-region)
> Dan> ;;(with-current-buffer "*R*" (end-of-buffer))
> Dan> ;;(save-excursion (ess-switch-to-end-of-ESS))
> Dan> (end-of-buffer-other-window 0)
> Dan> (forward-paragraph)
> Dan> )
>
> Hmm, ess-inf.el has been containing -- for about 10.5 years it
> seems:
>
> ---------------------------------------------------------------
>
> ;; This is from Mary Lindstrom <lindstro at Biostat.Wisc.Edu>
> ;; 31 Aug 1995 14:11:43 To: S-mode at stat.math.ethz.ch
> (defun ess-eval-paragraph (vis)
> "Send the current paragraph to the inferior ESS process.
> Prefix arg VIS toggles visibility of ess-code as for `ess-eval-region'."
> (interactive "P")
> (ess-force-buffer-current "Process to load into: ")
> (save-excursion
> (forward-paragraph)
> (let ((end (point)))
> (backward-paragraph)
> (ess-eval-region (point) end vis "Eval paragraph"))))
>
> ---------------------------------------------------------------
>
> but it is not (yet) bound to any key inside ESS,
Or anywhere in the ESS 'eval' menus.
> as you propose here :
>
> Dan> (global-set-key (kbd "C-c C-c") 'ess-eval-paragraph)
>
> Since I just see that C-c C-c is indeed unbound
> in the *.R buffers, we could adopt your proposed key binding
> indeed.
>
> What do others think about the proposed keybinding?
>
I think its good because 'sql-mode' uses the same binding for the same
function (but writing to an SQL process obviously).
> I could envisage an even smarter thing:
>
> Bind C-c C-c to ess-eval-paragraph-or-function
> which does not yet exist, but which would
>
> - see if we are inside of a function definition;
> - if yes, call ess-eval-function
> - if no, call ess-eval-paragraph
>
> What do people think about this?
I think that would be a good addition, because I have been writing
functions (loops actually) with non optimal layout simply for the
convenience of sending the code in one go with C-c C-c. If there was a
'block' check, that would be nice also. Personally I like the R process
buffer to jump to the end after I send a command, else I feel like I am
sending commands 'blind', and I get irritated by the extra key strokes
needed to keep jumping the process buffer to the end. Could this
behavior (as well as the 'paragraph forward' behavior be added to the
config?
I find it very convenient to skip through some code with nothing more
than repeated C-c's until I find the section I am developing.
Thanks for the help,
Dan.
> Martin <Maechler at stat.math.ethz.ch> http://stat.ethz.ch/people/maechler
> Seminar fuer Statistik, ETH-Zentrum LEO C16 Leonhardstr. 27
> ETH (Federal Inst. Technology) 8092 Zurich SWITZERLAND
> phone: +41-44-632-3408 fax: ...-1228 <><
More information about the ESS-help
mailing list