@macro essver{} 5.2.0
Current Documentation by A.J. Rossini (rossini@biostat.washington.edu) Department of Biostatistics University of Washington, USA. Original Documentation by David Smith (D.M.Smith@lancaster.ac.uk) Department of Mathematic and Statistics Lancaster University, UK Copyright (C) 1992--1995 David M. Smith Copyright (C) 1996--2002 A.J. Rossini.
Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies.
Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.
The S and Splus packages provide sophisticated statistical and graphical routines for manipulating data. S-mode, the package on which ESS was based, provided a programming environment for data analysis and statistical programming, as well as an intelligent interface to the S process.
The ESS (:= Emacs Speaks Statistics) package is an extension of S-mode to provide a common, generic, and useful interface, through Emacs, to many statistical packages. It has currently been extended for R, XLisp-Stat, and SAS, with other statistical languages such as Stata, SPSS, and Fiasco slated for implementations in the future.
A bit of notation before we begin. Emacs refers to both
Emacs as distributed by the Free Software Foundation, as well as
XEmacs, which is a second GNU version of Emacs. The Emacs major
mode ESS[language]
which is used for editing source for dialect
language
, can take values S
, SAS
, or XLS
,
for instance. The inferior process interface (the connection between
Emacs and the running process) referred to as interactive ESS
(iESS
), is denoted in the modeline by ESS[dialect]
, where
dialect
can take values S3
, S4
, S+3
,
S+4
, S+5
, S+6
,
R
, XLS
, VST
, SAS
, as well as others.
Currently, the documentation contains many references to `S' where actually any supported (statistics) language is meant, i.e., `S' could also mean `XLisp-Stat' or `SAS'.
For exclusively interactive users of S, ESS provides a number of features to make life easier. There is an easy to use command history mechanism, including a quick prefix-search history. To reduce typing, command-line completion is provided for all S objects and "hot keys" are provided for common S function calls. Help files are easily accessible, and a paging mechanism is provided to view them. Finally, an incidental (but very useful) side-effect of ESS is that a transcript of your session is kept for later saving or editing.
No special knowledge of Emacs is necessary when using S interactively under ESS.
For those that use S in the typical edit--test--revise cycle when programming S functions, ESS provides for editing of S functions in Emacs edit buffers. Unlike the typical use of S where the editor is restarted every time an object is edited, ESS uses the current Emacs session for editing. In practical terms, this means that you can edit more than one function at once, and that the ESS process is still available for use while editing. Error checking is performed on functions loaded back into S, and a mechanism to jump directly to the error is provided. ESS also provides for maintaining text versions of your S functions in specified source directories.
S is a powerful system for manipulating and analyzing data, but its user interface -- particularly on Unix platforms -- leaves something to be desired. ESS is a package which is designed to make S easier to use.
ESS provides several features which make it easier to interact with the ESS process (i.e. enter commands and view the output). These include:
tcsh
's facility for filenames; here it
also applies to object names and list components.
See section Completion of object names.
objects()
and search()
.
See section Hot keys for common commands.
If you commonly create or modify S functions, you will have found the standard facilities for this (the `fix()' function, for example) severely limiting. Using S's standard features, one can only edit one function at a time, and you can't continue to use S while editing. ESS corrects these problems by introducing the following features:
Finally, ESS provides features for re-submitting commands from saved transcript files, including:
Changes/New Features in 5.2.0:
Changes/New Features in 5.1.21:
Changes/New Features in 5.1.20:
Changes/New Features in 5.1.19:
Changes/New Features in 5.1.18:
Changes/New Features in 5.1.17:
Changes/New Features in 5.1.16:
Changes/New Features in 5.1.15:
Changes/New Features in 5.1.14:
Changes/New Features in 5.1.13:
Changes/New Features in 5.1.12:
Changes/New Features in 5.1.11:
Changes/New Features in 5.1.10:
Changes/New Features in 5.1.9:
Changes/New Features in 5.1.8:
Changes/New Features in 5.1.2:
ESS is based on Olin Shivers' excellent comint package (which is supplied with version 19 of GNU Emacs). The original version of ESS (then known as `S-mode') was written by Doug Bates (bates@stat.wisc.edu) and Ed Kademan (kademan@stat.wisc.edu). Frank Ritter (ritter@psy.cmu.edu) then merged this version with his own S-mode mode to form `S.el' version 2.1.
Version 2.1 of `S.el' was then updated and expanded by David Smith to form version 3.4. This was then updated for Emacs 19 to create version 4. Most bugs have now been fixed (and several new ones introduced) and many new features have been added. Thanks must go to the many people who have helped with the development of the present version of ESS:
ess-eval-line-and-next-line
are by Rod Ball.
The new version, ESS version 5, is being developed and currently maintained by
The latest stable version of ESS is always available on the web at: ESS web page or StatLib
The latest (no more than 24 hours behind the developers) version of ESS can also be retrieved using anonymous cvs:
You need a cvs client (that works with your firewall, if any)
the repository name is
:pserver:anoncvs@software.biostat.washington.edu:/var/anoncvs
using a command-line cvs client (i.e. on Unix or DOS), first type:
cvs -d :pserver:anoncvs@software.biostat.washington.edu:/var/anoncvs login
password is anoncvs
then type:
cvs -d :pserver:anoncvs@software.biostat.washington.edu:/var/anoncvs co ess
If ESS has already been installed on your system, the next chapter has details on how to get started using S under ESS.
If you need to install ESS, read section Installing ESS on your system for details on what needs to be done before proceeding to the next chapter.
section Customizing ESS provides details of user variables you can change to customize ESS to your taste, but it is recommended that you defer this section until you are more familiar with ESS.
Don't forget that this manual is not the only source of information about ESS. In particular, the mode-based online help (obtained by pressing C-h m when in the process buffer, edit buffer or help buffer) is quite useful. However the best source of information is, as always, experience -- try it out!
To start an S session, simply type M-x S RET, i.e. press ESC, then x, then capital S and then the RETURN key.
S will then (by default) ask the question
S starting data directory?
Enter the name of the directory you wish to start S from (that is,
the directory you would have cd
'd to before starting S from
the shell). This directory should have a `.Data' subdirectory.
You will then be popped into a buffer with name `*S*' which will be used for interacting with the ESS process, and you can start entering commands.
ESS allows you to run more than one ESS process simultaneously in the same session. Each process has a name and a number; the initial process (process 1) is simply named (using S-PLUS as an example) `S+3:1'. The name of the process is shown in the mode line in square brackets (for example, `[S+3:2]'); this is useful if the process buffer is renamed. Without a prefix argument, M-x S starts a new ESS process, using the first available process number. With a prefix argument (for R), C-u M-x R allows for the specification of command line options for the size of memory allocated to the R process, for example.
You can switch to any active ESS process with the command C-c
C-k (ess-request-a-process
). Just enter the name of the process
you require; completion is provided over the names of all running S
processes. This is a good command to consider binding to a global key.
For the predecessor to ESS (S-mode 4.8), the initial process was not
visibly numbered, i.e. S instead of S1 was used in the mode-line. To
obtain this behavior, set the variable ess-plain-first-buffername
to t
. See `ess-site' for how to set this for all users.
ESS works with processes on remote computers as easily as with processes on the local machine. The recommended way to access a statistical program on remote computer is to start it from a telnet or ssh buffer and then connect ESS to that buffer.
Should you or a colleague inadvertently start a statistical process in an ordinary `*shell*' buffer, the `ess-remote' command can be used to convert it to an ESS buffer and allow you to use the ESS commands with it.
We have two older commands, now deprecated, for accessing ESS processes on remote computers. See section S+elsewhere and ess-elsewhere.
These commands are now deprecated. We recommend `ess-remote'.
We have two versions of the elsewhere function.
`S+elsewhere' is specific for the S-Plus program. The more general function `ess-elsewhere' is not as stable.
If you do not wish ESS to prompt for a starting directory when starting
a new process, set the variable ess-ask-for-ess-directory
to
nil
. In this case, the value of the variable ess-directory
is used as the starting directory. The default value for this variable
is your home directory. If ess-ask-for-ess-directory
has a
non-nil
value (as it does by default) then the value of
ess-directory
provides the default when prompting for the
starting directory. Incidentally, ess-directory
is an ideal
variable to set in ess-pre-run-hook
.
If you like to keep a records of your S sessions, set the variable
ess-ask-about-transfile
to t
, and you will be asked for a
filename for the transcript before the ESS process starts.
nil
, as for a file name in which to save the session
transcript.
Enter the name of a file in which to save the transcript at the prompt. If the file doesn't exist it will be created (and you should give it a file name ending in `.St'; if the file already exists the transcript will be appended to the file. (Note: if you don't set this variable but you still want to save the transcript, you can still do it later -- see section Keeping a record of your S session.)
Once these questions are answered (if they are asked at all) the S
process itself is started by calling the program name specified in the
variable inferior-ess-program
.
If you need to pass any arguments to this program, they may be specified
in the variable inferior-S_program_name-args
(e.g. if
inferior-ess-program
is "S+"
then the variable to set is
inferior-S+-args
.
It is not normally necessary to pass arguments to the S program; in
particular do not pass the `-e' option to Splus
, since ESS
provides its own command history mechanism.
The primary function of the ESS package is to provide an easy-to-use front end to the S interpreter. This is achieved by running the S process from within an Emacs buffer, so that the Emacs editing commands are available to correct mistakes in commands, etc. The features of Inferior S mode are similar to those provided by the standard Emacs shell mode (see section `Shell Mode' in The Gnu Emacs Reference Manual). Command-line completion of S objects and a number of `hot keys' for commonly-used S commands are also provided for ease of typing.
Sending a command to the ESS process is as simple as typing it in and pressing the RETURN key:
If you make a typing error before pressing RET all the usual Emacs editing commands are available to correct it (see section `Basic editing commands' in The GNU Emacs Reference Manual). Once the command has been corrected you can press RETURN (even if the cursor is not at the end of the line) to send the corrected command to the ESS process.
ESS provides some other commands which are useful for fixing mistakes:
backward-kill-word
) comint-kill-input
) comint-bol
) See section `Shell Mode' in The Gnu Emacs Reference Manual, for other commands relevant to entering input.
In the process buffer, the TAB key is for completion, similar to that provided by Shell Mode for filenames. In Inferior S mode, pressing the TAB key when the cursor is following the first few characters of an object name completes the object name; if the cursor is following a file name TAB completes the file name.
When the cursor is just after a partially-completed object name,
pressing TAB provides completion in a similar fashion to
tcsh
except that completion is performed over all known S object names
instead of file names. ESS maintains a list of all objects known to S
at any given time, which basically consists of all objects (functions
and datasets) in every attached directory listed by the search()
command
along with the component objects of attached data frames
(if your version of S supports them).
For example, consider the three functions (available in Splus version
3.0) called binomplot()
, binom.test()
and
binomial()
. Typing bin TAB after the S prompt will
insert the characters `om', completing the longest prefix
(`binom') which distinguishes these three commands. Pressing
TAB once more provides a list of the three commands which have
this prefix, allowing you to add more characters (say, `.') which
specify the function you desire. After entering more characters
pressing TAB yet again will complete the object name up to
uniqueness, etc. If you just wish to see what completions exist without
adding any extra characters, type M-?.
ESS also provides completion over the components of named lists accessed using the `$' notation, to any level of nested lists. This feature is particularly useful for checking what components of a list object exist while partway through entering a command: simply type the object name and `$' and press TAB to see the names of existing list components for that object.
Completion is also provided over file names, which is particularly
useful when using S functions such as get()
or scan()
which require fully expanded file names. Whenever the cursor is within
an S string, pressing TAB completes the file name before
point, and also expands any `~' or environment variable references.
If the cursor is not in a string and does not follow a (partial) object name, the TAB key has a third use: it expands history references. See section References to historical commands.
ESS automatically keeps track of any objects added or deleted to the system (such as new objects created, or directories added to the search list) to make completion as accurate as possible. Whenever ESS notices that search list has changed (1) when you attach a directory or data frame, the objects associated with it immediately become available for a completion; when it is detached completion is no longer available on those objects.
To maintain a list of accessible objects for completion, ESS needs to
determine which objects are contained in each directory or data frame on
the search list. This is done at the start of each S session, by
running the objects()
command on every element of the search
list. On some systems, however, this can be rather slow; it's doubly
frustrating when you consider that most of the directories on the search
list are the standard S libraries, which never change anyway! When
ESS was installed, a database of the standard object names should have
been created which should speed up this process at the start of an S
session; if it has not been created you will get a warning like
`S-namedb.el does not exist'. See section Installing ESS on your system, for information on
how to create this database.
Efficiency in completion is gained by maintaining a cache of objects currently known to S; when a new object becomes available or is deleted, only one component of the cache corresponding to the associated directory needs to be refreshed. If ESS ever becomes confused about what objects are available for completion (such as when if refuses to complete an object you know is there), the command M-x ess-resynch forces the entire cache to be refreshed, which should fix the problem.
Most of the time, the cursor spends most of its time at the bottom of the ESS process buffer, entering commands. However all the input and output from the current (and previous) ESS sessions is stored in the process buffer (we call this the transcript) and often we want to move back up through the buffer, to look at the output from previous commands for example.
Within the process buffer, a paragraph
is defined as the prompt, the command after the prompt, and the output
from the command. Thus M-{ and M-} move you backwards and
forwards, respectively, through commands in the transcript. A
particularly useful command is M-h (mark-paragraph
) which
will allow you to mark a command and its entire output (for deletion,
perhaps). For more information about paragraph commands,
see section `Paragraphs' in The GNU Emacs Reference Manual.
If an ESS process finishes and you restart it in the same process buffer, the output from the new ESS process appears after the output from the first ESS process separated by a form-feed (`^L') character. Thus pages in the ESS process buffer correspond to ESS sessions. Thus, for example, you may use C-x [ and C-x ] to move backward and forwards through ESS sessions in a single ESS process buffer. For more information about page commands, see section `Pages' in The GNU Emacs Reference Manual.
Viewing the output of the command you have just entered is a common occurrence and ESS provides a number of facilities for doing this. Whenever a command produces a longish output, it is possible that the window will scroll, leaving the next prompt near the middle of the window. The first part of the command output may have scrolled off the top of the window, even though the entire output would fit in the window if the prompt were near the bottom of the window. If this happens, you can use the command
comint-show-maximum-output
)
to make more of the last output visible. (To make this happen
automatically for all inputs, set the variable
comint-scroll-to-bottom-on-input
to t
; for information on
this and other options for handling process input and output
see section `Shell Mode Options' in The GNU Emacs Reference Manual.)
If the first part of the output is still obscured, use
comint-show-output
) to view it. Finally, if you want to discard the last command output altogether, use
to delete it. Use this command judiciously to keep your transcript to a more manageable size.
If you want to view the output from more historic commands than the previous command, commands are also provided to move backwards and forwards through previously entered commands in the process buffer:
comint-previous-input
) comint-next-input
) Note that these two commands are analogous to C-p and C-n but apply to command lines rather than text lines. And just like C-p and C-n, passing a prefix argument to these commands means to move to the ARG'th next (or previous) command. (These commands are also discussed in section `Shell History Copying' in The GNU Emacs Reference Manual.)
There are also two similar commands (not bound to any keys by default) which move to preceding or succeeding commands, but which first prompt for a regular expression (see section `Syntax of Regular Expression' in The GNU Emacs Reference Manual), and then moves to the next (previous) command matching the pattern.
When moving through the transcript, you may wish to re-execute some of the commands you find there. ESS provides three commands to do this; these commands may be used whenever the cursor is within a command line in the transcript (if the cursor is within some command output, an error is signaled). Note all three commands involve the RETURN key.
inferior-ess-send-input
) comint-copy-old-input
) ess-transcript-send-command-and-move
) When the cursor is not after the current prompt, the RETURN key has a slightly different behavior than usual. Pressing RET on any line containing a command that you entered (i.e. a line beginning with a prompt) sends that command to the ESS process once again. If you wish to edit the command before executing it, use C-c RET instead; it copies the command to the current prompt but does not execute it, allowing you to edit it before submitting it.
These two commands leave the cursor at the new command line, allowing you to continue with interactive use of S. If you wish to resubmit a series of commands from the transcript, consider using M-RET instead, which leaves the cursor at the command line following the one you re-submitted. Thus by using M-RET repeatedly, you can re-submit a whole series of commands.
These commands work even if if the current line is a continuation line (i.e. the prompt is `+' instead of `>') -- in this case all the lines that form the multi-line command are concatenated together and the resulting command is sent to the ESS process (currently this is the only way to resubmit a multi-line command to the ESS process in one go). If the current line does not begin with a prompt, an error is signaled. This feature, coupled with the command-based motion commands described above, could be used as a primitive history mechanism. ESS provides a more sophisticated mechanism, however, which is described in section Command History.
To keep a record of your S session in a disk file, use the Emacs
command C-x C-w (write-file
) to attach a file to the
ESS process buffer. The name of the process buffer will (probably)
change to the name of the file, but this is not a problem. You can
still use S as usual; just remember to save the file before you quit
Emacs with C-x C-s. You can make ESS prompt you for a filename in
which to save the transcript every time you start S by setting the
variable
ess-ask-about-transfile
to t
; see section Changing the startup actions.
We recommend you save your transcripts with filenames that end in
`.St'. There is a special mode (ESS transcript mode ---
see section Manipulating saved transcript files) for editing transcript files which is
automatically selected for files with this suffix.
S transcripts can get very large, so some judicious editing is appropriate if you are saving it in a file. Use C-c C-o whenever a command produces excessively long output (printing large arrays, for example). Delete erroneous commands (and the resulting error messages or other output) by moving to the command (or its output) and typing M-h C-w. Also, remember that C-c C-e (and other hot keys) may be used for commands whose output you do not wish to appear in the transcript. These suggestions are appropriate even if you are not saving your transcript to disk, since the larger the transcript, the more memory your Emacs process will use on the host machine.
Finally, if it is your intention to produce S source code (suitable
for using with source()
or inclusion in an S function) from a
transcript, then the command M-x ess-clean-region may be of use.
This command works in any Emacs buffer, and removes all prompts and
command output from an ESS transcript within the current region, leaving
only the commands. Don't forget to remove any erroneous commands first!
ESS provides easy-to-use facilities for re-executing or editing previous
commands. An input history of the last few commands is maintained (by
default the last 50 commands are stored, although this can be changed by
setting the variable comint-input-ring-size
in
inferior-ess-mode-hook
.) The simplest history commands simply
select the next and previous commands in the input history:
comint-previous-input
) comint-next-input
) For example, pressing M-p once will re-enter the last command into the process buffer after the prompt but does not send it to the ESS process, thus allowing editing or correction of the command before the ESS process sees it. Once corrections have been made, press RET to send the edited command to the ESS process.
If you want to select a particular command from the history by matching it against a regular expression (see section `Syntax of Regular Expression' in The GNU Emacs Reference Manual), to search for a particular variable name for example, these commands are also available:
comint-previous-matching-input
) comint-next-matching-input
) A common type of search is to find the last command that began with a particular sequence of characters; the following two commands provide an easy way to do this:
comint-previous-matching-input-from-input
) comint-next-matching-input-from-input
)
Instead of prompting for a regular expression to match against, as they
instead select commands starting with those characters already entered.
For instance, if you wanted to re-execute the last attach()
command, you may only need to type att and then A-M-r and
RET. (Note: you may not have an ALT key on your keyboard,
in which case it may be a good idea to bind these commands to some other
keys.)
See section `Shell History Ring' in The GNU Emacs Reference Manual, for a more detailed discussion of the history mechanism.
Instead of searching through the command history using the command
described in the previous section, you can alternatively refer to a
historical command directly using a notation very similar to that used
in csh
. History references are introduced by a `!' or
`^' character and have meanings as follows:
In addition, you may follow the reference with a word designator
to select particular words of the input. A word is defined as a
sequence of characters separated by whitespace. (You can modify this
definition by setting the value of comint-delimiter-argument-list
to a list of characters that are allowed to separate words and
themselves form words.) Words are numbered beginning with zero. The
word designator usually begins with a `:' (colon) character;
however it may be omitted if the word reference begins with a `^',
`$', `*' or `-'. If the word is to be selected from the
previous command, the second `!' character can be omitted from the
event specification. For instance, `!!:1' and `!:1' both
refer to the first word of the previous command, while `!!$' and
`!$' both refer to the last word in the previous command. The
format of word designators is as follows:
In addition, you may surround the entire reference except for the first `!' by braces to allow it to be followed by other (non-whitespace) characters (which will be appended to the expanded reference).
Finally, ESS also provides quick substitution; a reference like `^old^new^' means "the last command, but with the first occurrence of the string `old' replaced with the string `new'" (the last `^' is optional). Similarly, `^old^' means "the last command, with the first occurrence of the string `old' deleted" (again, the last `^' is optional).
To convert a history reference as described above to an input suitable for S, you need to expand the history reference, using the TAB key. For this to work, the cursor must be preceded by a space (otherwise it would try to complete an object name) and not be within a string (otherwise it would try to complete a filename). So to expand the history reference, type SPC TAB. This will convert the history reference into an S command from the history, which you can then edit or press RET to execute.
For example, to execute the last command that referenced the variable
data
, type !?data SPC TAB RET.
ESS provides a number of commands for executing the commonly used
functions. These commands below are basically information-gaining
commands (such as objects()
or search()
) which tend to
clutter up your transcript and for this reason some of the hot keys
display their output in a temporary buffer instead of the process buffer
by default. This behavior is controlled by the variable
ess-execute-in-process-buffer
which, if
non-nil
, means that these commands will produce their output in
the process buffer instead. In any case, passing a prefix argument to
the commands (with C-u) will reverse the meaning of
ess-execute-in-process-buffer
for that command, i.e. the output
will be displayed in the process buffer if it usually goes to a
temporary buffer, and vice-versa. These are the hot keys that behave in
this way:
ess-execute-objects
) objects()
command to the ESS process. A prefix argument specifies the
position on the search list (use a negative argument to toggle
es-execute-in-process-buffer
as well). A quick way to see what
objects are in your working directory.
ess-execute-search
) search()
command to the ESS process.
ess-execute
)
ess-execute
may seem pointless when you could just type the
command in anyway, but it proves useful for `spot' calculations which
would otherwise clutter your transcript, or for evaluating an expression
while partway through entering a command. You can also use this command
to generate new hot keys using the Emacs keyboard macro facilities;
see section `Keyboard Macros' in The GNU Emacs Reference Manual.
The following hot keys do not use ess-execute-in-process-buffer
to decide where to display the output -- they either always display in
the process buffer or in a separate buffer, as indicated:
ess-execute-attach
) attach()
command.
If a numeric prefix argument is given it is used as the position on the
search list to attach the directory; otherwise the S default of 2 is
used. The attach()
command actually executed appears in the
process buffer.
ess-load-file
) source()
. If there is an error during loading, you can jump to
the error in the file with C-x ` (ess-parse-errors
).
See section Detecting errors in source files, for more details.
ess-display-help-on-object
) ess-quit
) q()
command to the ESS process (or (exit)
to the XLS process), and cleans up any temporary buffers (such as
help buffers or edit buffers) you may have created along the way. Use
this command when you have finished your S session instead of simply
typing q()
yourself, otherwise you will need to issue the command
M-x ess-cleanup
command explicitly to make sure that all the files that need to be saved
have been saved, and that all the temporary buffers have been killed.
For the S languages (S, S-Plus, R) ESS sets an option in the current process that programs in the language can check to determine the environment in which they are currently running.
ESS sets
options(STERM="iESS")
for S language processes running in an
inferior iESS[S]
or iESS[R]
buffer.
ESS sets
options(STERM="ddeESS")
for independent S-Plus for Windows
processes running in the GUI and communicating with ESS via
the DDE (Microsoft Dynamic Data Exchange) protocol through a
ddeESS[S]
buffer.
Other values of options()$STERM
that we recommend are:
length
: Fixed length xterm or telnet window.
scrollable
: Unlimited length xterm or telnet window.
server
: S-Plus Stat Server.
BATCH
: BATCH.
Rgui
: R GUI.
Commands
: S-Plus GUI without DDE interface to ESS.
Additional values may be recommended in the future as new interaction
protocols are created. Unlike the values iESS
and ddeESS
,
ESS can't set these other values since the S language program is not
under the control of ESS.
The following commands are also provided in the process buffer:
comint-interrupt-subjob
) ess-abort
) q()
nor
.Last
will be executed and device drivers will not finish
cleanly. This command is provided as a safety to
comint-stop-subjob
, which is usually bound to C-c C-z. If
you want to quit from S, use C-c C-q (ess-quit
) instead.
ess-dump-object-into-edit-buffer
) Other commands available is Inferior S mode are discussed in section `Shell Mode' in The Gnu Emacs Reference Manual.
ESS provides facilities for editing S objects within your Emacs session. Most editing is performed on S functions, although in theory you may edit datasets as well. Edit buffers are always associated with files, although you may choose to make these files temporary if you wish. Alternatively, you may make use of a simple yet powerful mechanism for maintaining backups of text representations of S functions. Error-checking is performed when S code is loaded into the ESS process.
To edit an S object, type
from within the ESS process buffer (*S*
). You will then be
prompted for an object to edit: you may either type in the name of an
existing object (for which completion is available using the TAB
key),
or you may enter the name of a new object.
A buffer will be created containing the text representation of the
requested object or, if you entered the name of a non-existent object at
the prompt and the variable ess-insert-function-templates
is non-nil
, you will be presented with a template defined by
ess-function-template
which defaults to a skeleton function construct.
You may then edit the function as required. The edit buffer generated
by ess-dump-object-into-edit-buffer
is placed in the ESS
major mode which provides a number of commands to facilitate editing
S source code. Commands are provided to intelligently indent S
code, evaluate portions of S code and to move around S code
constructs.
Note: when you dump a file with C-c C-d, ESS first checks
to see whether there already exists an edit buffer containing that
object and, if so, pops you directly to that buffer. If not, ESS next
checks whether there is a file in the appropriate place with the
appropriate name (see section Maintaining S source files) and if so, reads in that file.
You can use this facility to return to an object you were editing in a
previous session (and which possibly was never loaded to the S
session). Finally, if both these tests fail, the ESS process is
consulted and a dump()
command issued.
If you want to force ESS to ask the ESS process for the object's
definition (say, to reformat an unmodified buffer or to revert back to
S's idea of the object's definition) pass a prefix argument to
ess-dump-object-into-edit-buffer
by typing C-u C-c C-d.
The best way to get information -- particularly function definitions
--- into S is to load them in as source file, using S's
source
function. You have already seen how to create source
files using C-c C-d; ESS provides a complementary command for
loading source files (even files not created with ESS!) into the ESS
process:
After typing C-c C-l you will prompted for the name of the file to load into S; usually this is the current buffer's file which is the default value (selected by simply pressing RET at the prompt). You will be asked to save the buffer first if it has been modified (this happens automatically if the buffer was generated with C-c C-d). The file will then be loaded, and if it loads successfully you will be returned to the ESS process.
If any errors occur when loading a file with C-c C-l
, ESS will
inform you of this fact. In this case, you can jump directly to the
line in the source file which caused the error by typing C-x `
(ess-parse-errors
).
You will be returned to the offending file (loading it into a buffer if
necessary) with point at the line S reported as containing the
error. You may then correct the error, and reload the file. Note that
none of the commands in an S source file will take effect if any
part of the file contains errors.
Sometimes the error is not caused by a syntax error (loading a
non-existent file for example). In this case typing C-x ` will
simply display a buffer containing S's error message. You can force
this behavior (and avoid jumping to the file when there is a
syntax error) by passing a prefix argument to ess-parse-errors
with C-u C-x `.
Other commands are also available for evaluating portions of code in the
S process. These commands cause the selected code to be evaluated
directly by the ESS process as if you had typed them in at the
command line; the source()
function is not used. You may choose
whether both the commands and their output appear in the process buffer
(as if you had typed in the commands yourself) or if the output alone is
echoed. The behavior is controlled by the variable
ess-eval-visibly-p
whose default is nil
(display output only). Passing a prefix argument (C-u) to any of
the following commands, however, reverses the meaning of
ess-eval-visibly-p
for that command only -- for example C-u
C-c C-j echoes the current line of S (or other) code in the ESS
process buffer, followed by its output. This method of evaluation is an
alternative to S's source()
function
when you want the input as well as the output to be displayed. (You can
sort of do this with source()
when the option echo=T
is
set, except that prompts do not get displayed. ESS puts prompts in the
right places.) The commands for evaluating code are:
ess-eval-line
) ess-eval-line-and-go
) ess-eval-function
) ess-eval-function-and-go
) ess-eval-region
) ess-eval-region-and-go
) ess-eval-buffer
) ess-eval-buffer-and-go
) ess-eval-line-and-next-line
)
It should be stressed once again that these ess-eval-
commands
should only be used for evaluating small portions of code for debugging
purposes, or for generating transcripts from source files. When editing
S functions, C-c C-l is the command to use to update the
function's value. In particular, ess-eval-buffer
is now largely
obsolete.
One final command is provided for spot-evaluations of S code:
ess-execute-in-tb
) This is useful for quick calculations, etc.
All the above commands are useful for evaluating small amounts of code
and observing the results in the process buffer. A useful way to work
is to divide the frame into two windows; one containing the source code
and the other containing the process buffer. If you wish to make the
process buffer scroll automatically when the output reaches the bottom
of the window, you will need to set the variable
comint-scroll-to-bottom-on-output
to others
or t
.
*** Maybe a link to customization section here ***
ESS now provides a sophisticated mechanism for indenting S source
code (thanks to Ken'ichi Shibayama). Compound statements (delimited by
`{' and `}') are indented relative to their enclosing block.
In addition, the braces have been electrified to automatically indent to
the correct position when inserted, and optionally insert a newline at
the appropriate place as well. Lines which continue an incomplete
expression are indented relative to the first line of the expression.
Function definitions, if
statements, calls to expression()
and loop constructs are all recognized and indented appropriately. User
variables are provided to control the amount if indentation in each
case, and there are also a number of predefined indentation styles to
choose from. See section Variables controlling indentation.
Comments are also handled specially by ESS, using an idea borrowed from
the Emacs-Lisp indentation style. By default,
comments beginning with `###'
are aligned to the beginning of the line. Comments beginning with
`##' are aligned to the current level of indentation for the block
containing the comment. Finally, comments beginning with `#' are
aligned to a column on the right (the 40th column by default, but this
value is controlled by the variable comment-column
,)
or just after the expression on the line containing the comment if it
extends beyond the indentation column. You turn off the default
behavior by adding the line
(setq ess-fancy-comments nil)
to your `.emacs' file.
(GNU emacs uses the filename `~/.emacs' and
Xemacs uses the filename `~/.xemacs/init.el'
for the initialization file.)
The indentation commands provided by ESS are:
ess-indent-command
) newline-and-indent
) ess-indent-exp
) ess-electric-brace
) indent-for-comment
) GNU
, BSD
, K&R
, CLB
, and C++
.
The DEFAULT
style uses the default values for the indenting
variables (unless they have been modified in your `.emacs' file.)
This command causes all of the formatting variables
see section Variables controlling indentation to be buffer-local.
A number of commands are provided to move across function definitions in the edit buffer:
ess-beginning-of-function
) ess-end-of-function
) ess-mark-function
) Don't forget the usual Emacs commands for moving over balanced expressions and parentheses: See section `Lists and Sexps' in The GNU Emacs Reference Manual.
Completion is provided in the edit buffer in a similar fashion to the process buffer: M-TAB completes file names and M-? lists file completions. Since TAB is used for indentation in the edit buffer, object completion is now performed with C-c TAB. Note however that completion is only provided over globally known S objects (such as system functions) -- it will not work for arguments to functions or other variables local to the function you are editing.
Finally, two commands are provided for returning to the ESS process buffer:
ess-switch-to-end-of-ESS
) ess-switch-to-ESS
) In addition some commands available in the process buffer are also available in the edit buffer. You can still read help files with C-c C-v, edit another function with C-c C-d and of course C-c C-l can be used to load a source file into S. See section Other commands provided by inferior-ESS, for more details on these commands.
Every edit buffer in ESS is associated with a dump file on disk.
Dump files are created whenever you type C-c C-d
(ess-dump-object-into-edit-buffer
), and may either be deleted
after use, or kept as a backup file or as a means of keeping several
versions of an S function.
nil
, dump files created with C-c C-d are deleted
immediately after they are created by the ess-process.
Since immediately after S dumps an object's definition to a disk
file the source code on disk corresponds exactly to S's idea of the
object's definition, the disk file isn't really needed; deleting it now
has the advantage that if you don't modify the file (say, because
you just wanted to look at the definition of one of the standard S
functions) the source dump file won't be left around when you kill the
buffer. Note that this variable only applies to files generated with
S's dump
function; it doesn't apply to source files which already
exist. The default value is t
.
nil
(always
delete), ask
(always ask whether to delete), check
(delete
files generated with C-c C-d in this Emacs session, otherwise ask
--- this is the default) and t
(never delete). This variable is
buffer-local.
After an object has been successfully (i.e. without error) been loaded back into S with C-c C-l, the disk file again corresponds exactly (well, almost -- see below) to S's record of the object's definition, and so some people prefer to delete the disk file rather than unnecessarily use up space. This option allows you to do just that.
If the value of ess-keep-dump-files
is t
, dump files are
never deleted after they are loaded. Thus you can maintain a complete
text record of the functions you have edited within ESS. Backup files
kept as usual, and so by using the Emacs numbered backup facility ---
see section `Single or Numbered Backups' in The Gnu Emacs Reference Manual, you can keep a historic
record of function definitions. Another possibility is to maintain the
files with a version-control system such as RCS See section `Version Control' in The Gnu Emacs Reference Manual. As long as a dump file exists in the appropriate place for a
particular object, editing that object with C-c C-d finds that
file for editing (unless a prefix argument is given) -- the ESS
process is not consulted. Thus you can keep comments outside the
function definition as a means of documentation that does not clutter
the S object itself. Another useful feature is that you may format
the code in any fashion you please without S re-indenting the code
every time you edit it. These features are particularly useful for
project-based work.
If the value of ess-keep-dump-files
is nil, the dump file is always
silently deleted after a successful load with C-c C-l. While this
is useful for files that were created with C-c C-d it also applies
to any other file you load (say, a source file of function
definitions), and so can be dangerous to use unless you are careful.
Note that since ess-keep-dump-files
is buffer-local, you can make
sure particular files are not deleted by setting it to t
in the
Local Variables section of the file See section `Local Variables in Files' in The Gnu Emacs Reference Manual.
A safer option is to set ess-keep-dump-files
to ask
; this
means that ESS will always ask for confirmation before deleting the
file. Since this can get annoying if you always want to delete dump
files created with C-c C-d
, but not any other files, setting
ess-keep-dump-files
to check
(the default value) will
silently delete dump files created with C-c C-d in the current
Emacs session, but query for any other file. Note that in any case you
will only be asked for confirmation once per file, and your answer is
remembered for the rest of the Emacs session.
Note that in all cases, if an error (such as a syntax error) is detected while loading the file with C-c C-l, the dump file is never deleted. This is so that you can edit the file in a new Emacs session if you happen to quit Emacs before correcting the error.
Dump buffers are always autosaved, regardless of the value of
ess-keep-dump-files
.
Every dump file should be given a unique file name, usually the dumped object name with some additions.
%s
is replaced by the
object name.
By default, dump file names are the user name, followed by `.' and
the object and ending with `.S'. Thus if user joe
dumps the
object myfun
the dump file will have name `joe.myfun.S'.
The username part is included to avoid clashes when dumping into a
publicly-writable directory, such as `/tmp'; you may wish to remove
this part if you are dumping into a directory owned by you.
You may also specify the directory in which dump files are written:
By default, dump files are always written to `/tmp', which is fine
when ess-keep-dump-files
is nil
. If you are keeping dump
files, then you will probably want to keep them somewhere in your home
directory, say `~/S-source'. This could be achieved by including
the following line in your `.emacs' file:
(setq ess-source-directory (expand-file-name "~/S-source/"))
If you would prefer to keep your dump files in separate directories
depending on the value of some variable, ESS provides a facility for
this also. By setting ess-source-directory
to a lambda
expression which evaluates to a directory name, you have a great deal of
flexibility in selecting the directory for a particular source file to
appear in. The lambda expression is evaluated with the process buffer
as the current buffer and so you can use the variables local to that
buffer to make your choice. For example, the following expression
causes source files to be saved in the subdirectory `Src' of the
directory the ESS process was run in.
(setq ess-source-directory (lambda () (concat ess-directory "Src/")))
(ess-directory
is a buffer-local variable in process buffers
which records the directory the ESS process was run from.) This is
useful if you keep your dump files and you often edit objects with the
same name in different ESS processes. Alternatively, if you often
change your S working directory during an S session, you may
like to keep dump files in some subdirectory of the directory pointed to
by the first element of the current search list. This way you can edit
objects of the same name in different directories during the one S
session:
(setq ess-source-directory (lambda () (file-name-as-directory (expand-file-name (concat (car ess-search-list) "/.Src")))))
If the directory generated by the lambda function does not exist but can be created, you will be asked whether you wish to create the directory. If you choose not to, or the directory cannot be created, you will not be able to edit functions.
ESS provides an easy-to-use facility for reading S help files from
within Emacs. From within the ESS process buffer or any ESS edit
buffer, typing C-c C-v (ess-display-help-on-object
)
will prompt you for the name of an object for which you would like
documentation. Completion is provided over all objects which have help
files.
If the requested object has documentation, you will be popped into a
buffer (named *help(obj-name)*
) containing the help file.
This buffer is placed in a special `S Help' mode which disables the
usual editing commands but which provides a number of keys for paging
through the help file:
ess-describe-help-mode
) ess-display-help-on-object
) scroll-down
) scroll-up
) beginning-of-buffer
) and < (end-of-buffer
)
ess-skip-to-next-section
) and p
(ess-skip-to-previous-section
) ess-eval-region
) isearch-forward
) ess-switch-to-end-of-ESS
) kill-buffer
) ess-kill-buffer-and-go
) In addition, all of the ESS commands available in the edit buffers are also available in S help mode (see section Creating or modifying S objects). Of course, the usual (non-editing) Emacs commands are available, and for convenience the digits and - act as prefix arguments.
If a help buffer already exists for an object for which help is
requested, that buffer is popped to immediately; the ESS process is
not consulted at all. If the contents of the help file have changed,
you either need to kill the help buffer first, or pass a prefix argument
(with C-u) to ess-display-help-on-object
.
Help buffers are marked as temporary buffers in ESS, and are deleted
when ess-quit
or ess-cleanup
are called.
Inferior S mode records the transcript (the list of all commands executed, and their output) in the process buffer, which can be saved as a transcript file, which should normally have the suffix `.St'. The most obvious use for a transcript file is as a static record of the actions you have performed in a particular S session. Sometimes, however, you may wish to re-execute commands recorded in the transcript file by submitting them to a running ESS process. This is what Transcript Mode is for.
If you load file a with the suffix `.St' into Emacs, it is placed in S Transcript Mode. Transcript Mode is similar to Inferior S mode (see section Interacting with the ESS process): paragraphs are defined as a command and its output, and you can move though commands either with the paragraph commands or with C-c C-p and C-c C-n.
Three commands are provided to re-submit command lines from the transcript file to a running ESS process. They are:
ess-transcript-send-command
) ess-transcript-copy-command
) ess-transcript-send-command-and-move
) Note that these commands are similar to those on the same keys in Inferior S Mode. In all three cases, the commands should be executed when the cursor is on a command line in the transcript; the prompt is automatically removed before the command is submitted.
Yet another use for transcript files is to extract the command lines for inclusion in an S source file or function. Transcript mode provides one command which does just this:
ess-transcript-clean-region
) The remaining command lines may then be copied to a source file or edit buffer for inclusion in a function definition, or may be evaluated directly (see section Sending code to the ESS process) using the code evaluation commands from S mode, also available in S Transcript Mode.
ESS has a few miscellaneous features, which didn't fit anywhere else.
ESS provides Font-Lock (see section `Using Multiple Typefaces' in The Gnu Emacs Reference Manual) patterns for Inferior S Mode, S Mode, and S Transcript Mode buffers.
To activate the highlighting, you need to turn on Font Lock mode in the
appropriate buffers. This can be done on a per-buffer basis with
M-x font-lock-mode, or may be done by adding
turn-on-font-lock
to inferior-ess-mode-hook
,
ess-mode-hook
and ess-transcript-mode-hook
(see section Customizing ESS with hooks). Your systems administrator may have done this for you
in `ess-site.el' (see section Customizing ESS).
The font-lock patterns are defined in three variables, which you may modify if desired:
TRUE
.
One of the main features of the S
package is its ability to
generate high-resolution graphics plots, and ESS provides a number of
features for dealing with such plots.
printer()
driver
This is the simplest (and least desirable) method of using graphics
within ESS. S's printer()
device driver produces crude character
based plots which can be contained within the ESS process buffer
itself. To start using character graphics, issue the S command
printer(width=79)
(the width=79
argument prevents Emacs line-wrapping at column
80 on an 80-column terminal. Use a different value for a terminal with
a different number of columns.) Plotting commands do not generate
graphics immediately, but are stored until the show()
command
is issued, which displays the current figure.
Of course, the ideal way to use graphics with ESS is to use a windowing
system. Under X windows, this requires that the DISPLAY environment
variable be appropriately set, which may not always be the case within
your Emacs process. ESS provides a facility for setting the value of
DISPLAY before the ESS process is started if the variable
ess-ask-about-display
is non-nil
. See section Customizing ESS, for details of this variable,
and see section Starting the ESS process for information on how to set the value of
DISPLAY when beginning an S session.
If you are running S-PLUS or R, you might consider installing the database files. From within (X)Emacs, "C-x d" to the directory containing ESS. Now:
M-x S+3
(get S-PLUS running. once you have reached the SPLUS 3.x prompt, do:)
M-x ess-create-object-name-db
(this will create the file: ess-s+3-namedb.el; if it isn't in the ESS directory, move it there).
Then, completions will be autoloaded and will not be regenerated for every session.
For R:
M-x R
(get R running. once you have reached the R prompt, do:)
M-x ess-create-object-name-db
(this will create the file: ess-r-namedb.el; if it isn't in the ESS directory, move it there).
ess-display-help-on-object
and list completion
cannot be used while the user is entering a multi-line command. The
only real fix in this situation is to use another ESS process.
ess-eval-
commands can leave point in the ESS process
buffer in the wrong place when point is at the same position as the last
process output. This proves difficult to fix, in general, as we need to
consider all windows with window-point
at the right place.
ess-keep-dump-files
is nil
.
ess-execute
causes ESS
to hang.
Please send bug reports, suggestions etc. to
The easiest way to do this is within Emacs by typing
M-x ess-submit-bug-report
This also gives the maintainers valuable information about your installation which may help us to identify or even fix the bug.
Note that comments, suggestions, words of praise and large cash donations are also more than welcome.
There is a mailing list for discussions and announcements relating to ESS. Join the list by sending an e-mail with "subscribe ess-help" (or "help") in the body to ess-help-request@stat.math.ethz.ch; contributions to the list may be mailed to ess-help@stat.math.ethz.ch. Rest assured, this is a fairly low-volume mailing list.
The purposes of the mailing list include
ESS[S] is the mode for editing S language files. This mode handles:
ESS[S] mode should be automatically turned on when loading a file with the suffices found in ess-site (*.R, *.S, *.s, etc). However, one will have to start up an inferior process to take advantage of the interactive features.
iESS (inferior ESS) is the mode for interfacing with active statistical processes (programs). This mode handles:
To start up iESS mode, use:
M-x S+3 M-x S4 M-x R
(for S-PLUS 3.x, S4, and R, respectively. This assumes that you have access to each). Usually the site will have defined one of these programs (by default S+3) to the simpler name:
M-x S
Note that R has some extremely useful command line arguments, -v and -n. To enter these, call R using a "prefix argument", by
C-u M-x R
and when ESS prompts for "Starting Args ? ", enter (for example):
-v 10000 -n 5000
Then that R process will be started up using "R -v 10000 -n 5000".
New for ESS 5.1.2 (and later): "S-elsewhere" command
The idea of "M-x S-elsewhere" is that we open a telnet (or rlogin) to another machine, call the buffer "*S-elsewhere*", and then run S on the other machine in that buffer. We do that by defining "sh" as the inferior-S-elsewhere-program-name. Emacs sets it up in a "*S-elsewhere*" iESS buffer. The user does a telnet or login from that buffer to the other machine and then starts S on the other machine. The usual C-c C-n commands from myfile.s on the local machine get sent through the buffer "*S-elsewhere*" to be executed by S on the other machine.
- edit transcript
- color and font highlighting based on syntax.
- resubmit multi-line commands to an active process buffer
- The ability to request help from an S process for variables and functions, and to have the results sent into a separate buffer.
- ability to switch between processes which would be the target of the buffer (for the above).
The first is preferred, and configured for. The second one can be retrieved again, by changing emacs variables.
1: (preferred by the current group of developers): The source code is real. The objects are realizations of the source code. Source for EVERY user modified object is placed in a particular directory or directories, for later editing and retrieval.
2: (older version): S objects are real. Source code is a temporary realization of the objects. Dumped buffers should not be saved. _We_strongly_discourage_this_approach_. However, if you insist, add the following lines to your .emacs file (GNU emacs uses the filename `~/.emacs' and Xemacs uses the filename `~/.xemacs/init.el' for the initialization file):
(setq ess-keep-dump-files 'nil) (setq ess-delete-dump-files t) (setq ess-mode-silently-save nil)
The second saves a small amount of disk space. The first allows for better portability as well as external version control for code.
We present some basic suggestions for using ESS to interact with S. These are just a subset of approaches, many better approaches are possible. Contributions of examples of how you work with ESS are appreciated (especially since it helps us determine priorities on future enhancements)! (comments as to what should be happening are prefixed by "##").
1: ## Data Analysis Example (source code is real) ## Load the file you want to work with C-x C-f myfile.s ## Edit as appropriate, and then start up S-PLUS 3.x M-x S+3 ## A new buffer *S+3:1* will appear. Splus will have been started ## in this buffer. The buffer is in iESS [S+3:1] mode. ## Split the screen and go back to the file editing buffer. C-x 2 C-x b myfile.s ## Send regions, lines, or the entire file contents to S-PLUS. For regions, ## highlight a region with keystrokes or mouse and then send with: C-c C-r ## Re-edit myfile.s as necessary to correct any difficulties. Add ## new commands here. Send them to S by region with C-c C-r, or ## one line at a time with C-c C-n. ## Save the revised myfile.s with C-x C-s. ## Save the entire *S+3:1* interaction buffer with C-c C-s. You ## will be prompted for a file name. The recommended name is ## myfile.St. With the *.St suffix, the file will come up in ESS ## Transcript mode the next time it is accessed from Emacs. 2: ## Program revision example (source code is real) ## Start up S-PLUS 3.x in a process buffer (this will be *S+3:1*) M-x S+3 ## Load the file you want to work with C-x C-f myfile.s ## edit program, functions, and code in myfile.s, and send revised ## functions to S when ready with C-c C-f ## or highlighted regions with C-c C-r ## or individual lines with C-c C-n ## or load the entire buffer with C-c C-l ## save the revised myfile.s when you have finished C-c C-s 3: ## Program revision example (S object is real) ## Start up S-PLUS 3.x in a process buffer (this will be *S+3:1*) M-x S+3 ## Dump an existing S object my.function into a buffer to work with C-c C-d my.function ## a new buffer named yourloginname.my.function.S will be created with ## an editable copy of the object. The buffer is associated with the ## pathname /tmp/yourloginname.my.function.S and will amlost certainly not ## exist after you log off. ## enter program, functions, and code into work buffer, and send ## entire contents to S-PLUS when ready C-c C-b ## Go to *S+3:1* buffer, which is the process buffer, and examine ## the results. C-c C-y ## The sequence C-c C-y is a shortcut for: C-x b *S+3:1* ## Return to the work buffer (may/may not be prefixed) C-x C-b yourloginname.my.function.S ## Fix the function that didn't work, and resubmit by placing the ## cursor somewhere in the function and C-c C-f ## Or you could've selected a region (using the mouse, or keyboard ## via setting point/mark) and C-c C-r ## Or you could step through, line by line, using C-c C-n ## Or just send a single line (without moving to the next) using C-c C-j ## To fix that error in syntax for the "rchisq" command, get help ## by C-c C-v rchisq 4: Data Analysis (S object is real) ## Start up S-PLUS 3.x, in a process buffer (this will be *S+3:1*) M-x S+3 ## Work in the process buffer. When you find an object that needs ## to be changed (this could be a data frame, or a variable, or a ## function), dump it to a buffer: C-c C-d my.cool.function ## Edit the function as appropriate, and dump back in to the ## process buffer C-c C-b ## Return to the S-PLUS process buffer C-c C-y ## Continue working. ## When you need help, use C-c C-v rchisq ## instead of entering: help("rchisq")
1. Suppose that you are primarily an SPLUS 3.4 user, occasionally using S version 4, and sick and tired of the buffer-name *S+3* we've stuck you with. Simply edit the "ess-dialect" alist entry in the essd-s+3.el and essd-s4.el files to be "S" instead of "S4" and "S+3". This will insure that all the inferior process buffer names are "*S*".
2. Suppose that you WANT to have the first buffer name indexed by ":1", in the same manner as your S-PLUS processes 2,3,4, and 5 (for you heavy simulation people). Then uncomment the line in ess-site (or add after your (require 'ess-site) or (load "ess-site") command in your .emacs file, the line:
(setq ess-plain-first-buffername nil)
)
3. Fontlocking sometimes fails to behave nicely upon errors. When Splus dumps, a mis-matched " (double-quote) can result in the wrong font-lock face being used for the remainder of the buffer.
Solution: add a " at the end of the "Dumped..." statement, to revert the font-lock face back to normal.
ESS[SAS] was designed for use with SAS. It is descended from SAS-mode which was originally developed by Cook. Those editing features and new advanced features are part of ESS[SAS]. The user interface of ESS[SAS] has similarities with ESS[S], the ESS interface for S, and to the SAS Display Manager. By emacs, we mean either GNU Emacs from the Free Software Foundation or XEmacs from the XEmacs Project.
ESS[SAS] mode was designed to aid the user in writing and maintaining input command files, such as myfile.sas, for SAS. These are files containing SAS statements. In a batch environment such files would be submitted to SAS by the operating system command:
sas myfile.sas
In a SAS window environment, these files would be brought into the "SAS: PROGRAM EDITOR" window and then submitted with the 'Local' 'Submit' menu commands.
The *SAS:1.log* buffer in ESStr mode corresponds to the file myfile.log in SAS batch usage and to the "SAS: LOG" window in the SAS window environment. All commands submitted to SAS, informative messages, warnings, and errors appear here.
The *SAS:1.lst* buffer in ESSlst mode corresponds to the file myfile.lst in SAS batch usage and to the "SAS: OUTPUT" window in the SAS window environment. All data related printed output from the PROCs appear in this window.
The iESS [SAS:1] buffer exists solely as a communications buffer. Files are edited in the myfile.sas buffer. The C-c C-r key in ESS[SAS] mode is the functional equivalent of bringing a file into the "SAS: PROGRAM EDITOR" window followed by the 'Local' 'Submit' menu commands. The user should never use this buffer directly.
The ESS[SAS] mode was written with two primary goals.
1. Using the emacs environment is desirable for users accessing a remote computer via a network or dial-up who can not use the native SAS window environment.
2. Using the emacs environment is desirable for local users as well due to the inherent efficiency of using the same superior interface all of the time.
The default settings of the inferior-SAS-args in essd-sas.el are
-stdio -linesize 80 -noovp -nosyntaxcheck
with the interpretations:
-stdio required to make the redirection of stdio work -linesize 80 keeps output lines from folding on standard terminals -noovp prevents error messages from printing 3 times -nosyntaxcheck permits recovery after syntax errors
In addition there are several parameters that can't be set in the command line. For these, we recommend the following line appear in your autoexec.sas in your home directory:
options noovp pagesize=60 linesize=80 formdlim=' ';
Interpretations
noovp prevents error messages from printing 3 time pagesize=60 standard printed page length instead of window length linesize=80 keeps output lines from folding on standard terminals formdlim=' ' blank replaces "C-l" formfeeds to prevent mostly empty pages
The noovp and linesize=80 appear in both the inferior-SAS-args and in the autoexec.sas. The redundancy means that these options are in effect for both SAS interactive and batch jobs.
ESS[SAS] is the mode for editing SAS language files. This mode handles:
- proper indenting, generated by both [Tab] and [Return]. - color and font choices based on syntax. - ability to send the contents of an entire buffer, a highlighted region, or a single line to an inferior SAS process. - ability to switch between processes which would be the target of the buffer (for the above). - ability to save and submit the file you are working on as a batch SAS process with a single keypress and to continue editing while it is runs in the background. - capability of killing the batch SAS process through the shell buffer or allow the SAS process to keep on running after you exit emacs. - single keypress navigation of .sas, .log and .lst files (.log and .lst files are automatically refreshed with each keypress).
ESS[SAS], the mode for editing SAS language files, is automatically turned on when editing a file with a ".sas" suffix (or other, if specified in ess-site). The batch processing keypress commands are enabled by default to use the same function keys that the SAS Display Manager uses. The interactive capabilities of ESS require you to start an inferior SAS process with M-x SAS (See section iESS[SAS]--Inferior ESS processes.)
At this writing (@essver{}), the indenting and syntactic highlighting are usually correct.
iESS (inferior ESS) is the mode for interfacing with active statistical processes (programs).
To start up iESS[SAS] mode, use:
M-x SAS
We plan to add
- The ability to request help from a process for variables and functions, and to have the results sent into a separate buffer. - completion of object names and file names.
MS Windows: See section ESS[SAS]--MS Windows.
Submission of a SAS batch job is dependent on your environment. ess-sas-submit-method is determined by your operating system and your shell. It defaults to 'sh unless you are running Windows or Mac Classic. Under Windows, it will default to 'sh if you are using bash for your shell rather than MS-DOS ('ms-dos). On Mac OS X, it will default to 'sh, but under Mac Classic AppleScript is used ('apple-script). You will also set this to 'sh if the SAS batch job needs to run on a remote machine rather than your local machine. This works transparently if you are editing the remote file via ange-ftp/EFS or tramp. However, if you are editing the file locally and transferring it back and forth with Kermit, you need some additional steps. First of all, start Kermit locally before remotely logging in. Execute the command ess-kermit-get. A local copy of the file will be created with the ess-kermit-prefix character prepended (the default is ":"). Also, note that the remote Kermit command is defined by ess-kermit-command.
The command used by the SUBMIT function key (F3 or F8) to submit a batch SAS job, whether local or remote, is ess-sas-submit-command which defaults to sas-program. sas-program is "invoke SAS using program file" for Mac Classic and "sas" otherwise. However, you may have to alter ess-sas-submit-command for a particular program, so it is defined as buffer-local (conveniently, you can set it in Local Variables: at the end of your program). The command line is also made of ess-sas-submit-pre-command, ess-sas-submit-post-command and ess-sas-submit-command-options (the last of which is also buffer-local). Here are some examples for your .emacs file (you may also use custom-ize):
(setq ess-sas-submit-pre-command "nohup") ;'sh default (setq ess-sas-submit-post-command "-rsasuser &") ;'sh default (setq ess-sas-submit-command "/usr/local/sas/sas") ;'sh example (setq ess-sas-submit-pre-command "start") ;'ms-dos default (setq ess-sas-submit-post-command "-rsasuser -icon") ;'ms-dos default (setq ess-sas-submit-command "c:/progra~1/sas/sas.exe") ;Windows example (setq ess-sas-submit-command "c:\\progra~1\\sas\\sas.exe");Windows example
There is a built-in delay before a batch SAS job is submitted when using a Unix shell under either Unix or Windows. This is necessary in many cases since the shell might not be ready to receive a command. This delay is currently set high enough so as not to be a problem on any system. But, there may be cases when it needs to be set higher, or could be set much lower to speed things up. You can over-ride the default in your .emacs file by (the default of 5 seconds is shown):
(setq ess-sleep-for 5)
The description of the setup for function keys for batch processing of SAS files is unavoidably more complex than we wish it were. The actual use of the function keys is simple. There are five distinct options:
1. (default) Function keys in ESS[SAS] modes do whatever they normally do in other emacs modes. Many users will have defined some of the keys [f2]-[f12] in their .emacs or _emacs file, or will have installation-wide definitions in their site-start.el file. By default, ESS does not override those definitions. This default is intended to make ESS[SAS] mode behave similarly to other emacs modes.
2,3,4,5. Users who are primarily familiar with SAS, and who are learning emacs as a way to approach SAS, will likely want to duplicate the function key capabilities that SAS Institute provides with its Display Manager. There are still options.
The distinction between local and global appears subtle. If you want the ESS[SAS] definitions to work when you are in *shell* or when editing files other than the file extensions that SAS recognizes, you will most likely want to use the global definitions. If you want your function keys to understand SAS batch commands when you are editing SAS files, and to behave normally when editing other files, then you will choose the local definitions.
The option can be chosen by the person installing ESS for a site or by an individual.
;;2; (setq ess-sas-local-unix-keys t) ;;3; (setq ess-sas-local-pc-keys t)ESS[SAS] Function keys are available in all emacs modes if you uncomment either of the following lines in your ess-site.el:
;;4; (setq ess-sas-global-unix-keys t) ;;5; (setq ess-sas-global-pc-keys t)The names -unix- and -pc- have nothing to do with the operating system that you are running. Rather they mimic the definitions that the SAS Display Manager uses by default on those platforms.
(load "ess-site")line. If your site manager has chosen an option 2,3,4,5 you don't want, you must turn it off before selecting a different option. To turn off an option, add the appropriate line (uncommented) to your .emacs (_emacs) file.
;;2; (setq ess-sas-local-unix-keys nil) ;;3; (setq ess-sas-local-pc-keys nil) ;;4; (setq ess-sas-global-unix-keys nil) ;;5; (setq ess-sas-global-pc-keys nil)
Finally, we get to what the function keys actually do. You may recognize some of the Short Names as SAS Display Manager commands (they are in all capitals).
Unix PC Short Name Long Description F2 F2 refresh revert the current buffer with the file of the same name if the file is newer than the buffer. F3 F8 SUBMIT save the current .sas file (which is either the .sas file in the current buffer or the .sas file associated with the .lst or .log file in the current buffer) and submit the file as a batch SAS job. C-F3 C-F8 SUBMIT-REGION Write region to temporary file, and submit to SAS. F4 F5 PROGRAM switch buffer to .sas file. F5 F6 LOG switch buffer to .log file, `refresh' and goto next error message, if any. C-F5 C-F6 APPEND-TO-LOG Append ess-temp.log to the current .log file. F6 F7 OUTPUT switch buffer to .lst file and `refresh'. C-F6 C-F7 APPEND-TO-OUTPUT Append ess-temp.lst to the current .lst file. F7 F4 filetype-1 switch buffer to filetype-1 (defaults to .txt) file and `refresh'. F8 F3 shell switch buffer to shell. F9 F9 VIEWTABLE open an interactive FSEDIT/FSBROWSE session on the SAS dataset near point F10 F10 toggle-log toggle ESS[SAS] for .log files; may be useful for certain debugging situations F11 F11 filetype-2 switch buffer to filetype-2 (defaults to .dat) file and refresh. F12 F12 viewgraph open a GSASFILE near point for viewing either in emacs or with an external viewer
Besides the keys that mimic SAS Display Manager commands, six other keys have been provided for convenience.
`shell' switches you to the *shell* buffer where you can type operating system commands. This is especially helpful if you would like to kill a SAS batch job.
F2 performs the `refresh' operation on the current buffer. `refresh' compares the buffer date/time stamp with the file date/time stamp and replaces the buffer with the file if the file is newer. This is the same operation that is automatically performed when LOG, OUTPUT, `filetype-1' or `filetype-2' are pressed.
`filetype-1' switches you to a file with the same file root as your .sas file, but with a different extension; .txt by default. You can over-ride the default, by specifying a different extension in your .emacs file. For example, for `filetype-1':
(setq ess-sas-suffix-1 "txt")
`filetype-2' is similar, except it is .dat by default.
F10 toggles ESS[SAS] mode for .log files which is off by default (technically, it is SAS-log-mode, but it looks the same). The syntax highlighting can be helpful in certain debugging situations, but large .log files will take a long time to render.
F12 will open a GSASFILE near point for viewing either with emacs or with an external viewer. Depending on your version of emacs and the operating system you are using, emacs may support .gif and .jpg files internally. You may need to change the following two variables for your own situation:
(setq ess-sas-graph-suffix-regexp "[.]\\(e?ps\\|gif\\|jpe?g\\|tiff?\\)") (setq ess-sas-image-viewer "kodakimg") ;; external viewer
Again, two options.
The TAB key is bound by default to sas-indent-line. This function is used to syntactically indent SAS code so PROC and RUN are in the left margin, other statements are indented 4 spaces from the margin, continuation lines are indented 4 spaces in from the beginning column of that statement. This is the type of functionality that emacs provides in most programming language modes. This functionality is equivalent to uncommenting the following line in ess-site.el:
;;; (setq ess-sas-edit-keys-toggle 0)
ESS provides an alternate behavior for the TAB key that makes it behave as it does on non-emacs terminals, i.e. move the cursor to the next tab stop. The alternate behavior also provides a backwards TAB key: C-TAB. This functionality is obtained by uncommenting the following line in ess-site.el:
;;; (setq ess-sas-edit-keys-toggle 1)
Under the alternate behavior, the TAB key is bound to tab-to-tab-stop and the tab stops are set by default at multiples of 4.
We present one scenario for using ESS to interact with SAS. Contributions of examples of how you work with ESS are appreciated (especially since it helps us determine priorities on future enhancements)! (comments as to what should be happening are prefixed by "##").
Batch SAS (-unix-keys illustrated, pc-keys in the comments)
## Find the file you want to work with C-x C-f myfile.sas ## myfile.sas will be in ESS[SAS] mode ## Edit as appropriate, then save and submit the batch SAS job. ## -pc- F8 F3 ## The job runs in the shell buffer while you continue to edit ## myfile.sas. If you are running a Unix shell under Unix or ## Windows, the message buffer will notify you with a shell ## notification when the job is complete. If so, then you ## will also have the option of terminating the batch job ## before it is finished. ## -pc- F3 F8 ## In any case, you may want to visit the .log while the process ## is still running (unix only) or when it is done and check for ## error messages ## (you will be taken to the next error message, if any). ## The .log will be refreshed and you will be placed in it's buffer. ## -pc- F6 F5 ## Now, refresh the .lst and go to it's buffer. ## -pc- F7 F6 ## If you wish to make changes, go to the .sas file with ## -pc- F5 F4 ## make your editing changes and then submit again.
Interactive SAS
## Find the file you want to work with C-x C-f myfile.sas ## myfile.sas will be in ESS[SAS] mode ## Edit as appropriate, and then start up SAS with the cursor in ## the myfile.sas buffer M-x SAS ## Four buffers will appear on screen: ## myfile.sas in ESS[SAS] mode # your source file ## *SAS:1* in iESS [SAS:1] mode # ESS communication buffer ## *SAS:1.log* in Shell [] ESStr mode # SAS log information ## *SAS:1.lst* in Shell [] ESSlst mode # SAS listing information ## If you would prefer each of the four buffers to appear in its ## own individual frame, you can arrange for that. Place the ## cursor in the buffer displaying myfile.sas. Enter the ## sequence: C-c C-w ## The cursor will normally be in buffer myfile.sas. ## If not, put it there: C-x b myfile.sas ## Send regions, lines, or the entire file contents to SAS ## (regions are most useful). A highlighted region will normally ## begin with the keywords 'DATA' or 'PROC' and end with the ## keyword 'RUN;' C-c C-r ## Information appears in the log buffer, analysis results in the ## listing buffer. In case of errors, make the corrections in the ## myfile.sas buffer and resubmit with another C-c C-r ## PROC GPLOT graphs will normally be produced in a postscript ## file and be viewed later. Include the lines /* required gsoptions for batch files */ /* comment out these lines for interactive use on X-terminals*/ filename grafout 'temp.ps'; goptions device=ps gsfname=grafout gsfmode=append gaccess=sasgastd; ## in myfile.sas. ## PROC PLOT graphs can be viewed in the listing buffer. You may ## wish to control the vertical spacing to allow the entire plot ## to be visible on screen, for example, by proc plot; plot a*b / vpos=25; ## At the end of the session you may save the log and listing ## buffers with the usual C-x C-s commands. You will be prompted ## for a file name. Typically, the names myfile.log and mfile.lst ## will be used. You will almost certainly want to edit the saved ## files before including them in a report. The files are ## read-only by default. You can make them writable by the emacs ## command C-x C-q. ## At the end of the session, the input file myfile.sas will ## typically have been revised. You can save it. It can be used ## later as the beginning of another iESS[SAS] session. It can ## also be used as a batch input file to SAS. ## The *SAS:1* buffer is strictly for ESS use. The user should ## never need to read it or write to it. Refer to the .lst and ## .log buffers for monitoring output!
Here is a typical myfile.sas:
title 'Analysis of Case 0502'; data case0502; infile '/home/public/stat/Data/case0502.asc' firstobs=2; input percent code; run; proc glm; class code; model percent=code /ss1; run;
1. MS Windows users. - M-x SAS does not work on MS Windows. In order to run SAS inside an Emacs buffer it is necessary to start SAS with the -stdio option. SAS does not support the -stdio option on Windows. 2. If M-x SAS gives weird errors upon startup, check the following: - you are running Windows: SAS does not support stdio on Windows - ess-sas-sh-command (in the ESS source directory) needs to be executable (solution: "chmod ugo+rx ess-sas-sh-command"). - sas isn't in your executable path (verify using "which sas" from a shell command-line) - you need a copy of SAS (we can't solve this) 3. M-x SAS starts up SAS in the window system (motif, for example), instead of starting it up in the emacs buffers. Probably the unix command "sas" on your system calls a local script which in turn calls the sas executable. The fix is to call the sas executable directly. Change the line in ess-sas-sh command from:sas </dev/tty 1>$stdout 2>$stderr $to a call to the complete path name of the sas executable on your system, for example:/usr/local/sas612/sas </dev/tty 1>$stdout 2>$stderr $To find the complete path name on your system, you can execute the line (from the unix prompt):find / -name 'sas' -exec ls -ld {} \;and expect a response similar to the following-rwxr-xr-x 1 sas sas 2441216 Sep 9 1997 /usr/local/sas612/sas
M-x SAS
does not work on MS Windows. In order to run SAS inside
an Emacs buffer it is necessary to start SAS with the -stdio
option.
SAS does not support the -stdio
option on Windows.
The following section details those steps necessary to get ESS running on your system.
We now discuss installation, which might happen under Unix or Microsoft Windows. First, we discuss Unix installation. See section Unix installation.
For Microsoft Windows Installation please skip to the See section Microsoft Windows installation.
gunzip ess-@essver{}.tar.gz tar xvf ess-@essver{}.tar
(or:Thegunzip < ess-@essver{
.tar.gz | tar xvf -} ). (or using GNU tar:tar zxvf ess-@essver{
.tar.gz}).
tar
command will create the subdirectory ess-@essver{} and unarchive
the files there.
If you are using GNU Emacs 19.29, decompress/unarchive
`ESSDIR/ess-@essver{'/lisp/19.29.tar.gz},
read `ESSDIR/ess-@essver{'/lisp/19.29/README}, follow the instructions
and you might be able to get ESS to work.
Please note that GNU Emacs 19.29 is no longer supported.
For a list of supported versions of emacs, see See section Requirements.
(load "ESSDIR/ess-@essver{}/lisp/ess-site")to your user or system installation file (GNU Emacs uses `$HOME/.emacs' and XEmacs uses `$HOME/.xemacs/init.el' for the user initialization file. GNU Emacs uses default.el or site-init.el and XEmacs uses site-start.el for the system installation file). Alternatively, if ess-site.el is in your current Lisp path, you can do:
(require 'ess-site)to configure emacs for ESS.
C-x d
to the
directory containing ESS. Now:
M-x S+6get running. once you have reached the SPLUS prompt, do:
M-x ess-create-object-name-db(this will create the file `ess-s+6-namedb.el'; if it isn't in the ESS directory, move it there). Then, completions will be autoloaded and will not be regenerated for every session. For R, do the same, using
M-x Rand then
M-x ess-create-object-name-db
creating
`ess-r-namedb.el'; if it isn't in the ESS directory, move it there).
make allIf this works, then you might try:
make installThis will install the info files (and the lisp files, if they are to go in another directory). Don't forget to edit the file `dir' in the info directory specified by
INFODIR
in `doc/Makefile'. See
the sample `dir' file for an example of the line to add.
If you are using XEmacs, you might do:
make EMACS=xemacs alland then
make EMACS=xemacs installinstead of editing the Makefile. Note that you might need to use GNU make for everything to work properly An alternative, if you are running XEmacs and have access to the XEmacs system directories, would be to place the directory in the site-lisp directory, and simply type
make all
(and copy the
documentation as appropriate).
For GNU Emacs, you would still have to move the files into the top level
site-lisp directory.
For Microsoft Windows installation, please follow the next steps: (see separate instructions above for UNIX See section Unix installation.
cd c:\emacsExtract the files from the distribution, which will unpack into a subdirectory, `ess-@essver{'}.
gunzip ess-@essver{}.tar.gz tar xvf ess-@essver{}.tar (or:Thegunzip < ess-@essver{
.tar.gz | tar xvf -} ). (or: from the zip file:unzip ess-@essver{
.zip})
tar
command will extract files into the current directory.
Do not create `ess-@essver{'} yourself, or you will get an extra level
of depth to your directory structure.
path=%PATH%;c:\progra~1\spls2000\cmdOn Windows NT/2000, add the directories to the PATH using the MyComputer 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
progra~1
and not the long version with embedded blanks. Use
backslashes "\".
(load "/PATH/ess-site")to your .emacs (or _emacs) file (or default.el or site-init.el, for a site-wide installation). Replace
/PATH
above with the
value of ess-lisp-directory as defined in `ess-site.el'. Use
forwardslashes /
.
(GNU Emacs uses the filename `%HOME%/.emacs' and
XEmacs uses the filename `%HOME%/.xemacs/init.el'
for the initialization file.)
M-x S+6
(or M-x S
).
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. Similarly for S-PLUS 6.x. Send lines or regions
from the emacs buffer containing your S program (for example,
`myfile.s') to the S-Plus Commands Window with the
C-c C-n
or C-c C-r
keys.
Run S-PLUS 6.x or 2000 inside an emacs buffer
M-x Sqpe+6You 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. Similarly for S-PLUS 6.x. Send lines or regions from the emacs buffer containing your S program (for example, `myfile.s') to the *S+6* buffer with the
C-c C-n
or C-c C-r
keys. You do not have access to
interactive graphics in
this mode. You get Unix-like behavior, in particular the entire
transcript is available for emacs-style search commands.
If you wish to run R, you can start it with:
M-x RXLispStat can not currently be run with
M-x XLSHopefully, this will change. However, you can still edit with emacs, and cut and paste the results into the XLispStat *Listener* Window under Microsoft Windows. SAS for Windows uses the batch access with function keys that is described in `doc/README.SAS'. The user can also edit SAS files in an
ESS[SAS]
buffer and than manually copy and paste them into
an Editor window in the SAS Display Manager.
For Windows, inferior SAS in an iESS[SAS]
buffer does not work
on the local machine. It does work over a network connection to
SAS running on a remote Unix computer.
Reason: we use ddeclient to interface with programs and SAS doesn't
provide the corresponding ddeserver capability.
C-x d
to
the directory containing ESS. Now:
M-x Sqpe+6(get running. once you have reached the SPLUS prompt, do:)
M-x ess-create-object-name-db(this will create the file `ess-s+6-namedb.el'; if it isn't in the ESS directory, move it there). Then, completions will be autoloaded and will not be regenerated for every session. For R, do the same, using
M-x Rand then
M-x ess-create-object-name-db
creating
`ess-r-namedb.el'; if it isn't in the ESS directory, move it
there).
ESS version 5.1.n (n >= 2) works best with either GNU Emacs version 20.3 or higher, or XEmacs version 20.0 or higher. It has been most thoroughly tested with:
on the following platforms
with the following versions of emacs
If you run the S program (from the shell) with a command other than
`Splus' you will need to set the variable
inferior-ess-program
to the name of the appropriate program by including a line such as
(setq inferior-ess-program "S+")
in your `.emacs' file (substituting `S+' for the name of your S program.)
If you need to call this program with any arguments, the variable you
need to set is dependent on the value of inferior-ess-program
; for
example if it is "Splus"
, set the variable
inferior-Splus-args
to a string of arguments to the Splus
program. If
inferior-ess-program
has some other value, substitute the
Splus
part of inferior-Splus-args
with the appropriate
program name. There aren't many instances where you need to call S
with arguments, however: in particular do not call the S program
with the `-e' command-line editor argument since ESS provides this
feature for you.
If you are running Splus (the enhanced version of S from Statsci) you
may also need to set the variable S-plus
to t
. If your
value of inferior-ess-program
is "S+"
or Splus
this
will not be necessary, however; S-plus
defaults to t
in
this case.
Finally, if you use a non-standard prompt within S, you will need to set the
variable inferior-ess-prompt
to a regular expression which will match both the primary prompt ("> "
by default) and the continuing prompt (default of "+ "
.) The
default value of this variable matches S's default prompts. For example,
if you use ("$ "
) as your primary prompt (you have
options(prompt="$ ")
in your .First
function), add the
following line to your `.emacs':
(setq inferior-ess-prompt "^\\(\\+\\|[^\\$]*\\$\\) *")
You will also need to set the variable inferior-ess-primary-prompt
to a regular expression which matches the primary prompt only. Do not
anchor the regexp to the beginning of the line with `^'. Once
again, the default value matches S's default prompt; in the example
above the appropriate value would be "[^\\$]*\\$ *"
.
Once these variables are set appropriately, ESS should work on any system.
ESS can be easily customized to your taste simply by including the appropriate lines in your `.emacs' file. There are numerous variables which affect the behavior of ESS in certain situations which can be modified to your liking. Keybindings may be set or changed to your preferences, and for per-buffer customizations hooks are also available.
ESS is easily customizable by means of setting variables in your `.emacs' file. In most cases, you can change defaults by including lines of the form
(setq variable-name value)
in your `.emacs'.
In what follows, variable names will be listed along with their descriptions and default values. Just substitute the variable name and the new value into the template above.
t
nil
value, then every time ESS is
run with M-x S
you will be prompted for a directory to use as the working directory for
your S session; this directory should have a `.Data'
subdirectory.
If the value of ess-ask-for-ess-directory
is nil
, the
value of S-directory
is used as the working directory.
ess-ask-for-ess-directory
is nil
, and the
default when prompting for a directory if it is not. For example, you
may wish to set this to the value of the current buffer's working
directory before starting S by adding the following line to your
`.emacs' file (see section Customizing ESS with hooks)
(setq ess-pre-run-hook '((lambda () (setq S-directory default-directory))))
nil
nil
value, then every time ESS is
run with M-x S
you will be asked for a value for the DISPLAY
environment
variable
to be used in the current S session. If this variable is not set
correctly, S will not be able to create any windows under the X
windowing environment.
Completion is provided over the X-displays-list
variable; the
default is the current value of DISPLAY
. This feature is useful
is you often run S on a different display than that of the machine you
are running S from. If
ess-ask-about-display
is nil
, the current value of
DISPLAY
is used.
'(":0.0")
DISPLAY
environment variable,
provided for completion when prompting for such a value.
t
nil
value, then
dumping a non-existent object will result in the edit buffer containing
a skeleton function definition, ready for editing.
"/tmp/"
nil
.
object_name.S
nil
t
nil
, then TAB in the edit buffer always indents the
current line, regardless of the position of point in the line.
Otherwise, indentation is only performed if point is in the lines
indentation, and a tab character is inserted is point is after the first
nonblank character.
nil
nil
means automatically newline before and after braces
inserted in S code.
The following variables control amounts of indentation. These variables automatically become buffer-local in any ESS buffer, and so setting any of these variables has effect in the current buffer only.
ess-continued-statement-offset
.
foo
when it is called as
the value of an argument to another function in
arg=foo(...)
form. If not number, the statements are indented at
open-parenthesis following foo
.
expression()
specified in
obj <- expression(...)
form. If not a number, the statements are indented at open-parenthesis following `expression'.
else
clause with respect to the
corresponding if
.
In addition, a number of default styles are defined for you (in
ess-style-alist
):
DEFAULT
GNU
, BSD
, K&R
, CLB
, and C++
.
See `ess-cust.el' for the complete definitions of the styles.
See section Creating or modifying S objects, for more details.
nil
nil
, then the ess-execute-
commands (see section Other commands provided by inferior-ESS)
output to a temporary buffer. Otherwise, the
output goes to the ESS process.
nil
nil
, then the ess-eval-
commands (see section Creating or modifying S objects) echo the S commands in the process buffer by default. In any
case, passing a prefix argument to the eval command reverses the meaning
of this variable.
ESS provides the following hooks:
ESS
is run.
ess-eval-visibly
, say.
ESS provides a separate keymaps (keymap variables) for ESS process buffers, edit buffers and for help buffers. The key bindings in the edit buffers further depend on the language and dialect in use.
comint-mode-map
are automatically inherited.
ess-help-sec-map
is the keymap for the `s' prefix key. Keys defined in
ess-help-sec-keys-alist
are automatically inserted into this
keymap
when ESS is loaded.
Jump to:
Jump to: c
Jump to: . - a - b - c - d - e - f - g - h - i - k - l - m - n - o - p - q - r - s - t - u - v - w - x
.First
function
Jump to: ( - a - b - c - d - e - i - o - p - q - s - x
This document was generated on 3 July 2002 using texi2html 1.56k.