Managing Profiles in Rgedit
(c) 2012, Dan Dediu
Table of Contents
Introduction
The profile editor
Introduction
Profiles are introduced in version 0.8 and allow Rgedit to flexibly interact with R or even other command-line interactive programs such as Octave, locally or remotely through, for example, ssh.
Profiles have the following components:
- name: this is the profile's user-friendly name and must be unique (for example, "My custom-built R");
- cmd: represents the actual command line (including options) used to start an interactive session (for example, "/opt/R-optimized/R --no-save --no-restore");
- local: a boolean specifying if the profile is to be run locally or remotely (for example, True);
- default: is the profile
the default profile? There can be a single default profile and this
will be used implicitely in any new rgedit tab/session (for example, False);
- setwd: the command used
to change the current (working) folder (directory) taking as single
parameter (identified in standard Python string notation as "%s") the path, or None if no such command should be run (for example, "setwd(%s)");
- init-script: a boolean
value specifying if the init script containing various R routines used
by rgedit will called on a new session (for example, True);
- help-type: the help system used by the session; can be one of "HTML", "Text", "Default" or "Custom" (in which case the "help-custom-command" attribute must be given);
- help-custom-command: the actual commands to be run for a custom help system or None if not applicable;
- prompt: the prompt symbol (for example "> ");
- prompt-cmd: the actual command used to set the prompt symbol given as the only parameter (for example, "options( prompt="%s" )");
- continue: the prompt-continuation symbol (for example "+ ");
- continue-cmd: the actual command used to set the prompt continuation symbol given as the only parameter (for example, "options( continue="%s" )");
- source-cmd: the actual
command used to send a file containing commands to the interpreter
(taking as parameter the file path), or, if no such thing, None (for example, "source("%s",echo=TRUE,print.eval=TRUE,max.deparse.length=500000,local=TRUE)");
- quit-cmd; the command used to finish a session (for example "q()");
- comment: the comment character (for example, "#").
There always is a built-in profile (guaranteed to be always present in any rgedit installation and using a standard R installation) defined as:
Attribute
|
Value
|
name |
built-in
|
cmd |
R --no-save --no-restore
|
local |
True
|
default |
True
|
setwd |
setwd(%s)
|
init-script |
True
|
help-type |
HTML
|
help-custom-command |
None
|
prompt |
>
|
prompt-cmd |
options( prompt="%s" )
|
continue |
+
|
continue-cmd |
options( continue="%s" )
|
source-cmd |
source("%s",echo=TRUE,print.eval=TRUE,max.deparse.length=500000,local=TRUE)
|
quit-cmd |
q()
|
comment |
#
|
Below is an example of a profile using a local installation of GNU Octave:
Attribute
|
Value
|
name |
octave
|
cmd |
octave
|
local |
True
|
default |
False
|
setwd |
chdir %s
|
init-script |
False
|
help-type |
Default
|
help-custom-command |
None
|
prompt |
>
|
prompt-cmd |
PS1( "%s" )
|
continue |
+
|
continue-cmd |
PS2( "%s" )
|
source-cmd |
source("%s")
|
quit-cmd |
quit
|
comment |
#
|
And, finally, an example of a remote R session thorugh two ssh
hops (please note that the hostnames are fictious but this is based on
my current remote setup!). For remote sessions is probably advisable to
fall back on the text help (no remote browsers), no automatic setwd (as the local
and remote paths will be probably different, meaning that the user should be careful to manually change the working directory), and no source (as local
temp files are not directly accessible on the remote host, meaning that small pieces of text can be send to the console at any given time):
Attribute
|
Value
|
name |
remote R through chained ssh
|
cmd |
ssh -X -t user@host1 ssh -X -t host2 "R --no-save --no-restore"
|
local |
False
|
default |
False
|
setwd |
None
|
init-script |
True
|
help-type |
Text
|
help-custom-command |
None
|
prompt |
>
|
prompt-cmd |
options( prompt="%s" ) |
continue |
+
|
continue-cmd |
options( continue="%s" )
|
source-cmd |
None
|
quit-cmd |
q()
|
comment |
#
|
Thus, the profiles mechanism is quite flexible an can accomodate at
least GNU octave (a requested extenssion) and remote sessions (a setup
that is probably not uncommon). I'm pretty sure other uses ca be found
:)
The profile editor
Below is a screen shot
of the profile editor:
Basically, the profile editor allows the user to edit, delete or add profiles using a simple GUI.
- Editing is simple and ivolves toggling radio buttons and check boxes and double-clicking on text fields to edit the text. The built-in profile cannot be edited.
- To remove the currently selected profile press the "Delete profile" button. The built-in profile cannot be removed.
- To add
a new profile, press the "Add profile" button and select a template to
use by pressing one of the buttons; of course everything can be
customized afterwards...
Please note some conventions:
- The special value "None" must be given as "<None>";
- The changed values will be validated on pressing ENTER or any of the buttons (except Cancel);
- The strings are case-sensitive.