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...
48
(defvar S+6-dialect-name "S+6"
49
"Name of 'dialect' for S-PLUS 6.");easily changeable in a user's .emacs
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."
54
51
(file-directory-p (concat directory ".Data"))
55
52
(file-directory-p (concat directory ".Data/__Meta"))))
57
(defvar S+6-directory-function
54
(defvar S+-directory-function
59
(if (S+6-directory-p default-directory)
56
(if (S+-directory-p default-directory)
61
58
(or ess-directory default-directory))))
63
(defvar S+6-setup-directory-function
60
(defvaralias 'S+6-setup-directory-function 'S+-setup-directory-function)
61
(defvar S+-setup-directory-function
65
(when (and startdir (S+6-directory-p startdir))
63
(when (and startdir (S+-directory-p startdir))
67
65
(if (getenv "S_WORK")
68
66
(concat startdir ":" (getenv "S_WORK"))
69
67
;;(message "adding %s to S_WORK" startdir)
72
(defvar S+6-customize-alist
72
(defvaralias 'S+6-customize-alist 'S+-customize-alist)
73
(defvar S+-customize-alist
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)
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")
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")
90
91
S+common-cust-alist)
92
"Variables to customize for S+6.")
93
"Variables to customize for S+.")
94
95
(defvar ess-S+-post-run-hook nil
95
96
"Functions run in process buffer after the initialization of S+
98
(defun S+6 (&optional proc-name)
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."
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)))
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)))
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)
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))
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."
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)))
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."
123
(ess-transcript-mode S+6-customize-alist))
146
(ess-transcript-mode S+-customize-alist))
125
148
(defvar ess-s-versions-list nil
126
149
"List of other versions of S to add to ESS.