[ESS] Evaluating commented code

Stephen Eglen S.J.Eglen at damtp.cam.ac.uk
Fri Jan 18 23:56:06 CET 2013


> When I write scripts for analyzing data, I often comment out lines of code.
>  For example I might have something like:
>
> dat=read.csv()
> plot(y~x, data) # check for outliers
>
> Once I've made the plot, I don't want to make it again, so I'll comment it
> out.  And then my client sends me a revision of the data and I'll want to
> check it again, so I uncomment the plot statement and then evaluate it, and
> then comment the line again.
>
> It occurred to me today that it would be handy to have a key-combination
> similar to ess-eval-* that removes comment characters before sending the
> code line/block/paragraph to the inferior ess process.
>
> Has anyone written code to this?

hi Kevin,

I've not seen such a function.  Everything is possible though with Emacs
of course, and a wrapper (defadvice) with M-x uncomment-region would
help.

I'm wary of the approach though, partly because it then prevents you
including genuine text comments (not code) within your region to eval.
You could try making your own debug function along the lines of:

mydebug( plot(x,y))

where mydebug is a simple function to evaluate its first argument but
only according to some state variable.  This would then be usable if you
ever ran your R code outside ESS (shock horror!).


Stephen



More information about the ESS-help mailing list