Invoke ed Text Editor

DESCRIPTION:

Invokes the ed text editor on a S-PLUS object.

USAGE:

ed(data=<<see below>>, file=tempfile("ed."), editor="ed", 
   error.expr=<<see below>>) 

OPTIONAL ARGUMENTS:

data
any S-PLUS object. If data is missing, then a file is to be re-edited after it has failed to evaluate.
file
the name of the file on which the object should be written while the editing is done.
editor
the name of the text editor that will be invoked. By having this as an argument, it is easy to write other editor functions that can use ed as a building block. See, for example, function vi.
error.expr
Expression to be evaluated on error, typically one which prints a message. Of interest primarily to new editor functions which build on ed. See the examples.

VALUE:

the edited value of the object.

SIDE EFFECTS:

NONE.

DETAILS:

It is important to realize that ed does not change data; the returned value must be reassigned in order to save your editing changes, as in the example.

If errors resulted during the evaluation of the expression containing the editing, the file is retained and calling ed with no arguments will allow re-editing the file. This is typically useful if editing a function definition produced a syntax error.

SEE ALSO:

.

EXAMPLES:

  ttt <- ed(ttt) 
  ttt <- ed(ttt)    # now leave a syntax error in the file 
Syntax error: ... 
Errors occurred; Use a command like: 
        my.object <- ed() 
to re-edit this object. 
  ttt <- ed() # after an editing error occurred 
# example using error.expr 
  ttt <- ed(ttt, error.expr = cat("Type my.object <- ed() again.\\n"))   
     # leave another error in file 
Syntax error: ... 
# Type my.object <- ed() again. 
  ttt <- ed()  # fix the error