~ubuntu-branches/ubuntu/trusty/ess/trusty

« back to all changes in this revision

Viewing changes to lisp/ess-sp6-d.el

  • Committer: Package Import Robot
  • Author(s): Dirk Eddelbuettel
  • Date: 2012-12-22 00:56:45 UTC
  • mfrom: (1.2.28)
  • Revision ID: package-import@ubuntu.com-20121222005645-itzbu0xupmctgysn
Tags: 12.09-1-1
* New upstream version released twelve hours ago

* debian/control: Mention Julia in Description: (Closes: #692468)

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
;; You now need to make sure you've defined if you are running 5.0 or 5.1.
46
46
;; Lots of things are broken between them, GRR...
47
47
 
48
 
(defvar S+6-dialect-name "S+6"
49
 
  "Name of 'dialect' for S-PLUS 6.");easily changeable in a user's .emacs
50
 
 
51
 
(defun S+6-directory-p (directory)
 
48
(defun S+-directory-p (directory)
52
49
  "Splus 5++ directories have a .Data directory and a __Meta directory within."
53
50
  (and directory
54
51
       (file-directory-p (concat directory ".Data"))
55
52
       (file-directory-p (concat directory ".Data/__Meta"))))
56
53
 
57
 
(defvar S+6-directory-function
 
54
(defvar S+-directory-function
58
55
  (lambda ()
59
 
    (if (S+6-directory-p default-directory)
 
56
    (if (S+-directory-p default-directory)
60
57
        default-directory
61
58
      (or ess-directory default-directory))))
62
59
 
63
 
(defvar S+6-setup-directory-function
 
60
(defvaralias 'S+6-setup-directory-function 'S+-setup-directory-function)
 
61
(defvar S+-setup-directory-function
64
62
  (lambda (startdir)
65
 
    (when (and startdir (S+6-directory-p startdir))
 
63
    (when (and startdir (S+-directory-p startdir))
66
64
      (setenv "S_WORK"
67
65
              (if (getenv "S_WORK")
68
66
                  (concat startdir ":" (getenv "S_WORK"))
69
67
                ;;(message "adding %s to S_WORK" startdir)
70
68
                startdir)))))
71
69
 
72
 
(defvar S+6-customize-alist
 
70
 
 
71
 
 
72
(defvaralias 'S+6-customize-alist 'S+-customize-alist)
 
73
(defvar S+-customize-alist
73
74
  (append
74
 
   '((ess-local-customize-alist         . 'S+6-customize-alist)
75
 
     (ess-dialect                       . S+6-dialect-name)
 
75
   '((ess-local-customize-alist         . 'S+-customize-alist)
 
76
     (ess-dialect                       . S+-dialect-name)
76
77
     (ess-loop-timeout                  . ess-S-loop-timeout);fixme: dialect spec.
77
78
     (ess-function-pattern              . ess-R-function-pattern)
78
79
 
79
80
     (ess-object-name-db-file           . "ess-sp6-namedb.el")
80
 
     (inferior-ess-program              . inferior-S+6-program-name)
 
81
     (inferior-ess-program              . inferior-S+-program-name)
81
82
     (inferior-ess-help-command   . "help(\"%s\", pager=\"slynx -dump\", window=FALSE)\n")
82
83
     (inferior-ess-help-filetype . nil)
83
84
     (inferior-ess-search-list-command  . "searchPaths()\n")
84
85
 
85
 
     (ess-directory-function            . S+6-directory-function)
86
 
     (ess-setup-directory-function      . S+6-setup-directory-function)
87
 
     (inferior-ess-start-args       . inferior-Splus-args)
 
86
     (ess-directory-function            . S+-directory-function)
 
87
     (ess-setup-directory-function      . S+-setup-directory-function)
 
88
     (inferior-ess-start-args       . inferior-S+-start-args)
88
89
     (ess-STERM  . "iESS")
89
90
     )
90
91
   S+common-cust-alist)
91
92
 
92
 
  "Variables to customize for S+6.")
 
93
  "Variables to customize for S+.")
93
94
 
94
95
(defvar ess-S+-post-run-hook nil
95
96
  "Functions run in process buffer after the initialization of S+
96
97
  process.")
97
98
 
98
 
(defun S+6 (&optional proc-name)
 
99
(defalias 'S+6 'S+)
 
100
(defun S+ (&optional proc-name)
99
101
  "Call 'Splus6', based on S version 4, from Bell Labs.
100
102
New way to do it."
101
103
  (interactive)
102
 
  (setq ess-customize-alist S+6-customize-alist)
 
104
  (setq ess-customize-alist S+-customize-alist)
103
105
  (ess-write-to-dribble-buffer
104
 
   (format "\n(S+6): ess-dialect=%s, buf=%s\n" ess-dialect (current-buffer)))
 
106
   (format "\n(S+): ess-dialect=%s, buf=%s\n" ess-dialect (current-buffer)))
105
107
  (inferior-ess)
 
108
  (ess-command ess-S+--injected-code)
106
109
  (if inferior-ess-language-start
107
110
      (ess-eval-linewise inferior-ess-language-start))
108
111
  (with-ess-process-buffer nil
109
112
    (run-mode-hooks 'ess-S+-post-run-hook)))
110
113
 
111
 
 
112
 
(defun S+6-mode (&optional proc-name)
113
 
  "Major mode for editing S+6 source.  See `ess-mode' for more help."
 
114
(defvar ess-S+--injected-code
 
115
  ".ess.funargs <- function(object){
 
116
  funname <- deparse(substitute(object))
 
117
  fun <- try(object, silent = TRUE) ## works for special objects also
 
118
  if(is.function(fun)) {
 
119
    special <- grepl('[:$@[]', funname)
 
120
    args <- args(fun)
 
121
    fmls <- formals(args)
 
122
    fmls.names <- names(fmls)
 
123
    fmls <- gsub('\\\"', '\\\\\\\"', as.character(fmls), fixed = TRUE)
 
124
    args.alist <- sprintf(\"'(%s)\", paste(\"(\\\"\", fmls.names, \"\\\" . \\\"\", fmls, \"\\\")\", sep = '', collapse = ' '))
 
125
    ## envname <- environmentName(environment(fun))
 
126
    envname <-  if (special) '' else 'S+'
 
127
    cat(sprintf('(list \\\"%s\\\" %s )\\n', envname, args.alist))
 
128
  }
 
129
}
 
130
")
 
131
 
 
132
 
 
133
(defalias 'S+6-mode 'S+-mode)
 
134
(defun S+-mode (&optional proc-name)
 
135
  "Major mode for editing S+ source.  See `ess-mode' for more help."
114
136
  (interactive)
115
 
  (setq ess-customize-alist S+6-customize-alist)
116
 
  (ess-mode S+6-customize-alist proc-name)
 
137
  (setq ess-customize-alist S+-customize-alist)
 
138
  (ess-mode S+-customize-alist proc-name)
117
139
  (if (fboundp 'ess-add-toolbar) (ess-add-toolbar))
118
140
  (if ess-imenu-use-S (ess-imenu-S)))
119
141
 
120
 
(defun S+6-transcript-mode ()
 
142
(defalias 'S+6-transcript-mode 'S+-transcript-mode)
 
143
(defun S+-transcript-mode ()
121
144
  "S-PLUS 6 transcript mode."
122
145
  (interactive)
123
 
  (ess-transcript-mode S+6-customize-alist))
 
146
  (ess-transcript-mode S+-customize-alist))
124
147
 
125
148
(defvar ess-s-versions-list nil
126
149
  "List of other versions of S to add to ESS.
180
203
  \"Call S-X.Y, i.e., the S version 'S-X.Y' using ESS.
181
204
This function was generated by `ess-s-versions-create'.\"
182
205
  (interactive \"\")
183
 
  (let ((inferior-S+6-program-name \"S-X.Y\"))
184
 
    (S+6)))
 
206
  (let ((inferior-S+-program-name \"S-X.Y\"))
 
207
    (S+)))
185
208
 
186
209
")
187
210
    (with-current-buffer eval-buf
222
245
This function will run S-FULL-PATH
223
246
This function was generated by `ess-s-versions-create'.\"
224
247
  (interactive \"\")
225
 
  (let ((inferior-S+6-program-name \"S-FULL-PATH\"))
226
 
    (S+6)))
 
248
  (let ((inferior-S+-program-name \"S-FULL-PATH\"))
 
249
    (S+)))
227
250
 
228
251
")
229
252
        ;; need another version of template, with args.
232
255
This function will run S-FULL-PATH
233
256
This function was generated by `ess-s-versions-create'.\"
234
257
  (interactive \"\")
235
 
  (let ((inferior-S+6-program-name \"S-FULL-PATH\")
236
 
        (inferior-Splus-args \"S-MYARGS\"))
237
 
    (S+6)))
 
258
  (let ((inferior-S+-program-name \"S-FULL-PATH\")
 
259
        (inferior-S+-start-args \"S-MYARGS\"))
 
260
    (S+)))
238
261
 
239
262
")
240
263
        (while ess-s-versions-list