Subject: bug#69342: query-replace: ignore events not binded in query-replace-map

From: Juri Linkov <[email-masked]>
Date: Thu, 29 Feb 2024 19:34:19 +0200

> I suppose this feature will be available starting from Emacs version 30,
> right?

Yes, not before the next release.

> In the meantime, I was suggested this code on StackExchange
> (https://emacs.stackexchange.com/a/80494/15606):
>
> (defvar my-do-nothing-map
>   (let ((map (make-keymap)))
>     (set-char-table-range (nth 1 map) t 'ignore)
>     map))
>
> (set-keymap-parent query-replace-map my-do-nothing-map)
>
> and it seems to work with the actual version of query-replace.

Interesting hack.

> @@ -3111,7 +3111,7 @@ perform-replace
>  		  ;; read-event that clobbers the match data.
>  		  (set-match-data real-match-data)
>  		  (setq key (vector key))
> -		  (setq def (lookup-key map key))
> +		  (setq def (lookup-key map key t))
>  		  ;; Restore the match data while we process the command.
>  		  (cond ((eq def 'help)
>  			 (let ((display-buffer-overriding-action

Still this could be fixed as well.  Only one thing that I don't understand
is why lookup-key ignores bindings for [t] by default.  This requires adding
ACCEPT-DEFAULT=t to all calls.  But ok, this can't be changed now.