Subject: bug#63748: 30.0.50; eshell-previous-prompt doesn't work for multiline prompts

From: Jim Porter <[email-masked]>
Date: Mon, 29 May 2023 22:02:26 -0700

On 5/27/2023 1:38 AM, Tony Zorman via Bug reports for GNU Emacs, the
>      diff --git a/lisp/eshell/em-prompt.el b/lisp/eshell/em-prompt.el
>      index 9f9e58e83d..b6c873b41d 100644
>      --- a/lisp/eshell/em-prompt.el
>      +++ b/lisp/eshell/em-prompt.el
>      @@ -180,7 +180,8 @@ eshell-next-prompt
>                         (text-property-search-forward 'field 'prompt t))
>               (setq n (1- n)))
>           (let (match this-match)
>      -      (forward-line 0)           ; Don't count prompt on current line.
>      +      ;; Don't count prompt on current line.
>      +      (text-property-search-backward 'field 'prompt t)
>             (while (and (< n 0)
>                         (setq this-match (text-property-search-backward
>                                           'field 'prompt t)))
> 
> This is a tiny change, so I suppose it can be applied immediately (if I
> haven't overlooked anything, of course), or I can prepare a proper patch
> (that perhaps adds a test for multiline prompts to the right place).

Thanks for catching this. I think the change you propose makes sense 
(though I haven't actually tried it out).

A test would be great. See "test/lisp/eshell/em-prompt-tests.el": 
another test based on 'em-prompt-test/next-previous-prompt' (and 
possibly 'em-prompt-test/forward-backward-matching-input' too) should be 
sufficient, I think.

If you want to add a test yourself, go for it, and let me know if you 
run into any issues. Otherwise if you prefer, I can write a test case 
for this.