[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

12. Other features of ESS

ESS has a few miscellaneous features, which didn't fit anywhere else.

12.1 Syntactic highlighting of buffers  
12.2 Using graphics with ESS  
12.3 Imenu  Support for Imenu in ESS
12.4 Toolbar  Support for toolbar in ESS
12.5 TAGS  Using TAGS for S files
12.6 Rdired  Directory editor for R objects

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

12.1 Syntactic highlighting of buffers

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 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. Your systems administrator may have done this for you in `ess-site.el' (see section A. Customizing ESS).

The font-lock patterns are defined in three variables, which you may modify if desired:

Variable: inferior-ess-font-lock-keywords
Font-lock patterns for Inferior ESS Mode. The default value highlights prompts, inputs, assignments, output messages, vector and matrix labels, and literals such as `NA' and TRUE.

Variable: ess-mode-font-lock-keywords
Font-lock patterns for ESS programming mode. The default value highlights function names, literals, assignments, source functions and reserved words.

Variable: ess-trans-font-lock-keywords
Font-lock patterns for ESS Transcript Mode. The default value highlights the same patterns as in Inferior ESS Mode.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

12.2 Using graphics with ESS

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.

12.2.1 Using ESS with the printer() driver  The printer() graphics driver
12.2.2 Using ESS with windowing devices  The X11() (and other X-windows based) driver
12.2.3 Java Graphics Device  

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

12.2.1 Using ESS with the 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

(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.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

12.2.2 Using ESS with windowing devices

Of course, the ideal way to use graphics with ESS is to use a windowing system. Under X11, 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.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

12.2.3 Java Graphics Device

S+6.1 and newer on Windows contains a java library that supports graphics. Send the commands:


to start the graphics driver. This allows you to use ESS for both interaction and graphics within S-PLUS. (Thanks to Tim Hesterberg for this information.)

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

12.3 Imenu

Imenu is an Emacs tool for providing mode-specific buffer indexes. In some of the ESS editing modes (currently SAS and S), support for Imenu is provided. For example, in S mode buffers, the menubar should display an item called "Imenu-S". Within this menubar you will then be offered bookmarks to particular parts of your source file (such as the starting point of each function definition).

Imenu works by searching your buffer for lines that match what ESS thinks is the beginning of a suitable entry, e.g. the beginning of a function definition. To examine the regular expression that ESS uses, check the value of imenu-generic-expression. This value is set by various ESS variables such as ess-imenu-S-generic-expression.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

12.4 Toolbar

The R and S editing modes have support for a toolbar. This toolbar provides icons to act as shortcuts for starting new S/R processes, or for evaluating regions of your source buffers. The toolbar should be present if your emacs can display images. See section A. Customizing ESS, for ways to change the toolbar.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

12.5 TAGS

The Emacs tags facility can be used to navigate around your files containing definitions of S functions. This facility is independent of ESS usage, but is written here since ESS users may wish to take advantage of TAGS facility. Read more about emacs tags in an emacs manual.

Etags, the program that generates the TAGS file, does not yet know the syntax to recognise function definitions in S files. Hence, you will need to provide a regexp that matches your function definitions. Here is an example call (broken over two lines; type as one line) that should be appropriate.

etags --language=none
--regex='/\([^ \t]+\)[ \t]*<-[ \t]*function/\1/' *.R

This will find entries in your source file of the form:

some.name <- function

with the function name starting in column 0. Windows users may need to change the single quotes to double quotes.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

12.6 Rdired

Ess-rdired provides a dired-like buffer for viewing, editing and plotting objects in your current R session. If you are used to using the dired (directory editor) facility in Emacs, this mode gives you similar functionality for R objects.

To get started, first make sure you can load ess-rdired. Add the following to your .emacs and then restart emacs.

(autoload 'ess-rdired "ess-rdired" 
  "View *R* objects in a dired-like buffer." t)

Start an R session with M-x R and then store a few variables, such as:

s <- sin(seq(from=0, to=8*pi, length=100))
x <- c(1, 4, 9)
y <- rnorm(20)
z <- TRUE

Then use M-x ess-rdired to create a buffer listing the objects in your current environment and display it in a new window:

            mode length
  s      numeric    100
  x      numeric      3
  y      numeric     20
  z      logical      1

Type C-h m or ? to get a list of the keybindings for this mode. For example, with your point on the line of a variable, `p' will plot the object, `v' will view it, and `d' will mark the object for deletion (`x' will actually perform the deletion).

[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated by XEmacs Webmaster on September, 16 2005 using texi2html