[ESS-bugs] ess-mode 5.3.0; comint-prompt-regexp

Martin Maechler maechler at stat.math.ethz.ch
Mon Dec 10 15:40:32 CET 2007


>>>>> "tony" == A J Rossini <blindglobe at gmail.com>
>>>>>     on Sun, 9 Dec 2007 13:28:07 +0100 writes:

    tony> the more complex prompt handles debugging and
    tony> specialized prompts used by R.  The right solution
    tony> would be to capture the context change and switch, or
    tony> to use options() to guess at the simple prompt (which
    tony> would be nearly unnoticeable to the user these days).

I think I agree (with "nearly unnoticable").

getOption("prompt")  is the thing to use {in R; for
back-compatibility with S-plus, maybe better  options("prompt")[[1]].

Note that this possibly would have to be called inside *every*
ess-eval-.. call -- at least as long as 'ess-eval-visibly-p' is
not nil [it is 't' by default, but has been 'nil' for me, for
    	 more than 10 years; for good reasons...].

Further note that *changing* the prompt inside an R or S session is
already not quite properly supported, I think:

The (inferior-ess-mode) function is only called initially,
and it contains

  (setq inferior-ess-prompt
	;; Do not anchor to bol with `^'
	(concat "\\("
		inferior-ess-primary-prompt
		"\\|"
		inferior-ess-secondary-prompt
		"\\)"))
  (setq comint-prompt-regexp (concat "^" inferior-ess-prompt))

the whole part of which should be made dynamic (in Tony's sense),
and I have been coding a new function

  (defun ess-inferior-reset-prompts (&optional use-options)

for the last hour or so.

When testing the new function and new and old behavior:
One thing is very funny :

 C-c C-o  [ = comint-delete-output ]

works without a problem and very quickly
{for your nice reproducible example
     library(vegan); data(BCI); BCI
}
whereas indeed

 C-c C-p

does not.  
[OTOH, the documentation of C-c C-p  *does* mention the regexp,
 whereas the doc string of  C-c C-o  does not;
 so that could be the explanation]

I'm pretty confident I'll have this fixed for the next version
of ESS.

Martin Maechler, ETH Zurich


    tony> On Dec 6, 2007 5:21 PM, tyler <tyler at mail.mcgill.ca>
    tony> wrote:
    >> 
    >> Hi,
    >> 
    >> I previously submitted a bug related to this, which was
    >> not resolved.  When trying to move back to the previous
    >> prompt after long inputs, Emacs hangs. Following my
    >> previous post, I was told that I can C-g to cancel the
    >> command, which works. However, I still think there's a
    >> problem with C-c C-p, reproducible with:
    >> 
    >> library(vegan) data(BCI) BCI <C-c C-p>
    >> 
    >> I suspect there is something in the prompt regexp that is
    >> particularly inefficient. The inferior-ess-primary-prompt
    >> is currently set to
    >> 
    >> "\\([A-Z][][A-Za-z0-9.]*\\)*> "
    >> 
    >> and the comint-prompt-regexp becomes
    >> "^\\(\\([A-Z][][A-Za-z0-9.]*\\)*> \\|+ ?\\)".
    >> 
    >> Playing around in regexp-builder, I found that
    >> "\\([A-Z][][A-Za-z0-9.]*\\)" occasionally requires quite
    >> a long time to process. Setting the comint-prompt-regexp
    >> with (setq comint-prompt-regexp "^> \\|+ ?")
    >> 
    >> seems to work just as well as the default for me, and it
    >> doesn't hang on long output. What is
    >> "\\([A-Z][][A-Za-z0-9.]*\\)*> " supposed to match, and
    >> could it be rewritten to do this more efficiently?

Some people have always used  "R> " as their prompt, since the
old days when R was the exception and S-plus was the rule ...

Thank *you*, Tyler
for your report and proposals.



More information about the ESS-bugs mailing list