[ESS] ess-tracebug

Vitalie S. spinuvit.list at gmail.com
Wed Dec 8 23:49:37 CET 2010

Rainer M Krug <r.m.krug at gmail.com> writes:

> On 12/03/2010 06:30 PM, Erik Iverson wrote:
>> Hello,
>> Norm's recent message to ESS-help about his edtdbg
>> package made me recall an announcement [1] last month
>> about the ess-tracebug project, found at:
>> http://code.google.com/p/ess-tracebug/>
>> I'm having trouble following exactly what this ess-tracebug
>> code is supposed to do. I can install it and activate it just
>> fine, but getting something like the screenshots show has
>> been elusive.  Has anyone succeeded in this?
> Let's go through the screenshots:
> 1) (error_in_iess.png) :  no
> 2) (last_input_arrow.png) : no
> 3) (ess_traceback.png) : yes
> 4) (Debugging.png) : yes
> Vitalie: would it be possible to upload a short .R file, which can be
> used to reproduce the screenshots? That would make understanding the
> add-on much easier.

Hi everyone,
Thanks for feedback and sorry for late response, steeped out for a week.

I will illustrate the ess-tracebug functionality with the test file at
http://ess-tracebug.googlecode.com/svn/trunk/test.R .  It contains one function
lm_test with an erroneous "," at line 6.

For what follows, I will assume that all the key bindings are as suggested on
the main page http://code.google.com/p/ess-tracebug/ .

Go to the file and press M-c s (or just source it), you should get an error:

> + Error in source(file = "/home/vitoshka/SVN/ess-tracebug/test.R") :
  /home/vitoshka/SVN/ess-tracebug/test.R:6:15: unexpected ','
5: {
6:     ret.x <- x,

with the reference to the error position highlighted.

With M-] from test.R (next-error ) or from iESS buffer
(next-error-no-select) you can jump directly to the error and the line will be
highlighted for `next-error-highlight` (or `next-error-no-select`) seconds.
Mouse-click on the highlighted reference in the process buffer will also do the
job. This is the http://code.google.com/p/ess-tracebug/#ess-traceback screenshot.

The above navigation functionality is based on next-error and
next-error-no-select capabilities which you get in compilation, grep
and occur modes, and should be familiar to many of ESS users.

It might happen that the error reference is not detected and is not
highlighted as in the screenshot (1). It could only mean that the regular
expressions I composed do not capture the error format.

In that case please send to me the exact error message, preserving the
formatting.  R outputs errors differently depending on the OS, so it will
probably take some time to record all the available error formats.

There is an at leas on error format which is not yet detected. I will attend to
it asap.

Next step - the debugging.

Correct the  ","  error in the test.R and place the break-point (M-c b) at
some arbitrary position. Source the file once again M-c s.

Create the "main.R" file (or download from
http://ess-tracebug.googlecode.com/svn/trunk/main.R ) with the following code:

require(stats); require(graphics)
lm_test(Fertility ~ . , data = swiss)

Now run the above code.
If everything is ok you should be brought to the break-point
in the test.R; fringe should display the small triangle and the current line is
highlighted. Exactly as the last (4th) screenshot on the homepage illustrates
(http://code.google.com/p/ess-tracebug/#ess-debug ).

At this point you start pressing n,n,n... to jump through you code. I call this
easy-key-mode. In easy-key-mode n,q,c will do what usually n,Q,c will do in R
buffer. Any other event will trigger the exit from easy-key-mode and will be
passed down the emacs command loop. Obviously you can always use  M-c c , M-c n
,M-c q whenever you like (which also will bring you into the easy mode).

Easy key mode is entered automatically whenever the debugger starts from a
non-iESS buffer.

Now the work-flow.

With a big projects I always want to jump quickly to the focal point of my
analysis. This is where I source all the project files and execute
short code. I our case the working file is "main.R" 

When debugger starts it stores the "last input" position in the "main.R". You
can jump to that point with M-c i (ess-dbg-goto-input-point) which is
also an easy command; by repeatedly pressing i,i,i... you will be taken through
the ring of previous "input point" S-i will bring you backwards through that

When you execute M-c i the current position is  inserted into the
debug-ring. Usually it is the place when you correct the error. So it's a focal
point in the source code. You can jump through the debug-ring with M-c d d d D D

I find this functionality extremely handy, it improves the navigation speed twofold.

With hopes it was helpful,

> By the way: just screenshot 4 is worth the extension.
> Cheers,
> Rainer
>> I have activated ess-traceback and submit code from an R
>> file that produces errors, but all I see are the 'fringe
>> arrow', but no error line numbers.
>> This project looks interesting, but can anyone tell me how
>> to get results like the ones in the screenshots?
>> I must admit I do not understand the section "The Work-Flow",
>> so perhaps what I'm missing is because of that.
>> Thanks,
>> --Erik
>> [1] https://stat.ethz.ch/pipermail/ess-help/2010-November/006489.html>
>> ______________________________________________
>> ESS-help at stat.math.ethz.ch mailing list
>> https://stat.ethz.ch/mailman/listinfo/ess-help

More information about the ESS-help mailing list