1 ;;; essd-sp6w.el --- S-PLUS 6.x for Windows customization
3 ;;; copied and edited from essd-sp4.el - Richard M. Heiberger, April 2001
5 ;; Copyright (C) 2001 Richard M. Heiberger <rmh@sbm.temple.edu>
6 ;; Copyright (C) 2002--2005 A.J. Rossini, Rich M. Heiberger, Martin
7 ;; Maechler, Kurt Hornik, Rodney Sparapani, and Stephen Eglen.
9 ;; Original Author: Richard M. Heiberger <rmh@sbm.temple.edu>
10 ;; Created: April 2001
11 ;; Maintainers: ESS-core <ESS-core@stat.math.ethz.ch>
13 ;; Keywords: start up, configuration.
15 ;; This file is part of ESS.
17 ;; This file is free software; you can redistribute it and/or modify
18 ;; it under the terms of the GNU General Public License as published by
19 ;; the Free Software Foundation; either version 2, or (at your option)
22 ;; This file is distributed in the hope that it will be useful,
23 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
24 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 ;; GNU General Public License for more details.
27 ;; You should have received a copy of the GNU General Public License
28 ;; along with GNU Emacs; see the file COPYING. If not, write to
29 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
33 ;;; This file defines all the S-PLUS 6.x for Windows customizations
34 ;;; for ess-mode with ddeclient.
36 ;;; Requires and Autoloads:
39 ;;NO: this is autoloaded from other places (require 'ess-dde)
41 (autoload 'inferior-ess
"ess-inf" "Run an ESS process.")
42 (autoload 'ess-mode
"ess-mode" "Edit an ESS process.")
46 (defcustom S
+6-dialect-name
"S"
47 "Name of 'dialect' for S-PLUS 6.x and later.
48 Easily changeable in a user's `.emacs'."
52 (defvar inferior-S
+6-start-args
" "
53 "Default is empty. Can be used for license manager information, for example
54 `(setq inferior-S+6-start-args \" S_ELMHOST=\\\\\\\\@123.456.789.012 ELMTIMEOUT=60 \")'."
55 ;; (setq inferior-S+6-start-args " S_ELMHOST=\\\\@123.456.789.012 ELMTIMEOUT=60 ") ;; use this line as the model for your site-start.el
58 (defvar inferior-Sqpe-start-args
" "
59 "Default is empty. Can be used for license manager information, for example
60 `(setq inferior-Sqpe-start-args \" S_ELMHOST=@123.456.789.012 ELMTIMEOUT=60 \")'."
61 ;; (setq inferior-Sqpe-start-args " S_ELMHOST=@123.456.789.012 ELMTIMEOUT=60 ") ;; use this line as the model for your site-start.el
64 (defvar inferior-S
+6-multipleinstances
"/MULTIPLEINSTANCES"
65 "Default \"/MULTIPLEINSTANCES\" opens up a new instance of S+[678] in a
66 GUI window and connects it to the '(ddeESS [S+6])' window. The
67 alternative nil uses an existing S+6 GUI (if there is one) and
68 connects it to the '(ddeESS [S+6])' window.")
70 (defvar S
+6-customize-alist
72 '((ess-local-customize-alist .
'S
+6-customize-alist
)
73 (ess-dialect . S
+6-dialect-name
)
74 (ess-loop-timeout . ess-S-loop-timeout
);fixme: dialect spec.
75 (ess-object-name-db-file .
"ess-sp6-namedb.el" )
76 (inferior-ess-program . inferior-S
+6-program-name
)
77 (inferior-ess-help-command .
"help(\"%s\")\n")
78 (inferior-ess-help-filetype .
"chm")
79 (inferior-ess-search-list-command .
"searchPaths()\n")
80 (inferior-ess-start-file . nil
) ;"~/.ess-S+6")
81 (inferior-ess-start-args .
(concat
82 inferior-S
+6-multipleinstances
84 inferior-S
+6-start-args
86 inferior-S
+6-print-command
88 (directory-file-name default-directory
)))
89 ;; (inferior-ess-ddeclient . "ddeclient")
90 ;; (inferior-ess-client-name . "S-PLUS")
91 ;; (inferior-ess-client-command . "SCommand")
92 (ess-STERM .
"ddeESS")
95 "Variables to customize for S+6")
97 (defvar Sqpe
+6-customize-alist
99 '((ess-local-customize-alist .
'Sqpe
+6-customize-alist
)
100 (ess-dialect . S
+6-dialect-name
)
101 (ess-loop-timeout .
500000 );fixme: dialect specific custom.var
102 (ess-object-name-db-file .
"ess-sp6-namedb.el" )
103 (inferior-ess-program . inferior-Sqpe
+6-program-name
)
104 (inferior-ess-help-command .
"help(\"%s\")\n")
105 (inferior-ess-help-filetype .
"chm")
106 (inferior-ess-search-list-command .
"searchPaths()\n")
107 (inferior-ess-start-file . nil
) ;"~/.ess-S+6")
108 (inferior-ess-start-args .
(concat
109 ;; workaround for bug in S-Plus 6 for Windows:
112 inferior-Sqpe-start-args
;; e.g. license manager
117 "Variables to customize for Sqpe+6.")
121 ;;; There are extra complications in S+6 and S+7 and S+8 (compared to S+3)
124 ;;; (1) The StatSci supplied Splus.exe doesn't work in an emacs
125 ;;; buffer. It works as as a GUI window and we must send commands
126 ;;; to it through ddeclient. Nonetheless, we need to give it a
127 ;;; process name and be sure that that there is a valid running
128 ;;; process in the '(ddeESS [S+6])' buffer. Therefore we create an
129 ;;; ESS process in the buffer as a placeholder and start a shell
130 ;;; in the ESS buffer. From the shell we start Splus. Once Splus
131 ;;; finishes initializing and kills the original shell, we start
132 ;;; another shell. We have a buffer-local variable
133 ;;; inferior-ess-ddeclient, initialized to nil. When there is a
134 ;;; non-nil value of inferior-ess-ddeclient we send lines to
135 ;;; inferior-ess-ddeclient rather than to the Splus process.
136 ;;; (2) There is no Splus process running in the '(ddeESS [S+6])'
137 ;;; buffer. Therefore inferior-ess will never see a prompt,
138 ;;; unless we first change it to the null prompt "^". Then once
139 ;;; the process has started, we change it back.
140 ;;; (3) When M-x S+6 starts Splus by a shell command, then Splus is an
141 ;;; independent process and will be survive if the '(ddeESS [S+6])'
142 ;;; buffer is killed (or emacs is quit). The '(ddeESS [S+6])' is
143 ;;; made read-only and a warning is placed in it saying that "You
144 ;;; can't type anything here." Actually, if thestandalone Splus
145 ;;; is killed and the '(ddeESS [S+6])' is made writable (C-x C-q),
146 ;;; then '(ddeESS [S+6])' becomes a shell buffer.
148 (defun S+6 (&optional proc-name
)
149 "Verify that `inferior-S+6-program-name' points to S-Plus 6 or
150 S-Plus 7 or S-Plus 8. Start normally for S-Plus 6.1 and later.
151 Inform the user to start S-Plus 6.0 from the icon and then
152 connect to it with `S+6-existing'. Give an error message if
153 `inferior-S+6-program-name' doesn't point to S-Plus 6 or S-Plus 7
157 (set-buffer (find-file-noselect
158 (concat (executable-find inferior-S
+6-program-name
)
159 "/../../versions") t
))
162 (if (not (search-backward-regexp "splus\t[678].[0-9]" (point-min) t
))
163 (error "The emacs variable `inferior-S+6-program-name' does
164 not point to S-Plus 6 or 7 or 8. Please add `splus[678]?/cmd' (expand the
165 `[678]?' to match your setup) to your `exec-path' or specify the complete
166 path to `Splus.exe' in the variable `inferior-S+6-program-name' in your
169 (if (search-backward "splus\t6.0" (point-min) t
)
170 (error "S-Plus 6.0 for Microsoft Windows has a bug that
171 prevents it from being started by emacs. Instead, you must start it
172 by double-clicking an icon. Then you can connect to it with
173 `S+6-existing'. You should consider upgrading to a newer
174 release of S-Plus."))))
175 (S+6-initiate proc-name
)) ;; normal start ;
178 (defun S+6-initiate
(&optional proc-name
)
179 "Call 'S-PLUS [678].x for Windows', the 'GUI Thing' from StatSci. Put
180 S-Plus in an independent MS-Window (Splus persists even if the
181 '(ddeESS [S+6])' window is killed in emacs). Do this by creating a
182 comint process that calls sh. Send a shell command in that sh buffer
183 to call Splus. When it completes set up a shell as a placeholder in
184 the '(ddeESS [S+6])' buffer. The S-Plus options are correctly set.
185 In particular, the S-Plus Commands window is opened if the
186 Options/General Settings/Startup menu says it should be. There is a
187 startup delay of `ess-S+6-startup-delay' seconds during which the
188 screen will not be refreshed. This delay is here to allow slow disks
189 to start the Splus program."
192 (setq ess-customize-alist S
+6-customize-alist
)
193 (ess-write-to-dribble-buffer
194 (format "\n(S+6): ess-dialect=%s, buf=%s\n" ess-dialect
196 (setq ess-customize-alist
; change inferior-ess-program
197 (append ess-customize-alist
'((inferior-ess-program .
"sh"))))
198 (setq ess-customize-alist
; change inferior-ess-primary-prompt
199 (append ess-customize-alist
'((inferior-ess-primary-prompt .
"^"))))
200 (setq ess-customize-alist
; change inferior-ess-start-args
201 (append ess-customize-alist
'((inferior-ess-start-args .
"-i"))))
202 (let ((s-proj (getenv "S_PROJ")))
203 (cd (w32-short-file-name (directory-file-name default-directory
)))
204 (setenv "S_PROJ" default-directory
)
206 (sleep-for 2) ; need to wait, else working too fast! The Splus
207 ; command in '(ddeESS [S+6])' should follow the "$"
208 ; prompt. If not, then increase the sleep-for time!
209 (setenv "S_PROJ" s-proj
))
210 (setq ess-customize-alist S
+6-customize-alist
)
211 (ess-setq-vars-local ess-customize-alist
)
212 ;;; the next three lines belong in customize-alist, but can't be there
213 ;;; because of the broken ess-setq-vars-default usage in ess-inf.el
214 (setq inferior-ess-ddeclient
"ddeclient")
215 (setq inferior-ess-client-name
"S-PLUS")
216 (setq inferior-ess-client-command
"SCommand")
217 ;;; end of what belongs in customize-alist
218 (setq comint-process-echoes nil
)
219 (setq comint-input-sender
'comint-simple-send
)
220 (goto-char (point-max))
221 (insert (concat inferior-S
+6-program-name
" "
222 inferior-ess-start-args
)) ; Note: there is no final "&".
223 ;; Without the "&", the results of !system.command come to '(ddeESS [S+6])'
224 ;; With the "&", the results of !system.command in S get lost.
225 (inferior-ess-send-input)
226 (sleep-for ess-S
+6-startup-delay
) ; Need to wait, else working too fast!
227 ; If the ess-current-process-name doesn't appear in the
228 ; Splus Commands window increase the sleep-for time!
229 (setq ess-local-process-name ess-current-process-name
)
230 (ess-eval-linewise (concat "#" ess-current-process-name
))
231 (goto-char (point-min))
233 "This is a placeholder buffer. You can't type anything here.
234 Use `C-x b RET' to return to your file.\n
235 Anything sent to this process from an S-mode buffer goes
236 directly to the associated Splus Commands window.\n
237 The S-Plus Commands window must be visible.
238 You may need to open the S-Plus Commands window manually (by clicking on
239 Splus/Window/Commands Window).\n
240 Any results of the !system.command typed at the S prompt in the
241 Splus Commands window appear in this buffer.\n\n")
242 (goto-char (point-max)) ; comint-mode-map makes '(ddeESS [S+6])'
243 ;; (use-local-map comint-mode-map) ;a shell buffer after Splus is finished.
244 (set-buffer-process-coding-system 'raw-text-dos
'raw-text-unix
)
245 (toggle-read-only t
) ; force buffer to be read-only
246 (setq mode-name
"ddeESS")
247 ;; (ess-eval-linewise inferior-S+6-editor-pager-command)
248 (if inferior-ess-language-start
249 (ess-eval-linewise inferior-ess-language-start
))
255 (defun S+6-existing
(&optional proc-name
)
256 "Call 'S-PLUS [678].x for Windows', the 'GUI Thing' from StatSci. Do so by
257 finding an existing S-Plus in an independent MS-Window (if there is one) and
258 set up a '(ddeESS [S+6])' buffer in emacs. If there is no existing
259 S-Plus, then a new one will be opened in the default directory. The default
260 is usually something like 'c:/Program Files/Insightful/splus70/users/yourname'
261 for S-Plus before 8.0.4. Beginning with 8.0.4, S-Plus uses the default directory
262 'c:/Documents and Settings/yourname/My Documents/S-PLUS Projects/Project1'.
263 If you have a HOME environment variable, it will open it there."
265 (let* ((inferior-S+6-multipleinstances
" & # ") ; Note: there is a final "&".
266 (ess-S+6-startup-delay
0)) ;; No delay for existing S-Plus
267 ;; Without the "&", there is a core dump.
268 ;; With the "&", the results of !system.command in S get lost.
269 ;; We are picking up an existing S-Plus process for sending to.
270 ;; It doesn't know about us, so nothing comes back.
271 (S+6-initiate proc-name
))
273 (set-buffer (car (buffer-list))) ; get the ESS buffer just created
274 (toggle-read-only nil
) ; permit writing in ESS buffer
275 (goto-char (point-max))
279 "This is S+6-existing.
280 Results of the !system.command typed at the S prompt in the
281 Splus Commands window blink a DOS window and you won't see them.\n\n")
282 (toggle-read-only t
) ; restore ESS buffer to be read-only
286 ;;; There are extra complications in Sqpe+6 (compared to S+3) because
287 ;;; (1) The StatSci supplied Sqpe.exe won't work without SHOME as an
288 ;;; environment variable and Sqpe does not take command line
290 ;;; (2) Sqpe.exe comes up with options(interactive=F), which means it
291 ;;; doesn't provide prompts by default, and we must change it to T so
292 ;;; it will provide prompts.
294 (defun Sqpe+6 (&optional proc-name
)
295 "Call 'Sqpe' from 'S-PLUS [678].x for Windows', the 'Real Thing' from StatSci."
297 (setq ess-customize-alist Sqpe
+6-customize-alist
)
298 (let* ((shome-nil-p (equal (getenv "SHOME") nil
)))
299 (if shome-nil-p
(setenv "SHOME" inferior-Sqpe
+6-SHOME-name
))
300 (ess-write-to-dribble-buffer
301 (format "\n(Sqpe+6): ess-dialect=%s, buf=%s\n" ess-dialect
303 (setq ess-customize-alist
; change inferior-ess-primary-prompt
304 (append ess-customize-alist
'((inferior-ess-primary-prompt .
"^"))))
306 (setq ess-customize-alist Sqpe
+6-customize-alist
) ; restore i-e-p-p in alist
307 (ess-setq-vars-local ess-customize-alist
) ; restore i-e-p-p in buffer
308 (setq inferior-ess-prompt
; define with correct i-e-p-p
309 ;; Do not anchor to bol with `^' ; (copied from ess-inf.el)
311 inferior-ess-primary-prompt
313 inferior-ess-secondary-prompt
315 (setq comint-prompt-regexp
(concat "^" inferior-ess-prompt
))
316 ; define with correct i-e-p-p
317 (setq comint-input-sender
'inferior-ess-input-sender
)
318 (add-hook 'comint-output-filter-functions
'shell-strip-ctrl-m nil t
)
319 (goto-char (point-max))
320 (insert "options(interactive=T)")
321 (inferior-ess-send-input)
322 (setq mode-name
"iESS(Sqpe)")
323 ;; (ess-eval-linewise inferior-S+6-editor-pager-command)
324 (if inferior-ess-language-start
325 (ess-eval-linewise inferior-ess-language-start
))
326 (if shome-nil-p
(setenv "SHOME" nil
))))
330 (defun S+6-mode
(&optional proc-name
)
331 "Major mode for editing S+[678] source. See `ess-mode' for more help."
333 (setq ess-customize-alist S
+6-customize-alist
)
334 (ess-mode S
+6-customize-alist proc-name
)
335 (if ess-imenu-use-S
(ess-imenu-R)))
338 (defun S+6-transcript-mode
()
339 "S-PLUS 6.x transcript mode."
341 (ess-transcript-mode S
+6-customize-alist
))
344 (defun S+6-msdos
(&optional proc-name
)
345 "Verify that `inferior-S+6-program-name' points to S-Plus 6 or
346 S-Plus 7 or S-Plus 8. Start normally for S-Plus 6.1 and later.
347 Inform the user to start S-Plus 6.0 from the icon and then
348 connect to it with `S+6-msdos-existing'. Give an error message
349 if `inferior-S+6-program-name' doesn't point to S-Plus 6 or
350 S-Plus 7 or S-Plus 8."
353 (set-buffer (find-file-noselect
354 (concat (executable-find inferior-S
+6-program-name
)
355 "/../../versions") t
))
358 (if (not (search-backward-regexp "splus\t[678].[0-9]" (point-min) t
))
359 (error "The emacs variable `inferior-S+6-program-name' does
360 not point to S-Plus 6 or 7 or 8. Please add `splus[678]?/cmd'
361 (expand the `[678]?' to match your setup) to your `exec-path' or
362 specify the complete path to `Splus.exe' in the variable
363 `inferior-S+6-program-name' in your `.emacs' file.")
366 (if (search-backward "splus\t6.0" (point-min) t
)
367 (error "S-Plus 6.0 for Microsoft Windows has a bug that
368 prevents it from being started by emacs. Instead, you must start it
369 by double-clicking an icon. Then you can connect to it with
370 `S+6-msdos-existing'. You should consider upgrading to a newer
372 (S+6-msdos-initiate proc-name
))) ;; normal start ;
376 (defun S+6-msdos-initiate
(&optional proc-name
)
377 "Call 'S-PLUS [678].x for Windows', the 'GUI Thing' from StatSci. Put
378 S-Plus in an independent MS-Window (Splus persists even if the
379 '(ddeESS [S+6])' window is killed in emacs). Do this by creating a
380 comint process that calls sh. Send a shell command in that sh buffer
381 to call Splus. When it completes set up a shell as a placeholder in
382 the '(ddeESS [S+6])' buffer. The S-Plus options are correctly set.
383 In particular, the S-Plus Commands window is opened if the
384 Options/General Settings/Startup menu says it should be. There is a
385 startup delay of `ess-S+6-startup-delay' seconds during which the
386 screen will not be refreshed. This delay is here to allow slow disks
387 to start the Splus program."
390 (setq ess-customize-alist S
+6-customize-alist
)
391 (ess-write-to-dribble-buffer
392 (format "\n(S+6): ess-dialect=%s, buf=%s\n" ess-dialect
394 (setq ess-customize-alist
; change inferior-ess-program
395 (append ess-customize-alist
'((inferior-ess-program
396 .
(getenv "COMSPEC")))))
397 (setq ess-customize-alist
; change inferior-ess-primary-prompt
398 (append ess-customize-alist
'((inferior-ess-primary-prompt .
"^"))))
399 (setq ess-customize-alist
; change inferior-ess-start-args
400 (append ess-customize-alist
'((inferior-ess-start-args .
""))))
401 (let ((s-proj (getenv "S_PROJ")))
402 (cd (w32-short-file-name (directory-file-name default-directory
)))
403 (setenv "S_PROJ" default-directory
)
405 (sleep-for 2) ; need to wait, else working too fast! The Splus
406 ; command in '(ddeESS [S+6])' should follow the "$"
407 ; prompt. If not, then increase the sleep-for time!
408 (setenv "S_PROJ" s-proj
))
409 (setq ess-customize-alist S
+6-customize-alist
)
410 (ess-setq-vars-local ess-customize-alist
)
411 ;;; the next three lines belong in customize-alist, but can't be there
412 ;;; because of the broken ess-setq-vars-default usage in ess-inf.el
413 (setq inferior-ess-ddeclient
"ddeclient")
414 (setq inferior-ess-client-name
"S-PLUS")
415 (setq inferior-ess-client-command
"SCommand")
416 ;;; end of what belongs in customize-alist
417 (setq comint-input-sender
'comint-simple-send
)
418 (setq comint-process-echoes nil
)
419 (set-buffer-process-coding-system 'raw-text-dos
'raw-text-dos
)
420 (goto-char (point-max))
421 (insert (concat inferior-S
+6-program-name
" "
422 inferior-ess-start-args
)) ; Note: there is no final "&".
423 ;; Without the "&", the results of !system.command come to '(ddeESS [S+6])'
424 ;; With the "&", the results of !system.command in S get lost.
425 (inferior-ess-send-input)
426 (sleep-for ess-S
+6-startup-delay
) ; Need to wait, else working too fast!
427 ; If the ess-current-process-name doesn't appear in the
428 ; Splus Commands window increase the sleep-for time!
429 ;;; from msdos-minor-mode
430 (setq comint-process-echoes t
)
431 (add-hook 'comint-output-filter-functions
'shell-strip-ctrl-m nil t
)
432 ;;; end from msdos-minor-mode
433 (setq ess-local-process-name ess-current-process-name
)
434 (ess-eval-linewise (concat "#" ess-current-process-name
))
435 (goto-char (point-min))
437 "This is a placeholder buffer. You can't type anything here.
438 Use `C-x b RET' to return to your file.\n
439 Anything sent to this process from an S-mode buffer goes
440 directly to the associated Splus Commands window.\n
441 The S-Plus Commands window must be visible.
442 You may need to open the S-Plus Commands window manually
443 (by clicking on Splus/Window/Commands Window).\n
444 There is a `ess-S+6-startup-delay' second delay when this program starts
445 during which the emacs screen will be partially blank.\n
446 Remember to 'q()' from S-Plus and
447 then C-x C-q exit from the '(ddeESS [S+6])' buffer,
448 or take the risk of not being able to shut down your computer
449 and suffering through scandisk.\n
450 Any results of the !system.command typed at the S prompt in the
451 Splus Commands window (are supposed to) appear in this buffer.\n\n")
452 (goto-char (point-max)) ; comint-mode-map makes '(ddeESS [S+6])'
453 (use-local-map comint-mode-map
) ; a shell buffer after Splus is finished.
454 (toggle-read-only t
) ; force buffer to be read-only
455 (setq mode-name
"ddeESS")
456 ;; (ess-eval-linewise inferior-S+6-editor-pager-command)
457 (if inferior-ess-language-start
458 (ess-eval-linewise inferior-ess-language-start
))
461 (defun S+6-msdos-existing
(&optional proc-name
)
462 "Call 'S-PLUS [678].x for Windows', the 'GUI Thing' from StatSci. Do so by
463 finding an existing S-Plus in an independent MS-Window (if there is one) and
464 set up a '(ddeESS [S+6])' buffer in emacs. If there is no existing
465 S-Plus, then a new one will be opened in the default directory. The default
466 is usually something like 'c:/Program Files/Insightful/splus70/users/yourname'
467 for S-Plus before 8.0.4. Beginning with 8.0.4, S-Plus uses the default directory
468 'c:/Documents and Settings/yourname/My Documents/S-PLUS Projects/Project1'.
469 If you have a HOME environment variable, it will open it there."
471 (let* ((inferior-S+6-multipleinstances
"")
472 (ess-S+6-startup-delay
0)) ;; No delay for existing S-Plus
473 (S+6-msdos-initiate proc-name
))
475 (set-buffer (car (buffer-list))) ; get the ESS buffer just created
476 (toggle-read-only nil
) ; permit writing in ESS buffer
477 (goto-char (point-max))
481 "This is S+6-msdos-existing.
482 Results of the !system.command typed at the S prompt in the
483 Splus Commands window blink a DOS window and you won't see them.\n\n")
484 (toggle-read-only t
) ; restore ESS buffer to be read-only
487 (defun ess-sqpe-versions-create ()
488 "Generate the `M-x splusxy' functions for starting other versions of
489 Sqpe. See `ess-sqpe-versions' for strings that determine which
490 functions are created. This works by creating a temp buffer where the
491 template function `Sqpe+template' is edited by replacing the string
492 'Sqpe+template' by the version name. The list of functions actually
493 created appears in the *ESS* buffer.
495 The result `ess-sqpe-versions-created' will store a list of the new
496 Sqpe defuns, if any, that were created. The defuns will normally be
497 placed on the menubar upon ESS initialisation."
501 (eval-buf (get-buffer-create "*ess-temp-sqpe-evals*"))
502 (ess-sqpe-versions-created)
506 (set-buffer eval-buf
)
508 (delete-region (point-min) (point-max))
510 ;; Find which versions of Sqpe we want.
511 (setq versions
(ess-uniq-list ess-SHOME-versions
))
512 ;; Iterate over each string in VERSIONS, creating a new defun each time.
514 (setq version
(car versions
)
515 versions
(cdr versions
))
516 (if (file-executable-p version
)
519 (prin1 (symbol-function 'Sqpe
+template
) eval-buf
)
522 (while (search-forward "lambda" nil t
1)
524 (concat "defun " (file-name-nondirectory version
))
526 (while (search-forward "ess-SHOME" nil t
)
527 (replace-match version t t
))
528 (goto-char (point-max))
529 (setq ess-sqpe-versions-created
530 (cons (file-name-nondirectory version
)
531 ess-sqpe-versions-created
))
532 (ess-write-to-dribble-buffer
534 "(Sqpe): ess-sqpe-versions-create making M-x defun %s for %s \n"
535 (file-name-nondirectory version
) version
))
537 ;; buffer has now been created with defuns, so eval them!
539 (kill-buffer eval-buf
))
540 ess-sqpe-versions-created
))
542 ;; template function used by ess-sqpe-versions-create
543 (defun Sqpe+template
(&optional proc-name
)
544 "Call 'Sqpe' from 'S-PLUS for Windows ess-SHOME',
545 the 'Real Thing' from StatSci.
546 This function was generated by `ess-sqpe-versions-create'."
548 (setq ess-customize-alist Sqpe
+6-customize-alist
)
549 (let* ((use-dialog-box) ;; MS dialog box won't return a directory
550 (shome-old (getenv "SHOME"))
551 (inferior-Sqpe+6-SHOME-name
"ess-SHOME")
552 (inferior-Sqpe+6-program-name
(concat "ess-SHOME" "/cmd/sqpe.exe")))
553 (setenv "SHOME" "ess-SHOME")
554 (ess-write-to-dribble-buffer
555 (format "\n(Sqpe+template): ess-dialect=%s, buf=%s\n" ess-dialect
557 (setq ess-customize-alist
; change inferior-ess-primary-prompt
558 (append ess-customize-alist
559 '((inferior-ess-primary-prompt .
"^"))))
561 (setq ess-customize-alist Sqpe
+6-customize-alist
) ; restore i-e-p-p in alist
562 (ess-setq-vars-local ess-customize-alist
) ; restore i-e-p-p in buffer
563 (setq inferior-ess-prompt
; define with correct i-e-p-p
564 ;; Do not anchor to bol with `^' ; (copied from ess-inf.el)
566 inferior-ess-primary-prompt
568 inferior-ess-secondary-prompt
570 (setq comint-prompt-regexp
(concat "^" inferior-ess-prompt
))
571 ; define with correct i-e-p-p
572 (setq comint-input-sender
'inferior-ess-input-sender
)
573 (add-hook 'comint-output-filter-functions
'shell-strip-ctrl-m nil t
)
574 (goto-char (point-max))
575 (insert "options(interactive=T)")
576 (inferior-ess-send-input)
577 (setq mode-name
"iESS(Sqpe)")
578 ;; (ess-eval-linewise inferior-S+6-editor-pager-command)
579 (if inferior-ess-language-start
580 (ess-eval-linewise inferior-ess-language-start
))
581 (setenv "SHOME" shome-old
)))
588 \f ; Local variables section
590 ;;; This file is automatically placed in Outline minor mode.
591 ;;; The file is structured as follows:
594 ;;; Subsections: ;;;*;;;
595 ;;; Components: defuns, defvars, defconsts
596 ;;; Random code beginning with a ;;;;* comment
600 ;;; outline-minor-mode: nil
601 ;;; mode: outline-minor
602 ;;; outline-regexp: "\^L\\|\\`;\\|;;\\*\\|;;;\\*\\|(def[cvu]\\|(setq\\|;;;;\\*"
605 ;;; essd-sp6w.el ends here