fixr                package:mvbutils                R Documentation

_E_d_i_t_i_n_g _f_u_n_c_t_i_o_n_s

_D_e_s_c_r_i_p_t_i_o_n:

     'fixr' opens a function in your preferred text editor. Control
     returns immediately to the R command line, so you can keep working
     in R and can be editing several functions simultaneously (cf
     'edit'). A session-duration list of files/functions being edited
     is maintained, so that the function can be easily sourced back in
     to the right workspace, either by calling 'FF()' or automatically
     on file change. There is an optional automatic text backup
     facility.

_U_s_a_g_e:

      fixr( x, new=FALSE, install=FALSE)
      FF()

_A_r_g_u_m_e_n_t_s:

       x: a quoted or unquoted function name

     new: (rarely used) if TRUE, edit a blank function template in
          .GlobalEnv rather than any existing copy in the search path

 install: (rarely used) logical indicating whether to go through the
          process of asking you about your editor

_D_e_t_a_i_l_s:

     When 'fixr' is run for the first time (or if you set
     'install=TRUE'), it will ask you for some basic information about
     your text editor. In particular, you'll need to know what to type
     to invoke your text editor from the command shell (MS-DOS prompt
     on Windows) on a specific file. After supplying these details,
     'fixr' will launch the editor and print a message showing some
     'options' ('"backup.fix"', '"edit.scratchdir"' and
     '"program.editor"'), that will need to be set in your '.First'.
     function- which you can do via 'fixr(.First)'.

     'fixr' creates a blank function template if none existed, or if
     'new=TRUE' is specified.

     If the function has attributes, it's wrapped in a 'structure(...)'
     construct. If a 'doc' attribute exists, it's printed as free-form
     text at the end of the file, and the call to 'structure' will end
     with a line similar to:

     ,doc=flatdoc( EOF="<<end of doc>>"))

     When the file is read later on (see next paragraph, and
     'source.mvb' for technical details), that line will cause the rest
     of the file to be read in as a 'doc' attribute, which can be
     displayed by 'help'. If you want to add "flat-format
     documentation", you can also add these lines yourself- see
     'flatdoc'.

     To read functions back in again, call 'FF()', which checks the
     modification times of any function files. If any have been
     updated, 'FF' sources in the code and modifies the appropriate
     functions. It tries to write functions back into the workspace
     they came from, which might not be .GlobalEnv. If not, you'll be
     asked whether you want to 'save.image' that workspace (provided
     it's a "task"- see 'cd'). 'FF' should still put the function in
     the right place, even if you've called 'cd' after calling 'fixr'
     (unless you've detached the original task) or if you 'move'd it.

     'FF' can be called automatically whenever a valid command is
     executed (e.g. by typing 0<ENTER>; <ENTER> alone doesn't work)-
     see 'autoFF' for how to do this.

     If the function was being 'mtrace'd (see 'help(package=debug)'),
     'FF' will re-apply 'mtrace' after loading the edited version.

     If there is a problem with parsing, the 'source' attribute of the
     function is updated to the new code, but the function body is
     invisibly replaced with a 'stop' call, stating that parsing
     failed. 'FF' also prints an immediate warning.

     The list of functions being edited by 'fixr' is stored in the
     variable 'fix.list' in the 'mvb.session.info' environment. When
     you quit and restart R, the function files you have been using
     will stay open in the editor, but 'fix.list' will be empty; hence,
     updating the file "myfun.r" will not update the corresponding R
     function. If this happens, just type 'fixr(myfun)' in R and when
     your editor asks you if you want to replace the on-screen version,
     say no. Save the file again (some editors require a token
     modification, such as space-then-delete, first) and R will notice
     the update.

     An automatic text backup facility is available from 'fixr' and
     'FF': see '?get.backup'. The backup system also allows you to sort
     functions by edit date; see '?fix.order'.

_N_o_t_e:

     'fixr' is designed to be used with 'cd'; I'm not sure it will work
     independently.

     ESS users will not be very interested in 'fixr', even if they use
     'cd'!

_S_e_e _A_l_s_o:

     '.First', 'edit', 'cd', 'get.backup', 'fix.order', 'move',
     'autoFF'

