[ESS] ess-tracebug behavior [probably wishlist]

Vitalie Spinu spinuvit at gmail.com
Tue Apr 9 21:27:49 CEST 2013


  >> Ross Boylan <ross at biostat.ucsf.edu>
  >> on Tue, 9 Apr 2013 12:00:53 -0700 wrote:

 > When I flag a function for debugging with C-c C-t d I get the usual
 > browser dialog, but no display of the function with the current line
 > highlighted.  I'm also using ess developer.

This happens if the debugged function does not contain source
references. If you source the file (C-c C-l) or simply eval the function
(C-c C-c) the source is always there. I expect that you are debugging an
in-package function. R does not keep sources by default. There is an
option keep-source on building, and devtools actually have that option
on. Unfortunately the source points to a temporary folder where the
package was temporary unpacked and it is long gone, so even with that
option it will not work as expected.

The obvious workaround is to turn the developer on load the file or
function. This is what I do.

 > I suspect this is the expected behavior.  It would be really nice if
 > such a display came up, and the printout of the function body and the
 > calling arguments were suppressed (I think I saw an option to cut this
 > off, at least if it was long, but am not sure how to do that).

There is an R option to limit the number of lines printed. I forgot the
name. See debug or trace docs.

 > ess-tracebug will not in general know where the source file is (which is
 > why I think the current behavior is  expected).  I can imagine two
 > options: asking the user for the source file location, or dumping the
 > function body into a temporary file.

Asking is not an option, many times you want to debug a function from a
package like base. There is no file location for those.

The second idea really appeals to me and I think it is quite
doable. Will look at it at the end of the month.

 > It could also be more or less clever about finding the source location
 > automatically.

 > There are various nasty corner cases because the same symbol could refer
 > to different functions at different points in a single source file.  The
 > symbol could also be a variable that is not the name of any function
 > definition.

Not always applicable, but in principle it is possible to look for the
occurrence of the expression. R also often reports wrong location, so
this feature might be indeed handy. I was thinking to add a shortcut to
call multi-occur on the error expression. 

    Vitalie



More information about the ESS-help mailing list