1
;;; essd-r.el --- R customization
3
;; Copyright (C) 1997--2001 A. J. Rossini, Richard M. Heiberger, Kurt
4
;; Hornik, Martin Maechler, and Rodney Sparapani.
7
;; Author: A.J. Rossini <rossini@u.washington.edu>
8
;; Maintainers: A.J. Rossini <rossini@u.washington.edu>
9
;; M. Maechler <maechler@stat.math.ethz.ch>
10
;; Created: 12 Jun 1997
11
;; Modified: $Date: 2002/01/20 06:14:36 $
12
;; Version: $Revision: 5.34 $
13
;; RCS: $Id: essd-r.el,v 5.34 2002/01/20 06:14:36 rmh Exp $
15
;; Keywords: start up, configuration.
17
;; This file is part of ESS.
19
;; This file is free software; you can redistribute it and/or modify
20
;; it under the terms of the GNU General Public License as published by
21
;; the Free Software Foundation; either version 2, or (at your option)
24
;; This file is distributed in the hope that it will be useful,
25
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
26
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27
;; GNU General Public License for more details.
29
;; You should have received a copy of the GNU General Public License
30
;; along with GNU Emacs; see the file COPYING. If not, write to
31
;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
34
;;; This file defines all the R customizations for ESS. See essl-s.el
35
;;; for general S language customizations.
37
;;; Autoloads and Requires
39
(ess-message "[essd-r:] (require 'essl-s)")
42
(ess-message "[essd-r:] (autoload ..) & (def** ..)")
44
(autoload 'inferior-ess "ess-inf" "Run an ESS process.")
45
(autoload 'ess-mode "ess-mode" "Edit an ESS process.")
49
(defvar R-customize-alist
50
'((ess-local-customize-alist . 'R-customize-alist)
54
(ess-loop-timeout . 500000 )
55
(ess-dump-filename-template . (concat (user-login-name)
58
(ess-mode-editing-alist . S-editing-alist)
59
(ess-mode-syntax-table . S-syntax-table)
60
(ess-help-sec-regex . ess-help-R-sec-regex)
61
(ess-help-sec-keys-alist . R-help-sec-keys-alist)
62
(ess-object-name-db-file . "ess-r-namedb.el" )
63
(ess-retr-lastvalue-command
64
. ".Last.value <- get(\".ess.lvsave\",inherits=TRUE)\n") ; envir=1
65
(ess-save-lastvalue-command
66
. "assign(\".ess.lvsave\",.Last.value,inherits=TRUE)\n") ;envir=1
67
(ess-imenu-mode-function . 'ess-imenu-R)
68
(inferior-ess-program . inferior-R-program-name)
69
(inferior-ess-objects-command . "objects(pos = %d)\n")
70
(inferior-ess-search-list-command . "search()\n")
71
(inferior-ess-help-command . "help(\"%s\", htmlhelp=FALSE)\n")
72
(inferior-ess-exit-command . "q()\n")
73
(inferior-ess-primary-prompt . "[A-Za-z0-9.]*> ")
74
(inferior-ess-secondary-prompt . "+ ?")
75
(comint-use-prompt-regexp-instead-of-fields . t) ;; emacs 21 and up
76
(inferior-ess-start-file . nil) ;; "~/.ess-R"
77
(inferior-ess-start-args . "")
79
(ess-editor . R-editor)
81
(inferior-ess-language-start .
83
"STERM='" ess-STERM "'"
85
(concat ", editor='" ess-editor "'"))
87
(concat ", pager='" ess-pager "'"))
90
"Variables to customize for R")
92
;;; AJR: Need to condition on this...!
95
;; R that does the right thing irregardless of OS.
96
(defun R (&optional start-args)
97
"Call 'R', the GNU 'S clone' from Robert & Ross (Auckland, NZ).
98
Optional prefix (C-u) allows to set command line arguments, such as --vsize."
100
(setq ess-customize-alist R-customize-alist)
101
;; for debugging only
102
(ess-write-to-dribble-buffer
104
"\n(R): ess-dialect=%s, buf=%s, start-arg=%s\n current-prefix-arg=%s\n"
105
ess-dialect (current-buffer) start-args current-prefix-arg))
114
(concat "Starting Args [other than `"
118
default-process-coding-system)
120
(setq default-process-coding-system '(undecided-dos . undecided-dos)))
121
(inferior-ess r-start-args) ;; (R)
122
(if inferior-ess-language-start
123
(ess-eval-linewise inferior-ess-language-start))))
126
(defun R-mode (&optional proc-name)
127
"Major mode for editing R source. See `ess-mode' for more help."
129
(setq ess-customize-alist R-customize-alist)
130
;;(setq imenu-generic-expression R-imenu-generic-expression)
131
(ess-mode R-customize-alist proc-name)
132
;;; AJR: Need to condition on this...!
133
;; MM: and you probably should really use ess-imenu-mode-function from above!
136
(fset 'r-mode 'R-mode)
139
(autoload 'ess-transcript-mode "ess-trns"
140
"Major mode for editing S transcript files." t)
142
(defun R-transcript-mode ()
143
"Does the right thing."
145
(ess-transcript-mode R-customize-alist))
147
(fset 'r-transcript-mode 'R-transcript-mode)
149
(defun R-fix-T-F (&optional from quietly)
150
"Fix T/F into TRUE and FALSE --- CAUTIOUSLY"
151
(interactive "d\nP"); point and prefix (C-u)
154
(ess-rep-regexp "\\(\\([][=,()]\\|<-\\|_\\) *\\)T\\>" "\\1TRUE"
155
'fixcase nil (not quietly))
157
(ess-rep-regexp "\\(\\([][=,()]\\|<-\\|_\\\) *\\)F\\>" "\\1FALSE"
158
'fixcase nil (not quietly))))
160
;;; R package wizard tools. See ``R-extensions'' manual for more details as to
161
;;; the construction of an R package.
163
(defun R-package-wizard (&optional packages-directory)
164
"Create an R project skeleton.
165
Top-level directory is one below `packages-directory', i.e. package
166
contents will be placed in packages-directory/package-name."
168
(let* ((R-pkg-directory (if packages-directory
170
(concat "Starting Directory (where you keep packages: ?"))))
171
(R-pkg-name (read-string (concat "Package Name: ")))
172
(R-pkg-home-dir (concat R-pkg-directory R-pkg-name))
173
(R-pkg-R-srcdir (concat R-pkg-home-dir "/R"))
174
(R-pkg-compiled-srcdir (concat R-pkg-home-dir "/src"))
175
(R-pkg-man-srcdir (concat R-pkg-home-dir "/man"))
176
(R-pkg-test-srcdir (concat R-pkg-home-dir "/tests"))
177
(R-pkg-exec-srcdir (concat R-pkg-home-dir "/exec"))
178
(R-pkg-Description-file (concat R-pkg-home-dir "/Description"))
179
(R-pkg-Index-file (concat R-pkg-home-dir "/INDEX")))
180
;; Now create and construct everything
181
(make-directory R-pkg-home-dir)
182
(make-directory R-pkg-R-srcdir)
183
(make-directory R-pkg-compiled-srcdir)
184
(make-directory R-pkg-man-srcdir)
185
(make-directory R-pkg-test-srcdir)
186
(make-directory R-pkg-exec-srcdir)
187
(R-create-description-file R-pkg-name R-pkg-Description-file)
188
(R-create-index-file R-pkg-home-dir R-pkg-Index-file)))
190
(defun R-create-description-file (R-pkg-name R-pkg-Description-file)
191
"Create a proper description file."
194
(defun R-create-index-file (R-pkg-home-dir R-pkg-Index-file)
195
"Create a proper description file.
196
This should use R CMD to rebuild the index."
203
; Local variables section
205
;;; This file is automatically placed in Outline minor mode.
206
;;; The file is structured as follows:
209
;;; Subsections: ;;;*;;;
210
;;; Components: defuns, defvars, defconsts
211
;;; Random code beginning with a ;;;;* comment
215
;;; outline-minor-mode: nil
216
;;; mode: outline-minor
217
;;; outline-regexp: "\^L\\|\\`;\\|;;\\*\\|;;;\\*\\|(def[cvu]\\|(setq\\|;;;;\\*"
220
;;; ess-site.el ends here