Subject: Re: bug#52356: 27.2; Isearch prompt changes unexpectedly with char folding enabled

From: Juri Linkov <[email-masked]>
Date: Sun, 12 Dec 2021 19:30:16 +0200

>> Do you think this problem exists only
>> when isearch-lazy-count is customised to t?
>
> No, I can just launch ‘emacs -Q’, go to the beginning of the buffer
> and start searching for something with ‘C-s M-s '’ to get the
> flickering prompt. What the settings in the first message do is change
> the prompt: it is ‘Pending char-fold I-search’ without them (after
> doing ‘C-s M-s '’) and just ‘I-search:’ with them (where just ‘C-s’
> suffices for starting a char-folded search).
>
> Your patch works both with and without my settings. I don’t know if
> there are cases where it suppresses useful messages.

A possible variant would be not to flicker too much by
transitioning from the message:

  Pending char-fold I-search: string

to

  1/20 Pending char-fold I-search: string

whereas currently it changes to

  1/20 Char-fold I-search: string

by removing the prefix "Pending" after a delay.

But maybe better not to display "Pending" at all?

So with the following patch, adding or removing characters in the search
string doesn't show with the message "Pending" in char-fold mode:

diff --git a/lisp/isearch.el b/lisp/isearch.el
index 75a80840d6..e3b0c34b4a 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -3479,7 +3479,7 @@ isearch-message-prefix
   ;; If currently failing, display no ellipsis.
   (or isearch-success (setq ellipsis nil))
   (let ((m (concat (if isearch-success "" "failing ")
-		   (if isearch-adjusted "pending " "")
+		   (if (eq isearch-adjusted t) "pending " "")
 		   (if (and isearch-wrapped
 			    (not isearch-wrap-function)
 			    (if isearch-forward
@@ -3586,7 +3586,7 @@ isearch-search-fun-default
                   (let ((lax (and (not bound)
                                   (isearch--lax-regexp-function-p))))
                     (when lax
-                      (setq isearch-adjusted t))
+                      (setq isearch-adjusted 'lax))
                     (if (functionp isearch-regexp-function)
                         (funcall isearch-regexp-function string lax)
                       (word-search-regexp string lax))))