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

From: Juri Linkov <[email-masked]>
Date: Mon, 15 Jun 2020 01:55:58 +0300

>> isearch uses overriding-terminal-local-map, so the proper test case is:
>>
>> (setq overriding-terminal-local-map
>>       (let ((map (make-keymap)))
>> 	(define-key map [delete-frame]
>> 	  (lambda (&rest ignore)
>> 	    (interactive)
>> 	    (message "DELETE-FRAME")))
>> 	(define-key map "!"
>> 	  (lambda (&rest ignore)
>> 	    (interactive)
>> 	    (message "!")))
>> 	map))
>>
>> and indeed typing '!' you get the message,
>> but no message when clicking the `X' icon.
>
> The docstring of 'overriding-terminal-local-map' says:
>
>   Per-terminal keymap that takes precedence over all other keymaps.
>
> so maybe this is right for a *per-terminal* keymap not to react
> to window events such as clicking the `X' icon?

If there is no bug here, then I see two possible solutions for isearch:

1. use special-event-map in isearch.el the same way as isearch.el uses
   overriding-terminal-local-map;

2. use the hook ‘delete-frame-functions’ to explicitly exit isearch.