^ and comint-prompt-regexp (was: [Emacs-diffs] master d58c29b: Revert last tweak in 'comint-output-filter')

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

^ and comint-prompt-regexp (was: [Emacs-diffs] master d58c29b: Revert last tweak in 'comint-output-filter')

Stefan Monnier
>     * lisp/comint.el (comint-output-filter): Revert last tweak because
>     it can hang gdb indefinitely.

Hmm... it would be worthwhile to investigate what's really going on here.

> -            (while (string-match (concat "\\(" comint-prompt-regexp
> +            (while (string-match (concat "\\(^" comint-prompt-regexp

Since comint-prompt-regexp almost always starts with "^", this change
seems to be fundamentally wrong: it will give a regexp of the form
\(^^...\) which interprets the second ^ as an actual ^ char rather than
as a `bolp` check.

So if it avoids a problem, it's likely not the right fix but rather
because it just deactivates this loop.

As the original author of this code, I must admit that I don't fully
understand why this loop is here (it seems redundant with the
immediately preceding loop, which was introduced by the same commit).

Maybe we should just comment it out.


        Stefan

Reply | Threaded
Open this post in threaded view
|

Re: ^ and comint-prompt-regexp

Andy Moreton-3
On Tue 12 Mar 2019, Stefan Monnier wrote:

>>     * lisp/comint.el (comint-output-filter): Revert last tweak because
>>     it can hang gdb indefinitely.
>
> Hmm... it would be worthwhile to investigate what's really going on here.
>
>> -            (while (string-match (concat "\\(" comint-prompt-regexp
>> +            (while (string-match (concat "\\(^" comint-prompt-regexp
>
> As the original author of this code, I must admit that I don't fully
> understand why this loop is here (it seems redundant with the
> immediately preceding loop, which was introduced by the same commit).

It looks to me that the first loop only removes prompts that match the
previous prompt found in the buffer text. The second loop removes any
prompts that match the regexp (which may not be the same as the previous
prompt if `comint-prompt-regexp' contains alternatives).

I presume it was done this way to be slightly faster ?

    AndyM