~ubuntu-branches/ubuntu/breezy/ess/breezy

« back to all changes in this revision

Viewing changes to lisp/essd-r.el

  • Committer: Bazaar Package Importer
  • Author(s): Camm Maguire
  • Date: 2002-03-04 14:26:19 UTC
  • Revision ID: james.westby@ubuntu.com-20020304142619-udvspp3pjys7tapf
Tags: upstream-5.1.20
ImportĀ upstreamĀ versionĀ 5.1.20

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
;;; essd-r.el --- R customization
 
2
 
 
3
;; Copyright (C) 1997--2001 A. J. Rossini, Richard M. Heiberger, Kurt
 
4
;; Hornik, Martin Maechler, and Rodney Sparapani.
 
5
 
 
6
 
 
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 $
 
14
;;
 
15
;; Keywords: start up, configuration.
 
16
 
 
17
;; This file is part of ESS.
 
18
 
 
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)
 
22
;; any later version.
 
23
 
 
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.
 
28
 
 
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.
 
32
 
 
33
;;; Commentary:
 
34
;;; This file defines all the R customizations for ESS.  See essl-s.el
 
35
;;; for general S language customizations.
 
36
 
 
37
;;; Autoloads and Requires
 
38
 
 
39
(ess-message "[essd-r:] (require 'essl-s)")
 
40
(require 'essl-s)
 
41
 
 
42
(ess-message "[essd-r:] (autoload ..) & (def** ..)")
 
43
 
 
44
(autoload 'inferior-ess "ess-inf" "Run an ESS process.")
 
45
(autoload 'ess-mode     "ess-mode" "Edit an ESS process.")
 
46
 
 
47
;;; Code:
 
48
 
 
49
(defvar R-customize-alist
 
50
  '((ess-local-customize-alist     . 'R-customize-alist)
 
51
    (ess-language                  . "S")
 
52
    (ess-dialect                   . "R")
 
53
    (ess-suffix                    . "R")
 
54
    (ess-loop-timeout              . 500000 )
 
55
    (ess-dump-filename-template    . (concat (user-login-name)
 
56
                                             ".%s."
 
57
                                             ess-suffix))
 
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       . "")
 
78
    (ess-STERM  . "iESS")
 
79
    (ess-editor . R-editor)
 
80
    (ess-pager  . R-pager)
 
81
    (inferior-ess-language-start .
 
82
                                 (concat "options("
 
83
                                         "STERM='"  ess-STERM  "'"
 
84
                                         (if ess-editor 
 
85
                                             (concat ", editor='" ess-editor "'"))
 
86
                                         (if ess-pager 
 
87
                                             (concat ", pager='"  ess-pager  "'"))
 
88
                                         ")"))
 
89
)
 
90
  "Variables to customize for R")
 
91
 
 
92
;;; AJR: Need to condition on this...!
 
93
(require 'ess-menu)
 
94
 
 
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."
 
99
  (interactive "P")
 
100
  (setq ess-customize-alist R-customize-alist)
 
101
  ;; for debugging only
 
102
  (ess-write-to-dribble-buffer
 
103
   (format
 
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))
 
106
  (let* ((r-always-arg
 
107
          (if ess-microsoft-p
 
108
              "--ess "
 
109
            "--no-readline "))
 
110
         (r-start-args
 
111
          (concat r-always-arg
 
112
                  (if start-args
 
113
                      (read-string
 
114
                       (concat "Starting Args [other than `"
 
115
                               r-always-arg
 
116
                               "'] ? "))
 
117
                    nil)))
 
118
         default-process-coding-system)
 
119
    (if ess-microsoft-p
 
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))))
 
124
 
 
125
 
 
126
(defun R-mode  (&optional proc-name)
 
127
  "Major mode for editing R source.  See `ess-mode' for more help."
 
128
  (interactive)
 
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!
 
134
  (ess-imenu-R))
 
135
 
 
136
(fset 'r-mode 'R-mode)
 
137
 
 
138
 
 
139
(autoload 'ess-transcript-mode "ess-trns"
 
140
  "Major mode for editing S transcript files." t)
 
141
 
 
142
(defun R-transcript-mode ()
 
143
  "Does the right thing."
 
144
  (interactive)
 
145
  (ess-transcript-mode R-customize-alist))
 
146
 
 
147
(fset 'r-transcript-mode 'R-transcript-mode)
 
148
 
 
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)
 
152
  (save-excursion
 
153
    (goto-char from)
 
154
    (ess-rep-regexp "\\(\\([][=,()]\\|<-\\|_\\) *\\)T\\>" "\\1TRUE"
 
155
                    'fixcase nil (not quietly))
 
156
    (goto-char from)
 
157
    (ess-rep-regexp "\\(\\([][=,()]\\|<-\\|_\\\) *\\)F\\>" "\\1FALSE"
 
158
                    'fixcase nil (not quietly))))
 
159
 
 
160
;;; R package wizard tools.  See ``R-extensions'' manual for more details as to
 
161
;;; the construction of an R package.
 
162
 
 
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."
 
167
  (interactive "P")
 
168
  (let* ((R-pkg-directory (if packages-directory
 
169
                                  (read-string
 
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)))
 
189
 
 
190
(defun R-create-description-file (R-pkg-name R-pkg-Description-file)
 
191
  "Create a proper description file."
 
192
  )
 
193
 
 
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."
 
197
  )
 
198
 
 
199
 ; provides
 
200
 
 
201
(provide 'essd-r)
 
202
 
 
203
 ; Local variables section
 
204
 
 
205
;;; This file is automatically placed in Outline minor mode.
 
206
;;; The file is structured as follows:
 
207
;;; Chapters:     ^L ;
 
208
;;; Sections:    ;;*;;
 
209
;;; Subsections: ;;;*;;;
 
210
;;; Components:  defuns, defvars, defconsts
 
211
;;;              Random code beginning with a ;;;;* comment
 
212
 
 
213
;;; Local variables:
 
214
;;; mode: emacs-lisp
 
215
;;; outline-minor-mode: nil
 
216
;;; mode: outline-minor
 
217
;;; outline-regexp: "\^L\\|\\`;\\|;;\\*\\|;;;\\*\\|(def[cvu]\\|(setq\\|;;;;\\*"
 
218
;;; End:
 
219
 
 
220
;;; ess-site.el ends here