R-alpha: R-mode from S-mode (for emacs)

Martin Maechler (maechler@stat.math.ethz.ch)
Tue, 26 Mar 96 12:30:47 +0100

Date: Tue, 26 Mar 96 12:30:47 +0100
Message-Id: <9603261130.AA01068@>
From: Martin Maechler <maechler@stat.math.ethz.ch>
To: wvenable@attunga.stats.adelaide.edu.au
In-Reply-To: <9603261106.AA09411@attunga.stats.adelaide.edu.au> (message from
Subject: R-alpha: R-mode from  S-mode (for emacs)

I've adapted a little bit of  S-mode  to become  'R-mode'.

>>>>> "Bill" == Bill Venables <wvenable@attunga.stats.adelaide.edu.au> writes:

    Bill> I must ask David Smith how difficult it is to adapt S-mode to
    Bill> become R-mode.

Here are my basic additions
[some of them also my changing some of the defaults of S-mode]

The following is to be added to your  ~/.emacs  (or equivalent),
and then  type		
		M-x R

and open files ``foo.R''   or add the line '###-*- R -*-'
to the front of your R source files.

-------------- snip --- snip ------------------------------------------------

(setq auto-mode-alist
       (append '(( "\\.R$"  . R-mode))

(fset 'r-mode 'R-mode) ;=> a file starting with "#--*-R-*-- will load r-mode .
(fset 'R-mode 'S-mode)
(defun R () "Call 'R', the  'S clone' of Robert & Ross from NZ"
   (let ((inferior-S-program "R"))
     ;; 'nil FAILS !(setq S-ask-for-S-directory nil);- 
     (setq S-version-running "R");-> using 'ls()' instead of objects...
     (setq inferior-S-objects-command "if(%d == 1) ls() else builtins()")
     (setq inferior-S-search-list-command "search()\n");- is failing in R
     (setq inferior-S-help-command "help(\"%s\")\n")
     (setenv "PAGER" "cat") ;-- a MUST for the old-style (nroff) help  above !

;;;--- for R-mode, you should not need these : ------------

;;;  ===================  
;;; |   S command mode  |
;;;  ===================
 ;; Change the default which assumes you want to start from  $HOME :
 (setq S-directory nil) ;-- i.e., always propose the default-directory
 ;;(setq S-pre-run-hook '(lambda () (setq S-directory default-directory)))
 ;;					~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 (load "S-mode/S-site")

 ;;-- Even if  help.start() has been used:
 ;;--    use Emacs-buffer, not window-system window for 'Help' (C-c C-v):
 (setq inferior-S-help-command "help(\"%s\", window = FALSE)\n")
 (setq S-synchronize-evals nil) ; Default: NO synchronize,
 (setq S-eval-visibly-p    nil) ; so things are NOT blocked
 ;; Our machines are fast; but we need some time to
 ;; automatically start up graphics and/or help - windows
 (setq S-loop-timeout 40000)
 (setq inferior-S-program "Splus")

   (lambda ()
     ;;-- un-wise people removed this to \C-c\C-a in emacs-19.26,
     ;;-- even though with the following, you can use C-u C-a for 'beg.-line'
     (define-key comint-mode-map "\C-a" 'comint-bol)

r-testers mailing list -- To (un)subscribe, send
subscribe	or	unsubscribe
(in the "body", not the subject !)  To: r-testers-request@stat.math.ethz.ch