[ESS] shift-return key binding on ESS Wiki, .R versus .Rnw

David Afshartous david.r.afshartous at Vanderbilt.Edu
Wed Dec 22 17:30:17 CET 2010

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)

   (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 ()
     (if (not (member "*R*" (mapcar (function buffer-name) (buffer-list))))
	(setq w1 (selected-window))
	(setq w1name (buffer-name))
	(setq w2 (split-window w1))
	(set-window-buffer w2 "*R*")
	(set-window-buffer w1 w1name))))

   (defun my-ess-eval ()
     (if (and transient-mark-mode mark-active)
	(call-interactively 'ess-eval-region)
       (call-interactively 'ess-eval-line-and-step)))

   (add-hook 'ess-mode-hook
	       (local-set-key [(shift return)] 'my-ess-eval)))

   (add-hook 'inferior-ess-mode-hook
	       (local-set-key [C-up] 'comint-previous-input)
	       (local-set-key [C-down] 'comint-next-input)))
   (require 'ess-site)

David Afshartous, Ph.D.
Research Associate Professor
School of Medicine
Department of Biostatistics
Vanderbilt University

More information about the ESS-help mailing list