Subject: bug#79368: 31.0.50; exiting a recursive isearch through an error keeps isearch map active

From: Juri Linkov <[email-masked]>
Date: Wed, 03 Sep 2025 09:45:54 +0300

close 79368 31.0.50
thanks

> However, any self-inserting key presses after that reactivate
> isearch mode.  C-g or ESC ESC ESC do not help to escape that
> state.  The minibuffer window cannot be selected with C-x o,
> either, to get back to the isearch prompt.
>
> A C-h b in that state reveals that the isearch mode bindings
> are still active.  I remember having seen a report on
> emacs-devel about a similar issue, IIRC it was related to
> isearch during an edebug sesssion.  Might be related or not.

Thanks for the bug report.  The problem is that when
'read-from-minibuffer' in 'isearch-edit-string'
raises an error because of recursive minibuffers,
then in 'with-isearch-suspended' the unwind form is
called twice in a row, and 'isearch-mode' is called twice.
But 'isearch-mode' overrides the original
'overriding-terminal-local-map' on the second call.

So after

  (progn (isearch-mode t) (isearch-mode t) (isearch-done))

'isearch-done' restored a wrong map.

Now 'isearch-mode' is fixed to protect from multiple calls.