GNU bug report logs - #69342
query-replace: ignore events not binded in query-replace-map

Previous Next

Package: emacs;

Reported by: Gabriele Nicolardi <gabriele <at> medialab.sissa.it>

Date: Fri, 23 Feb 2024 22:18:01 UTC

Severity: normal

Fixed in version 30.0.50

Done: Juri Linkov <juri <at> linkov.net>

Bug is archived. No further changes may be made.

Full log


Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Gabriele Nicolardi <gabriele <at> medialab.sissa.it>
To: bug-gnu-emacs <at> gnu.org
Subject: query-replace: ignore events not binded in query-replace-map
Date: Fri, 23 Feb 2024 23:16:15 +0100
[Message part 1 (text/plain, inline)]
Hi,

I have this function:

|(defun my-replacements () (interactive) (query-replace "foo" "bar" nil 
(point-min) (point-max)) (query-replace "baz" "quz" nil (point-min) 
(point-max)) (query-replace "fred" "thud" nil (point-min) (point-max))) |

If I run it and accidentally type, for example, ‘k’ during one of the 
replacements, the function is interrupted, skipping all the remaining 
replacements.

I know that |query-replace| (and |query-replace-regexp|) accepts only 
events binded in the |query-replace-map| and from the manual I know that:

   Aside from this, any other character exits the query-replace, and is
   then reread as part of a key sequence. Thus, if you type C-k, it exits
   the query-replace and then kills to end of line. In particular, C-g
   simply exits the query-replace.

I would like to circumvent this behavior by ensuring that events not 
defined in the |query-replace-map| are simply ignored. Is there a way to 
achieve this?

I thought it could be done with a macro, e.g.:

|(with-ignore-qr-unbinded-events MY CODE HERE) |

but I have no idea how to do it.

As a feature request (this would be my first choice), I would like to 
add an optional argument to the function(s) so that I can have control 
over this behavior. Does it make sense to you?

Best regards,

Gabriele Nicolardi

​
[Message part 2 (text/html, inline)]

This bug report was last modified 1 year and 136 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.