User manual

Chapter 10: Developing with ESS 53
of-open, i.e. C-u C-c C-e C-t, visit the generated HTML file instead. Requires the
Roxygen and tools packages to be installed.
[Command]ess-roxy-previous-entry
C-c C-o p Go to start of the Roxygen entry above point.
[Command]ess-roxy-next-entry
C-c C-o n Go to end of the Roxygen entry above point.
[Command]ess-roxy-hide-all
C-c C-o C-h Use the hideshow mode to fold away the visibility of all Roxygen entries.
Hide-show support must be enabled for this binding to get defined.
ESS also advises the following standard editing functions in order to make Roxygen
editing more intuitive:
TAB ess-R-complete-object-name Complete Roxygen tag at point. E.g. doing
TAB when the point is at the end of @par completes to @param.
M-h mark-paragraph If the transient mark mode is active, place mark and point at
start end end of the field at point and activate the mark.
TAB ess-indent-command If hide-show support is enabled, fold away the visibility
of the Roxygen entry at point.
M-q fill-paragraph Fill the Roxygen field at point.
C-a move-beginning-of-line Move to the point directly to the right of the Rox-
ygen start string.
RET newline-and-indent Insert a new line and the Roxygen prefix string.
10.3 ESS developer
Usual ESS evaluation commands, See Chapter 5 [Evaluating code], page 34, send portions
of the current buffer for the evaluation in the current environment (usually R_GlobalEnv).
Often, in process of the developing packages with namespaces, it is necessary to evaluate
code directly in the package’s environment or its namespace. The ess-developer utility
provides such a functionality with minimal disruption of the usual ESS work-flow.
To understand how ess-developer works you must be familiar with namespace system
in R. In a nutshell, all objects defined in a package ’foo’ are stored in an environment
called ’namespace:foo’. Parent environment of ’namespace:foo’ is an environment ’im-
ports:foo’ which contains copies of all objects from other packages which ’foo’ imports.
Parent environment of ’imports:foo’ is the ’namespace:base’. Parent environment of ’names-
pace:base’ is .GlobalEnv. Thus functions and methods stored in ’namespace:foo’ see all the
objects in .GlobalEnv unless shadowed by objects in ’imports:foo’, ’namespace:base’, or
’namespace:foo’ itself. There is another environment associated with ’foo’ - ’package:foo’.
This environment stores *copies* of exported objects from ’namespace:foo’ and is placed
on the search() path, i.e. if ’foo’ is loaded and if you start with .GlobalEnv and iter-
atively call parent.env() you will get eventually to ’package:foo’. Thus all methods and
functions defined in .GlobalEnv can "see" objects in ’package:foo’ environment. See also
http://cran.r-project.org/doc/manuals/R-ints.html#Namespaces.