Subject: Re: bug#41338: Toolbar-bug in Emacs 27.0.91/Pretest

From: Juri Linkov <[email-masked]>
Date: Sun, 17 May 2020 01:55:06 +0300

>> To reproduce:
>>
>> (1) Start Emacs (without any customizations).
>>
>> (2) Open a file which has the standard toolbar, say mouse.el
>>
>> (3) Do C-x m, to open a message buffer; this buffer has a toolbar _different_
>> from the standard one.
>>
>> (4) Do C-x 5 2, to get the message buffer shown in a second frame.
>>
>> (5) In the first frame, make the buffer showing mouse.el active again.
>>
>> (6) In that buffer, do C-s, to invoke isearch and search for some word.
>>
>> (7) Using the mouse, close the frame showing mouse.el, but do so in a state
>> where still isearch overlays show up.
>>
>> (8) Now click with mouse-1 in the remaining frame, i.e., in that showing the
>> message buffer, and the toolbar changes to the standard one.
>>
>> I consider this as a bug. In case it is not platform independent, I us an NS-build.
>
> I see this too, on GNU/Linux (both in 27.0.91 and a recent build from
> master).  Moreover, if in the remaining frame I switch from the message
> buffer to the buffer in which isearch was invoked, the tool bar is now
> the isearch tool bar and the mode line has the "Isearch" lighter, but
> there are no isearch overlays and point is where it was before invoking
> isearch.  This seems surprising.  But now typing C-s restores the
> isearch state the buffer had (i.e. the same overlays) before closing the
> other frame.

isearch-mode-map has such bindings:

    ;; Pass frame events transparently so they won't exit the search.
    ;; In particular, if we have more than one display open, then a
    ;; switch-frame might be generated by someone typing at another keyboard.
    (define-key map [switch-frame] nil)
    (define-key map [delete-frame] nil)

and indeed the ‘switch-frame’ event is fired when the frame is switched
during isearch, and it exits isearch.

But I don't know why the ‘delete-frame’ event is not fired on frame deletion.

Perhaps isearch.el should explicitly use the hook ‘delete-frame-functions’
to exit isearch.