3 ESS: Using S-Plus 4.x for Windows
4 =================================
6 (also see detailed help at the end, for more information)
8 Beginning with ESS 5.1.2 we are able to use inferior iESS mode to
9 communicate directly with a running S-Plus 4.x process using the
10 Microsoft DDE protocol. We use the familiar (from Unix ESS) C-c C-n
11 and related key sequences to send lines from the S-mode file to the
12 inferior S process. We continue to edit S input files in ESS[S] mode
13 and transcripts of previous S sessions in ESS Transcript mode. All
14 three modes know the S language, syntax, and indentation patterns and
15 provide the syntactic highlighting that eases the programming tasks.
17 ESS (originally S-mode) was initially designed for use with S and
18 S-PLUS(tm) on the Unix computers with interprocess communication using
19 the Unix standard input and standard output protocols. S-Plus 4.x was
20 designed for the Microsoft Windows 95/98/NT and uses DDE as the
21 interprocess communications protocol. The protocols are very
24 See the document README.S for detailed information on:
25 - general Emacs features.
29 - Scenarios for use (possibilities, based on actual usage)
31 The following are not identical in MS Windows to the similarly named
32 sections in README.S and are covered in this document:
33 - running an S process as an inferior process to Emacs
34 - ESS-help: assistance with viewing help
40 The easiest way to install ESS on Windows machines is to place the
41 unzipped directory tree on the machine in, for specificity,
43 Then add the following line to your ~/_emacs (or ~/.emacs) file:
44 (load-file "c:/emacs/ess-5.1.21/lisp/ess-site.el")
46 For improved startup efficiency (but not execution efficiency) you can
47 follow the more elaborate installation procedures described in
48 README.S. These procedures depend on your already having installed
49 /bin/sh and make, programs that come with the Unix-like utilities from
51 http://sourceware.cygnus.com/cygwin/
54 iESS: Inferior ESS processes
55 ============================
57 iESS (inferior ESS) is the mode for interfacing with active
58 statistical processes (programs). This mode behaves very differently
59 with S-Plus 4.x for Windows than it does for the Unix versions of
62 S-Plus 4.x for Windows is full-featured Windows program. It has GUI
63 subwindows, icons, menus, buttons, and Windows-style interprocess
64 communication. By contrast Unix versions of S-Plus have only the
65 equivalent of the Commands window (running in an ordinary xterm (or
66 other shell window)) and the Graphics windows.
68 iESS for S-Plus 4.x is completely compatible with all the Windows
69 features. At this time it has been used extensively with NTemacs 20.3.l
70 http://www.cs.washington.edu/homes/voelker/ntemacs.html
71 http://www.cs.washington.edu/homes/voelker/ntemacs/ftp/
72 iESS uses the ddeclient program included as part of the NTemacs distribution.
73 We recommend that the user install bash as the shell under emacs.
74 http://sourceware.cygnus.com/cygwin/
75 Our programs do work should the user choose to use one of the Windows
76 shells (command.com on 95/98, or cmd.exe on NT).
78 The starting key sequence depends on the shell the user prefers:
80 bash users: The S-Plus user starts S-Plus from within emacs with
81 "M-x S" (or with "M-x S+4").
83 msdos users: The S-Plus user starts S-Plus from within emacs with
84 "M-x S+4-msdos". msdos users MUST remember to close S-Plus cleanly
85 and then close the *S+4 ddeclient* buffer with `exit', or take the
86 risk of not being able to shut down the computer cleanly.
88 Either of these emacs command sequences starts the usual S-Plus 4.x
89 window. There may be a slight delay before the emacs window can be
90 used. The S-Plus window must have a visible Commands window placed on
91 the left side of the S-Plus window. We recommend placing the S-Plus
92 window on the left side of the screen and the emacs window on the
93 right side of the screen. This placement permits activity in the
94 S-Plus commands window to be monitored while lines are sent over from
95 the active emacs window.
97 The user then sends individual lines or groups of lines to the S-Plus
98 process using the emacs command C-c C-n (for lines), C-c C-r (for
99 regions), C-c C-b (for the entire buffer). The lines magically appear
100 in the S-Plus Commands window, as if they had been typed manually or
101 been sent by mouse copy and paste commands. The results of the
102 commands appear in the S-Plus Commands window. No results come back
103 to the emacs process (this is the major difference between the Unix
104 and Windows actions of ESS).
106 An entire file can be sent over with C-c C-l. In this case, only the
107 command `source("filename")' appears in the S-Plus Commands window.
108 No input statements or output from the commands appear. All global
109 assignments have been made.
111 In order to create an S transcript it is necessary to
113 (1) highlight a region in the S-Plus Commands window (the easiest way
114 is to use the Ctrl+A keystroke or the "Edit/Select All" menu
115 command) and then copy Ctrl+C it. Ctrl+C is a standard Windows
118 (2) open an ESS Transcript file, for example myfile.st, in emacs. The
119 suffix ".st" stands for S Transcript. When a myfile.st file is
120 created or read it always comes in as a read-only file. This is a
121 protection to keep the user from accidentally changing an
122 historical file. Make it writable with C-x C-q and the paste the
123 copied region using C-y (the standard emacs yank command (which
124 corresponds to the Windows paste)).
126 Caution: switching from the emacs window to the S-Plus window causes
127 finger confusion as the keystroke commands are not the same.
129 Once the transcript has been created in an emacs buffer it has most of
130 the standard iESS (inferior ESS) mode features, including sending
131 lines back to the active statistical process (program). This features
134 - proper indenting, generated by both [Tab] and [Return].
135 - color and font highlighting based on syntax.
136 - ability to resubmit the contents of a multi-line command
137 to the executing process with a single keystroke [RET].
138 - transcript recording and editing
141 Optional Ways to Start S-Plus 4.x with emacs
142 ============================================
144 1. If you already have an S-Plus 4.x window and wish to add emacs
145 access to that window, then you can start an emacs iESS buffer with
146 "M-x S+4-existing" (bash users) or "M-x S+4-msdos-existing" (msdos users).
148 2. If you really like the S-Plus to run inside an emacs *S+4* buffer,
149 just the way it does in Unix, then you can start an emacs iESS
150 buffer with "M-x Sqpe+4". There is no interactive graphics
151 available in this arrangement. Postscript graphics to a file are
152 available. None of the GUI menus and buttons are available.
155 ESS-help: assistance with viewing help
156 ======================================
158 The key sequence C-c C-v entered from any ESS buffer sends a help
159 request to the running S-Plus. Help files in S-Plus 4.x for StatSci
160 distributed functions use the Windows Help mechanism. They do not
161 appear in emacs buffers.
164 Recommended Settings on first use of a new _Data directory
165 ==========================================================
167 The first time you use S-Plus in a new directory you must do some setup.
169 - Click Window/Commands Window
171 - Click Options/General Settings/Startup.
172 Click Select Data Dialog off.
173 Click Command Line on.
174 Click Object Browser on.
176 Assuming you have downloaded and are using the gnuserv/gnuclient
178 http://www.cs.washington.edu/homes/voelker/ntemacs/contrib/gnuserv.zip
179 - Click Options/General.Settings/Computations.
180 Change Editor to gnuclient.
181 Change Pager to gnuclientw.
182 Note these are different. The behavioral difference is that gnuclient
183 will freeze S-Plus until "C-x #" is typed to the emacs buffer.
184 This is the correct behavior when you are using the S function edit().
185 With emacs as your editor, you are less likely to need the edit() function.
187 - Click Options/Command Line Options/Options/Key Scroll/Page Keys.
189 - Click Options/Graph Options/Options/Auto Pages/Every Graph.
191 - Click Options/"Save Window Size/Properties as Default"
194 History of M-x S+4 and related functions
195 ========================================
197 In May 1998, Brian Ripley wrote an early version of an interface
198 between ESS and S-Plus using the DDE concept. The original version
199 demonstrated feasability of the concept. It was limited to a single
200 line (that is, C-c C-n worked correctly when the S statement was
201 complete on a single line). The region and buffer commands C-c C-r
202 and C-c C-b did not work.
204 In December 1998, Richard Heiberger completely rewrote the DDE
205 interaction to use the ddeclient program that was first distributed
206 with NTemacs 20.3.1. He further developed the remaining functions
207 to the point where all ESS functions now work with S-Plus 4.x on the
208 Windows operating systems.
211 Detailed Help For S-PLUS 2000 and the License Manager
212 (Thanks to David Brahm, <brahm@alum.mit.edu>)
213 =====================================================
215 Found the solution to getting Sqpe-mode to work with the license manager - I
216 set S_ELMHOST in Emacs with (setenv "S_ELMHOST" "123.45.67.890"), instead of
217 trying to make it a command-line argument. Thus I was also able to reduce
218 the number of modifications to "essd-sp4.el". I still change the delay time
219 by hand (from 30 seconds to 10); I wish this were a variable so I could just
220 put (setq-default inferior-ess-delay 10) in my .emacs.
222 I've attached my new installation instructions, with these modifications.
226 How to Install S-Plus, Emacs, ESS, and Cygwin on NT. (David Brahm 11/9/99)
229 >From MathSoft <http://www.mathsoft.com/splus> (800)569-0123
230 Desktop icon "C:\Program Files\sp2000\cmd\splus.exe" u:/splus/init.s
231 s_proj=p:/home/s s_elmhost=123.45.67.890
233 U:/Splus/init.s contains:
234 library("Lib", first=T, lib.loc="u:\\Splus")
235 U:/Splus/Lib contains directories: _Data, _Prefs, Flat, and Source
236 Resize S-Plus window to match Emacs window.
237 In Options > General > Startup, check "Command Line"
238 Options > "Save Window Size/Properties as Default"
241 <ftp://ftp.gnu.org/gnu/windows/emacs/latest> get "em2041.zip"
242 <http://www.gnu.org/software/emacs/windows/ntemacs.html> for FAQ
243 Extract (with WinZip) to C:\, thus creating C:/emacs-20.4
244 Double-click on C:/emacs-20.4/bin/addpm.exe, copy icon to desktop.
245 In "Emacs" icon shortcut, change to Start in P:/Home
246 Create file C:/emacs-20.4/site-lisp/site-start.el (see below).
247 User can put additional customization in P:/Home/.emacs
250 <http://ess.stat.wisc.edu/> get "ess-5.1.21.zip"
251 Extract to C:\emacs-20.4, thus creating C:/emacs-20.4/ess-5.1.21
252 In C:/emacs-20.4/ess-5.1.21/lisp/essd-sp4.el:
253 Change (sleep-for 30) to (sleep-for 10) (twice)
256 <http://sourceware.cygnus.com/cygwin/> get "full.exe" (or "usertools.exe")
257 Double-click on full.exe and accept all defaults, installing to C:/Cygnus
258 Make directories C:/bin and C:/tmp
259 Copy C:/Cygnus/Cygwin-B20/H-i586-cygwin32/bin/sh.exe to C:/bin
260 Right-click My Computer > Properties > Environment, and append this to Path:
261 ";c:\bin;c:\Cygnus\Cygwin-B20\H-i586-cygwin32\bin"
262 *or* put this line into C:/autoexec.bat:
263 set PATH=c:\bin;c:\Cygnus\Cygwin-B20\H-i586-cygwin32\bin
264 W95/98 only: If an error "Out of environment space" occurs, add to
266 shell=C:\command.com /e:4096 /p
269 Here is my site-start.el file:
270 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
272 (setenv "HOME" "P:/Home")
274 "C:/Cygnus/Cygwin-b20/H-i586-cygwin32/bin;C:/Progra~1/sp2000/cmd")
276 ; ESS and customization:
277 (load "C:/Emacs-20.4/ess-5.1.21/lisp/ess-site")
278 (setenv "SHELL" "C:/Cygnus/Cygwin-b20/H-i586-cygwin32/bin/bash")
279 (setenv "S_ELMHOST" "123.45.67.890")
280 (setenv "S_FIRST" "source(\"U:/Splus/init.s\")") ; Initialization file
281 (setenv "SHOME" "C:/Progra~1/sp2000")
282 (setq-default inferior-Sqpe+4-program-name "c:/Progra~1/sp2000/cmd/Sqpe")
283 (setq ess-ask-for-ess-directory nil)
284 (setq ess-directory "P:/Home/S/")
285 (setq ess-execute-in-process-buffer t)
286 (make-local-variable 'comment-indent-function)
287 (setq-default comment-indent-function 'ess-comment-indent)
288 (fset 'run-s "\C-x2\M-xS\C-m")
289 (global-set-key "\M-s" 'run-s) ; ESC-s runs "run-s" which starts S
292 (set-frame-size (selected-frame) 80 56)
295 (setq-default auto-fill-function 'do-auto-fill)
296 (setq-default fill-column 79)
298 ; Macros and set-keys:
299 (global-set-key "\C-u" 'query-replace-regexp)
301 (defun flat (tabw) "Turns off line-wrap; prefix sets tab width."
303 (turn-on-hscroll) ; (setq truncate-lines 1)
304 (if (> tabw 1) (setq tab-width tabw))
306 (global-set-key "\C-c\C-f" 'flat)
308 ; Fonts (uncomment the next line for a bolder font):
309 ; (set-default-font "-adobe-courier-bold-r-normal--*-140-*-*-m-*-iso8859-1")
310 (global-font-lock-mode t)
311 (custom-set-variables)
313 '(font-lock-comment-face
314 ((((class color) (background light)) (:foreground "Firebrick"))))
315 '(font-lock-string-face
316 ((((class color) (background light)) (:foreground "SeaGreen"))))
317 '(font-lock-keyword-face
318 ((((class color) (background light)) (:foreground "MediumBlue"))))
319 '(font-lock-constant-face
320 ((((class color) (background light)) (:foreground "VioletRed"))))
321 '(font-lock-type-face
322 ((((class color) (background light)) (:foreground "Goldenrod"))))
323 '(font-lock-variable-name-face
324 ((((class color) (background light)) (:foreground "Blue"))))
325 '(font-lock-function-name-face
326 ((((class color) (background light)) (:foreground "VioletRed"))))