Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

When I use R in Emacs through the ESS package, C-c C-c in a .R buffer will send a “block” of code to the inferior R process for evaluation. This was added just a few years ago, but my fingers are now trained to use that key combination for evaluating any block of code. Since I have been learning Emacs Lisp, I decided that a good idea would be to make C-c C-c a binding to eval-defun. I really like how it is working out as I have to redefine my Lisp functions many times!

Just put the following in your .emacs file to get this behavior. However, please note the following from the eval-defun help string, “If the current defun is actually a call to defvar’ or defcustom’, evaluating it this way resets the variable using its initial value expression even if the variable already has some other value. (Normally defvar’ and defcustom’ do not alter the value if there already is one.)”

(define-key lisp-mode-shared-map "C-cC-c" 'eval-defun)