
@node Unix installation, Microsoft Windows installation, , Installation
@comment  node-name,  next,  previous,  up
@section Unix installation

@enumerate

@item

@code{cd} to a directory where you keep emacs lisp files, or create a
new directory (for example, @file{$HOME/ess}) to hold the distribution.
This directory will be referred to below as "the ESS distribution
directory".  

@emph{Note for XEmacs packages:} ESS is no longer available as an XEmacs package.  
But, you can still install ESS into the XEmacs package system by choosing
@file{ESSDIR}=@file{PREFIX/lib/xemacs/site-packages}.
ESS requires that the XEmacs sumo tarball (all XEmacs packages combined) also
be installed.  For information on installing XEmacs packages, follow this link: 
@uref{http://www.xemacs.org/Documentation/packageGuide.html, Quickstart Package Guide}.

@comment It will contain,
@comment at the end, the tar file @file{ess-VERSION.tar.gz}, and a directory for
@comment the ESS source, which will be termed "the ESS-VERSION source directory".
@comment Note that the .elc files may be installed elsewhere (as specified in the
@comment Makefile) if desired.

@item
Retrieve the latest version from
@uref{http://ess.r-project.org/downloads/ess, ESS downloads area}
to @file{ESSDIR}.

@item
Extract the files from the disribution.
@display
If you are using GNU tar, @code{tar zxf ess-VERSION.tgz}.
Otherwise, @code{gunzip < ess-VERSION.tgz | tar xf -},
@end display

The @code{tar} command will create the subdirectory @file{ess-VERSION} and install
the files there.

@comment If you are using GNU Emacs 19.29, decompress/unarchive
@comment @file{ESSDIR/ess-VERSION/lisp/19.29.tar.gz},
@comment read @file{ESSDIR/ess-VERSION/lisp/19.29/README}, follow the instructions
@comment and you might be able to get ESS to work.
@comment @emph{Please note that GNU Emacs 19.29 is no longer supported}.
@comment For a list of supported versions of emacs, see @xref{Requirements}.

@item
Edit the file @file{ESSDIR/ess-VERSION/lisp/ess-site.el} as explained in the
comments section of that file.
@comment Installations that are using ESS only for S-Plus
@comment 6.x will probably not need to make any changes.  Installations that also
@comment have one or more of (S4, S+3/4/5/6/7/8, R, SAS, BUGS, XLispStat, Stata)
@comment may need to uncomment corresponding lines in @file{ESSDIR/ess-VERSION/lisp/ess-site.el}.

@item
If you are using GNU Emacs add the line
@example
(load "ESSDIR/ess-VERSION/lisp/ess-site")
@end example
to @file{$HOME/.emacs}.  For XEmacs, if you followed the XEmacs package system
installation advice, add the line
@example
(require 'ess-site)
@end example
to @file{$HOME/.xemacs/init.el}.  Otherwise, for XEmacs, add the line
@example
(load "ESSDIR/ess-VERSION/lisp/ess-site")
@end example
to @file{$HOME/.xemacs/init.el}.  
  
@comment GNU Emacs uses @file{default.el} or
@comment @file{site-init.el} and XEmacs uses @file{site-start.el} for the system
@comment installation file).
@comment Alternatively, if @file{ess-site.el} is in your current @code{load-path}, then:
@comment @example
@comment (require 'ess-site)
@comment @end example
@comment to configure emacs for ESS.

@item
That's it!  ESS is now ready to use.  (The remaining step below is only for a
custom installation.)  To edit statistical programs, just open files with the
requisite extensions (@file{.R} for R, @file{.sas} for SAS, @file{.bug} for BUGS,
etc.).  To start a statistical process within emacs, such as R, type @code{M-x R}.

@c @item
@c (OPTIONAL) If you are running S-PLUS or R, you might consider
@c installing the database files.  From within emacs, @code{C-x d} to the
@c directory containing ESS.  Now:
@c @example
@c M-x S+6
@c @end example
@c to get S running.  Once you see the SPLUS prompt, do:
@c @example
@c M-x ess-create-object-name-db
@c @end example
@c (this will create the file @file{ess-sp6-namedb.el}; if it isn't in the
@c ESS directory, move it there).

@c Then, completions will be autoloaded and will not be regenerated for
@c every session.

@c For R, do the same, using
@c @example
@c M-x R
@c @end example
@c and then @code{M-x ess-create-object-name-db} creating
@c @file{ess-r-namedb.el}; if it isn't in the ESS directory, move it there).

@item
@b{(OPTIONAL) READ THIS ITEM THOROUGHLY BEFORE STARTING}:

If you want to place the compiled files in other locations edit the
@code{LISPDIR}, @code{INFODIR} and @code{ETCDIR} entries in Section 1 of
@file{Makeconf} in the @file{ESSDIR/ess-VERSION} directory (if you are
using XEmacs, then uncomment the XEmacs subsection in Section 1).

You can compile those files by:
@example
make all
@end example

When that completes successfully, install the compiled files:
@example
make install
@end example

@c This will install the compiled info files and lisp files.  If you are an
@c XEmacs user, then you should be done.  If not, then you may have to
@c edit/create the file @file{dir} that is found in the directory specified
@c by @code{INFODIR}: see the sample @file{dir} in ESSDIR/ess-VERSION/doc/info.
@c If @file{dir} does not exist in @code{INFODIR}, then the sample
@c @file{dir} will be installed.


@comment An alternative, if you are running XEmacs and have access to the
@comment XEmacs system directories, would be to place the directory in the
@comment site-lisp directory, and simply type @code{make all} (and copy the
@comment documentation as appropriate).
@comment
@comment For GNU Emacs, you would still have to move the files into the top level
@comment site-lisp directory.

@end enumerate

@c >>>> FIXME (see comment in ess.texi): error in ``makeinfo readme.texi''
@c @node Microsoft Windows installation, , Unix installation, Installation
@node Microsoft Windows installation, Requirements, Unix installation, Installation
@comment  node-name,  next,  previous,  up
@section Microsoft Windows installation

For @b{Microsoft Windows installation}, please follow the next steps.

@enumerate

@item
@code{cd} to a directory where you keep emacs lisp files, or create a
new directory (for example, @file{c:\ess\}) to hold the distribution.
This directory will be referred to below as "the ESS distribution
directory".  

@emph{Note for XEmacs packages:} ESS is no longer available as an XEmacs
package. But, you can still install ESS into the XEmacs package system
by choosing @file{ESSDIR}=@file{PREFIX\XEmacs\site-packages}.  ESS
requires that the XEmacs sumo tarball (all XEmacs packages combined)
also be installed.  For information on installing XEmacs packages,
follow this link:
@uref{http://www.xemacs.org/Documentation/packageGuide.html, Quickstart
Package Guide}.

@item
Retrieve the latest zip file (@file{ess-VERSION.zip}) from
@uref{http://ess.r-project.org/downloads/ess, ESS downloads area} and
store it in the ESS distribution directory.  Be aware that http browsers
on Windows frequently change the "." and "-" characters in filenames to
other punctuation.  Please change the names back to their original form.

@item
Extract all the files from @file{ess-VERSION.zip} into the ESS
distribution directory as @file{c:\ess\ess-VERSION\}.  (It is possible
to unpack the zip archive in Windows Explorer by double clicking on the
folder; you should then see a new folder called @file{ess-VERSION}.
Drag that folder into your ESS distribution directory.)

@comment @item
@comment Add the line
@comment @example
@comment (load "C:/emacs/ess-VERSION/lisp/ess-site")
@comment @end example
@comment to your emacs initialization file.  (GNU Emacs uses the filename
@comment @file{~/.emacs} and XEmacs uses the filename
@comment @file{~/.xemacs/init.el} for the initialization file.  The tilde is
@comment recognised by emacs as your HOME directory, i.e. the value of your HOME
@comment environment variable.)  Replace
@comment @code{VERSION} above with the version number of ESS.  Remember to use
@comment forwardslashes @code{/}, rather than backslashes @code{\}, in your filename
@comment inside emacs code files.

@item
If you are using GNU Emacs add the line
@example
(load "ESSDIR/ess-VERSION/lisp/ess-site")
@end example
to @file{%HOME%\.emacs}.  For XEmacs, if you followed the XEmacs package system
installation advice, add the line
@example
(require 'ess-site)
@end example
to @file{%HOME%\.xemacs\init.el}.  Otherwise, for XEmacs, add the line
@example
(load "ESSDIR/ess-VERSION/lisp/ess-site")
@end example
to @file{%HOME%\.xemacs\init.el}.  
@emph{Note:} Both GNU Emacs and XEmacs require that the HOME environment
variable be set on your system, otherwise, your initialization file will
not be utilized, and therefore, ESS will not work.

After saving your initialization file, ESS is now installed.  Start a
new emacs and you should be ready to use ESS.  For example, to edit
statistical programs, load the files with the requisite extensions
(".sas" for SAS, ".S" or "s" or "q" or "Q" for S-PLUS, ".r" or ".R" for
R, and ".lsp" for XLispStat).  One further step is needed if you wish to
run statistical processes, see below.

@item
To run statistical processes under ESS, Windows users will need to make
sure that the directories for the software they will be using is in the
PATH environment variable.  On Windows 9x, add lines similar to the
following to your @file{c:\autoexec.bat} file:
@example
path=%PATH%;c:\progra~1\insightful\splus70\cmd
@end example
On Windows NT/2000/XP, add the directories to the PATH using the
@code{My Computer/Control Panel/System/Advanced/Environment Variables} menu.
Note that the directory containing the program is
added to the PATH, not the program itself.  One such line is needed
for each software program.  Be sure to use the abbreviation
@code{progra~1} and not the long version with embedded blanks.  Use
backslashes "@code{\}".

An alternative, for R users, is that rather than adjusting the PATH
variable, you can add the following to your emacs initialization file
(and restart emacs):
@example
(setq inferior-R-program-name "c:/progra~1/R/R-2.2.1/bin/Rterm.exe")
@end example
This assumes that you have installed R-2.2.1 in the default location.
Change the path otherwise to point to other locations.

Windows users who place S-PLUS anywhere other than the default
location will also need to add the following three lines (properly
adjusted for their location) to their @file{%HOME%\.emacs} or
@file{%HOME%\.xemacs\init.el} file:
@example
(setq-default inferior-S+6-program-name
    "c:/progra~1/Insightful/SPLUS70/cmd/Splus")
(setq-default inferior-Sqpe+6-SHOME-name
    "c:/progra~1/Insightful/SPLUS70")
(setq-default inferior-Sqpe+6-program-name
    "c:/progra~1/Insightful/SPLUS70/cmd/Sqpe.exe")
@end example
The above example uses the default location of S-PLUS in
@code{c:\progra~1\Insightful}.  Please note that ESS
considers S-PLUS 6, 7, and 8 to be variants of S+6.

These users may also need to modify the emacs variable @code{ess-SHOME-versions}
to match their installation in order to get the full set of S-PLUS versions
on their machine into the @code{ESS} menu.
 
To start the S-PLUS [678].x GUI from ESS under emacs:
@enumerate
@item
If you use Cygwin bash as your primary shell, then
@example
M-x S
(or @code{M-x S+6}).
@end example
@item
If you use the MSDOS prompt window as your primary shell, then
@example
M-x S+6-msdos
@end example
@end enumerate
You will then be
asked for a pathname ("S starting data directory?"), from which to
start the process.  The prompt will propose your current directory
as the default.  ESS will start the S-PLUS GUI.  There will be
slight delay during which emacs is temporarily frozen.  ESS will arrange for
communication with the S-PLUS GUI using the DDE protocol.
Send lines or regions
from the emacs buffer containing your S program (for example,
@file{myfile.s}) to the S-PLUS Commands Window with the
@code{C-c C-n} or @code{C-c C-r} keys.
(If you are still using S-PLUS 4.x or 2000,\
then use @code{M-x S+4} or @code{M-x S+4-msdos}.)

To start an S-PLUS [678].x session inside an emacs buffer---and
without the S-PLUS GUI:
@example
M-x Sqpe
(or @code{M-x Sqpe+6}).
@end example
This works with both the bash and msdos shells.
You will then be asked for a pathname ("S starting data
directory?"), from which to start the process.  The prompt will
propose your current directory as the default.
You get Unix-like behavior, in particular the entire
transcript is available for emacs-style search commands.
Send lines or regions from the emacs buffer containing your S
program (for example, @file{myfile.s}) to the *S+6* buffer with the
@code{C-c C-n} or @code{C-c C-r} keys.
Interactive graphics are available with Sqpe by using the java
library supplied with S-PLUS 6.1 and newer releases.
Enter the commands:
@example
library(winjava)
java.graph()
@end example
Graphs can be saved from the @code{java.graph} device
in several formats, but not PostScript.   If you
need a PostScript file you will need to open a separate
@code{postscript} device.
(If you are still using S-PLUS 4.x or 2000, then use @code{M-x Sqpe+4}.)

To connect to an already running S-PLUS GUI (started, for example,
from the S-PLUS icon):
@example
M-x S+6-existing
@end example
or
@example
M-x S+6-msdos-existing
@end example
You will then be
asked for a pathname ("S starting data directory?"), from which to
start the process.  The prompt will propose your current directory
as the default.  ESS will arrange for
communication with the already running S-PLUS GUI using the DDE protocol.
Send lines or regions
from the emacs buffer containing your S program (for example,
@file{myfile.s}) to the S-PLUS Commands Window with the
@code{C-c C-n} or @code{C-c C-r} keys.
(If you are still using S-PLUS 4.x or 2000,
 then use @code{M-x S+4-existing} or @code{M-x S+4-msdos-existing}.)

If you wish to run R, you can start it with:
@example
M-x R
@end example

XLispStat can not currently be run with
@example
M-x XLS
@end example
Hopefully, this will change.  However, you can still edit with
emacs, and cut and paste the results into the XLispStat
*Listener* Window under Microsoft Windows.

@comment SAS for Windows uses the batch access with function keys that is
@comment described in
@comment @file{doc/README.SAS}.
@comment @xref{ESS(SAS)--MS Windows}.
@comment The user can also edit SAS files
@comment in an @code{ESS[SAS]} buffer and than manually copy and paste them into
@comment an Editor window in the SAS Display Manager.
@comment
@comment For Windows, inferior SAS in an @code{iESS{[SAS]}} buffer does not work
@comment on the local machine.  It does work over a network connection to
@comment SAS running on a remote Unix computer.
@comment
@comment Reason:  we use ddeclient to interface with programs and SAS doesn't
@comment provide the corresponding ddeserver capability.

@c @item
@c (OPTIONAL) If you are running Sqpe or R, you might consider
@c installing the database files.  From within emacs, @code{C-x d} to
@c the   directory containing ESS.  Now:
@c @example
@c M-x Sqpe+6
@c @end example
@c to get S running.  Once you see the SPLUS prompt, do:
@c @example
@c M-x ess-create-object-name-db
@c @end example
@c (this will create the file @file{ess-s+6-namedb.el}; if it isn't in the
@c ESS directory, move it there).

@c Then, completions will be autoloaded and will not be regenerated
@c for every session.

@c For R, do the same, using
@c @example
@c M-x R
@c @end example
@c and then @code{M-x ess-create-object-name-db} creating
@c @file{ess-r-namedb.el}; if it isn't in the ESS directory, move it
@c there).

@item That's it!

@end enumerate
@comment Requirements duplicated?
@comment @node Requirements, , Microsoft Windows installation, Installation
@comment node-name,  next,  previous,  up
@comment @section Requirements
@comment @include requires.texi
