Subject: bug#71927: 29.4; ibuffer-do-isearch and ibuffer-do-isearch-regexp not prompting for input

From: Stephen Berman <[email-masked]>
Date: Thu, 04 Jul 2024 12:06:40 +0200

On Thu, 04 Jul 2024 12:59:24 +0300 Eli Zaretskii <[email-masked]> wrote:

>> From: Eshel Yaron <[email-masked]>
>> Cc: Juri Linkov <[email-masked]>,  John Paul Wallington <[email-masked]>,
>>   Basil L. Contovounesios <[email-masked]>,  [email-masked],
>>   [email-masked]
>> Date: Thu, 04 Jul 2024 09:12:10 +0200
>>
>> Eli Zaretskii <[email-masked]> writes:
>>
>> > I have a question: ibuffer-do-isearch just calls
>> > multi-isearch-buffers.  Does multi-isearch-buffers exit immediately,
>> > or does it exit only when the multi-isearch is done?  If the former, I
>> > guess this is why the problem happens.
>> >
>> >> So we need someone who knows ibuffer internals.
>> >
>> > I've added two people who might be able to help.
>>
>> FWIW, AFAICT everything is working correctly, it's just that the
>> "Operation finished" message hides the prompt.  ibuffer-do-isearch
>> should tell define-ibuffer-op not to display that message, somehow.
>
> I don't see how this could be considered "correct": the "Operation
> finished" message is supposed to be shown only after the Isearch is
> finished in all the marked buffer, not before.  It looks like we need
> a function that will not return until all the buffers where searched,
> because that's what define-ibuffer-op expects.  Don't you agree?

The attached patch appears to DTRT, but I only tested it briefly.

Steve Berman
diff --git a/lisp/ibuf-ext.el b/lisp/ibuf-ext.el
index 95ff014aa5b..9ad033b5fdb 100644
--- a/lisp/ibuf-ext.el
+++ b/lisp/ibuf-ext.el
@@ -598,7 +598,7 @@ revert
 (define-ibuffer-op ibuffer-do-isearch ()
   "Perform a `isearch-forward' in marked buffers."
   (:interactive ()
-   :opstring "searched in"
+   :no-opstring t
    :complex t
    :modifier-p :maybe)
   (multi-isearch-buffers (ibuffer-get-marked-buffers)))
@@ -607,7 +607,7 @@ ibuffer-do-isearch
 (define-ibuffer-op ibuffer-do-isearch-regexp ()
   "Perform a `isearch-forward-regexp' in marked buffers."
   (:interactive ()
-   :opstring "searched regexp in"
+   :no-opstring t
    :complex t
    :modifier-p :maybe)
   (multi-isearch-buffers-regexp (ibuffer-get-marked-buffers)))
diff --git a/lisp/ibuf-macs.el b/lisp/ibuf-macs.el
index 1fd94967836..ace1972054f 100644
--- a/lisp/ibuf-macs.el
+++ b/lisp/ibuf-macs.el
@@ -166,6 +166,7 @@ define-ibuffer-op
 				  mark
 				  modifier-p
 				  dangerous
+				  no-opstring
 				  (opstring "operated on")
 				  (active-opstring "Operate on")
                                   before
@@ -196,6 +197,8 @@ define-ibuffer-op
 OPSTRING is a string which will be displayed to the user after the
 operation is complete, in the form:
  \"Operation complete; OPSTRING x buffers\"
+NO-OPSTRING is a boolean which should be set to suppress the message
+after the operation is complete.
 ACTIVE-OPSTRING is a string which will be displayed to the user in a
 confirmation message, in the form:
  \"Really ACTIVE-OPSTRING x buffers?\"
@@ -246,9 +249,10 @@ define-ibuffer-op
 			    ())
                           (and after `(,after)) ; post-operation form.
 			  `((ibuffer-redisplay t)
-			    (message ,(concat "Operation finished; " opstring
-                                              " %s %s")
-                                     count (ngettext "buffer" "buffers" count)))))
+			    (unless ,no-opstring
+			      (message ,(concat "Operation finished; " opstring
+						" %s %s")
+                                       count (ngettext "buffer" "buffers" count))))))
 		 (inner-body (if complex
 				 `(progn ,@body)
 			       `(progn