[ESS] Emac s No0b seekz dreem functi0n (C-c C-c)
Dan Bolser
dmb at mrc-dunn.cam.ac.uk
Thu Oct 5 09:41:51 CEST 2006
Dan Bolser wrote:
>
> GSOH
>
>
> The following does not work, and I can't work out why (I am very
> inexperienced with emacs).
>
> (defun ess-eval-paragraph-and-step-xxx (vis)
> "Send the current paragraph to the inferior ESS process and move
> forward to
> the next paragraph. Arg has same meaning as for `ess-eval-region'."
> (interactive "P")
> (let ((beg-end (ess-eval-paragraph vis)))
> (goto-char (1+ (cadr beg-end))))
> (save-excursion
> (ess-switch-to-end-of-ESS)
> )
> )
>
>
> I am trying to get the functionality of ess-eval-paragraph-and-step
> (C-c C-c), but combine it with the convenience of
> ess-eval-line-and-step (C-c C-n), which also shows the 'process
> window' at the appropriate place (the bottom). The above code leaves
> the 'active' cursor in the 'process window' which isn't what I want.
>
> I would like ess-eval-paragraph-and-step-xxx to evaluate the function
> or paragraph AND also show the 'process window' AND move the 'cursor'
> to the bottom of the 'process window' AND put the cursor back at the
> end of the function or paragraph just as ess-eval-paragraph-and-step
> does. I had limited success using an *other-window* command (I forget
> which), but obviously that is not as good as talking directly to the
> ESS 'process window'
>
> Thanks for any help
>
> Dan.
>
>
>
> P.S.
>
> Hmmm....
>
> I got this to work (but I don't really know how)...
>
>
> (defun ess-eval-paragraph-and-step-xxx (vis)
> "Er..."
> (interactive "P") ; What is this?
> (ess-eval-paragraph-and-step vis)
> (previous-line 1)
> (ess-eval-line-and-step)
> )
>
> (global-set-key (kbd "C-c C-c") 'ess-eval-paragraph-and-step-xxx)
>
>
> However, that 'global-set-key' part doesn't seem to work (running the
> function from M-x appears to work fine). Is this a dumb issue, or is
> the binding gobbled up by ess? (I am running all this after loading
> ess with
>
> ;; Allow R command automatically
> (load "/home/xxx/emacs/ess-5.3.3/lisp/ess-site")
>
Follow up...
The following is working like a dream...
(defun ess-eval-function-or-paragraph-and-step-dan (vis)
"Er..."
(interactive "P")
(ess-eval-function-or-paragraph-and-step vis)
(previous-line 1)
(ess-eval-line-and-step)
)
(add-hook 'ess-mode-hook
(lambda ()
(local-set-key (kbd "C-c C-c")
'ess-eval-function-or-paragraph-and-step-dan)
)
)
Except that the following function throws an error using C-c C-c (as
bound above), whereas it is executed without error using C-c C-r over
the whole region...
y <- function(x) {
print(x)
}
However, this works...
y <- function(x) {print(x)}
Anything else (spread over more than one line) fails using my C-c C-c
function. However, (of course) the original
"ess-eval-function-or-paragraph-and-step" works fine.
Can anyone on the list help me to get the behavior I want without the
above failure? I figure I can simply tweak the original function
definition, but I am not sure how.
Cheers,
Dan.
>
>
>
>
>
>
>
More information about the ESS-help
mailing list