[ESS] R-mode local key binding

Richard M. Heiberger rmh at temple.edu
Sat Jan 29 20:39:17 CET 2005


This is a good start.  It has a few clashes with the ESS style.

1. Don't defun R-mode, as that is a function name already used by ESS.
Redefining an important function name might make things stop working.


2. The specific functions you are defining are already in ESS.
 
M-;
puts comment symbols at the beginning of a single empty line and at
the end of a single line that already has code.  If you mark a region,
it puts comment symbols at the beginning of each line in the region.

C-M-\
indent-region


3. The message you use "cleaning R code" is not the ideal message.
"indenting R code" is better.  ESS usually uses the word "clean"
in the function ess-transcript-clean-region which is used to
convert an S language output transcript file myfile.rt or
myfile.st into an input file.

   ess-transcript-clean-region is an interactive Lisp function in `ess-trns'.
   (ess-transcript-clean-region beg end even-if-read-only)
   
   Strip the transcript in the region, leaving only (R/S/Lsp/..) commands.
   Deletes any lines not beginning with a prompt, and then removes the
   prompt from those lines that remain.  Prefix argument means to use
   C-x C-q to clean even if the buffer is M-x read-only.
   

4.  Here is how to define a key and limit it to a single mode, in
this case ess-mode.  This function and key definition displays
the date and time when pressed in ess-mode (which includes
R-mode), but not elsewhere.


(defun jeaneid ()
  "display the date and time"
  (interactive)
  (message (time-stamp-string)))

(define-key ess-mode-map [(control f8)] 'jeaneid)




More information about the ESS-help mailing list