[ESS] problem with ess-transcript-clean-region

Tony Plate tplate at acm.org
Thu Jan 14 18:30:19 CET 2010


The function ess-transcript-clean-region has been working incorrectly for me in versions 5.5 and 5.7.1 of ESS.

When given the input:

> x <- list(list(a > 0),
+           list(b > 0), list(c >= 0),
+           list(d > 0), list(e > 0))
> x <- (a > 0
+           & (b > 0) & (c >= 0))

ess-transcript-clean-region used to (e.g., in ESS-5.2.0beta4) correctly result in:

x <- list(list(a > 0),
          list(b > 0), list(c >= 0),
          list(d > 0), list(e > 0))
x <- (a > 0
          & (b > 0) & (c >= 0))

However, with versions 5.5 and 5.7.1 of ESS, I see the result:

x <- list(list(a > 0),
0), list(c >= 0),
0), list(e > 0))
x <- (a > 0
          & (b > 0) & (c >= 0))

(Note that the continuation lines are incorrectly handled in the first expression, but are OK in the second -- it looks like that for some but not all continuation lines, an internal "greater than" sign is being treated as the prompt.)

I see this behavior with ess-5.5 and ess-5.7.1.  The last version that I installed that worked correctly was ess-5.2.0beta4.

I'm running in GNU Emacs 22.3.1 (i386-mingw-nt5.2.3790) of 2008-09-06 on SOFT-MJASON, under Windows XP, but I also see the same behavior on my Ubuntu GNU/Linux machine.

The culprit appears be the following change in ess-transcript-clean-region:

The line
        (replace-regexp (concat "^" inferior-ess-prompt) ""))
was replaced with
	(while (re-search-forward (concat "^" inferior-ess-prompt) nil t)
	  (replace-match "" nil nil)))

I've manually looked at the value of inferior-ess-prompt and it appears to be correct, and it appears to match correctly, but the replace-match call doesn't seem to be doing the right thing (which may indeed be a bug in replace-match, though I'm not enough of an emacs-lisp hacker to be able to judge that.)

When I revert the re-search-forward/replace-match expression in my installation of ESS 5.7.1 back to use replace-regexp as was used in ESS 5.2.0beta4), I get the old, correct behavior.

-- Tony Plate



More information about the ESS-help mailing list