[ESS] ess-eval-function artifacts

tyler tyler.smith at mail.mcgill.ca
Mon May 12 09:42:49 CEST 2008


tyler <tyler.smith at mail.mcgill.ca> writes:

Hi again,

I've been having some issues with ess-eval-visibly-p and
ess-eval-function or ess-eval-region. I've left my original posting
below, as this message is about a different, but related issue.

When I use ess-eval-function/region, since I've got ess-eval-visibly-p
set to nil, I get a combination of + and > symbols left on the R process
command line. As I posted before, these 'left-overs' can propagate
themselves when you work back and forth through the command history.
Another user confirmed this behaviour on another platform, so I think
it's not just happening to me.

This isn't in itself a problem. The problem is that these 'left-overs'
are sometimes ignored by the interpreter, but sometimes not. This
produces syntax errors, as any command prefixed by '+ + + > >' is not
proper R code. In one afternoon of use I collected a series of
examples, which I have pasted below.

Does this happen to anyone else? Has anyone found a good way to avoid
this problem? After some study my best effort is adding a few lines to
ess-eval-region to clean up the last line of the process buffer. This
comes at the cost of a half-second wait following each call to
ess-eval-buffer/function, which I find less distracting than the syntax
errors.

Here's my 'fix' to ess-eval-buffer:

	  (let ((sprocess (get-ess-process ess-current-process-name)))
	    (process-send-region sprocess start end)
	    (process-send-string sprocess "\n"))))))
;; altered code starts here:
  (message "Finished evaluation... cleaning up")
  (while (accept-process-output 
            (get-ess-process ess-current-process-name) 0 500))
  (set-buffer (get-ess-buffer ess-current-process-name))
  (end-of-buffer)
  (comint-bol)
  (kill-line)
;; end altered code
  ;; return value
  (list start end))


Thanks,

Tyler


Problem examples (long lines snipped for clarity)
+----------------------------------------+
Description: 

Sent commands from .R to process. Entered additional command at the
prompt - bell03() is a simulation model. Entered several more commands
at subsequent prompt. Returned to line with bell03(), repeated the
simulation with M-<ret>. Error resulted.


> > > + > > > > tmp <- bell03(M = 18, K = 2000, <snipped> d = 0, b = 1)
Time = 0
> kernel9 <- tmp$census
> kernel9[kernel9 > 1000] <- kernel9[kernel9 > 1000] - 1000
> image(kernel9)
> image(kernel9, x = 1:18, y = 1:18, <snipped> oldstyle = TRUE)
> > > + > > > > tmp <- bell03(M = 18, K = 2000, <snipped> d = 0, b = 1)
Error: unexpected '>' in ">"
> 

+----------------------------------------+
Description:

Sent a long simulation to the R process, the actual source code as
follows:

conv.test <- function(sim, radj, name) {
  for(i in 1:20) {
    sim[[i + 1]] <- smith08(cont = sim[[i]], t = 500)
    names(sim)[i + 1] <- as.character(i * 500)
    radj[[i]] <- vp.neut(sim[[i + 1]], habitats)
    names(radj)[[i]] <- as.character(i * 500)
  }

  save(file = name, list = c("sim", "radj"))
  return (list(sim, radj))
}

smith.30n <- vector("list", 21)
smith.30n[[1]] <- smith08(M = 60, K = 500, u = 0.3, m = 0.005, t = 0)
smith.30n.Adj.R <- vector("list", 20)

system.time(tmp <- conv.test(smith.30n, smith.30n.Adj.R, "smith.30n") )

On completion of the simulation several R prompts are left stacked on a
single line, which causes an error when the next function is called:

<output from simulation snipped>
    user   system  elapsed 
3300.902    3.132 3330.513 
> > > ls()
Error: unexpected '>' in ">"
> 

+----------------------------------------+
Description: 
Backed up in the transcript to a function that was called
successfully on a line that included the ess-eval-visibly-p artifacts.
The original function executed properly, but using C-c <enter>, editing
the function, and then hitting <enter>, I get the following:

## original context:
> + + + + + + + + + + + + + > > > > > > > > > summary(lm(Ma ~ X + Y, thau))

Call:
lm(formula = Ma ~ X + Y + XY + X2 + Y2 + X3 + Y3 + X2Y + XY2, 
    data = thau)

## <output snipped>

## further down:

> + + + + + + + + + + + + + > > > > > > > > > summary(lm(Ma ~ X + Y, thau))
Error: unexpected '>' in "+ + + + + + + + + + + + + >"
> 




Original problem follows:

> Hi,
>
> I posted this as a bug, but apparently it is something peculiar to my
> set up. Can anyone else reproduce the following?
>
> Open R in Emacs (M-x R).
> Make sure eval-visibly-p is nil.
> Open a .R file in another buffer.
> With point in a function, send that function to R with C-c C-f
>
> At this point, having sent a function with 24 lines, I see the following
> in my R process buffer:
>
>> + + + + + + + + + + + + + + + + + + + + + + + + > 
>
> Now, if I advance one in the command line history (M-n), I get history item
> 150, in my case just a call to the object 'alpha', presumably I wanted
> to see what was inside that object:
>
>> + + + + + + + + + + + + + + + + + + + + + + + + > alpha
>
> If I then reverse back to the front of the history line with M-p, I get
> the following:
>
>> + + + + + + + + + + + + + + + + + + + + + + + + > + + + + + + + + + + + + + + + + + + + + + + + + > 
>
> If, for whatever reason, I move back and forth in the history, every time
> I get to the history element that corresponds to the function I sent
> with C-c C-f, I get another batch of + symbols:
>
>> + + + + + + + + + + + + + + + + + + + + + + + + > + + + + + + + + + + + + + + + + + + + + + + + + > + + + + + + + + + + + + + + + + + + + + + + + + > + + + + + + + + + + + + + + + + + + + + + + + + > 
>
> and so forth. Does this happen for anyone else? I think I've traced the
> source to comint-restore-input, but I'm not sure what to do about it.
>
> Thanks,
>
> Tyler
>
> ______________________________________________
> ESS-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/ess-help
>

-- 
I never loan my books, for people never return them. The only books remaining in
my library are those I’ve borrowed from others.
                                       --unknown




More information about the ESS-help mailing list