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

From: Juri Linkov <[email-masked]>
Date: Mon, 18 May 2020 01:03:16 +0300

> I found Juri's post confusing, probably because I know next to nothing
> about frame events.  He quotes this comment in isearch-mode-map:
>
>     ;; Pass frame events transparently so they won't exit the search.

Actually this comment is confusing.  It makes no sense to me.

What makes more sense is that frame events should exit the search,
because such frame events as ‘switch-frame’ and ‘delete-frame’
change the current buffer (‘switch-frame’ changes the current buffer
to the buffer on the switched frame, and ‘delete-frame’ changes
the current buffer to the buffer on the remaining frame).

There are precautions in isearch.el that take care to exit isearch
when the current buffer changes because many things break in this case.

One of things that breaks is that reported in this bug report
where isearch-mode remembers tool-bar-map that was active
in the current buffer before starting isearch, then frame deletion
by clicking on the 'X' (close frame button) in the frame's title bar
changes the current buffer to the buffer of the remaining frame
while isearch is still active, then isearch-done called
in another buffer restores tool-bar-map in wrong buffer.

> but then says "and indeed the ‘switch-frame’ event is fired when the
> frame is switched during isearch, and it exits isearch", which seems to
> contradict the comment.

Yes, this contradicts the comment because the comment makes no sense.

> But in any case, according to my tests, switch
> the frame does indeed exit Isearch, whether via `C-x 5 o' or the
> toolkits `Alt-TAB'.

In my tests it exits isearch as well, and this is the right thing to do.

> Juri added: "But I don't know why the
> ‘delete-frame’ event is not fired on frame deletion."  But my tests
> indicate that, unlike when switching the frame, when deleting the frame,
> Isearch is exited only when the delete frame event comes from Emacs, not
> from the toolkit.

And my tests show the same: 'C-x 5 0' exits isearch, but clicking on the
close frame button doesn't exit isearch - that's the problem.