[ESS] shift-return key binding on ESS Wiki, .R versus .Rnw
Erik Iverson
eriki at ccbr.umn.edu
Wed Dec 22 17:35:37 CET 2010
David,
I did not test this at all, but to get started, I notice
there is a variable called Rnw-mode-hook, which is run before
entering a buffer into Rnw-mode. So you could try as a first
step:
(add-hook 'Rnw-mode-hook
'(lambda()
(local-set-key [(shift return)] 'my-ess-eval)))
Hope that helps,
--Erik
David Afshartous wrote:
>
> All,
> There is a nice shift-return key binding described on the ESS Wiki
> (http://www.emacswiki.org/emacs/EmacsSpeaksStatistics#toc3). I added it
> (shown below) to my .emacs file; it works but only for .R files. What
> would be the most direct way to change it such that it also works for
> .Rnw files? (I tried a few things but nothing has worked so far)
> Thanks,
> David
>
>
>
> (setq ess-ask-for-ess-directory nil)
> (setq ess-local-process-name "R")
> (setq ansi-color-for-comint-mode 'filter)
> (setq comint-prompt-read-only t)
> (setq comint-scroll-to-bottom-on-input t)
> (setq comint-scroll-to-bottom-on-output t)
> (setq comint-move-point-for-output t)
>
> (defun my-ess-start-R ()
> (interactive)
> (if (not (member "*R*" (mapcar (function buffer-name) (buffer-list))))
> (progn
> (delete-other-windows)
> (setq w1 (selected-window))
> (setq w1name (buffer-name))
> (setq w2 (split-window w1))
> (R)
> (set-window-buffer w2 "*R*")
> (set-window-buffer w1 w1name))))
>
> (defun my-ess-eval ()
> (interactive)
> (my-ess-start-R)
> (if (and transient-mark-mode mark-active)
> (call-interactively 'ess-eval-region)
> (call-interactively 'ess-eval-line-and-step)))
>
> (add-hook 'ess-mode-hook
> '(lambda()
> (local-set-key [(shift return)] 'my-ess-eval)))
>
> (add-hook 'inferior-ess-mode-hook
> '(lambda()
> (local-set-key [C-up] 'comint-previous-input)
> (local-set-key [C-down] 'comint-next-input)))
> (require 'ess-site)
>
>
>
More information about the ESS-help
mailing list