unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: Gabriele Nicolardi <gabriele@medialab.sissa.it>
Cc: 69342@debbugs.gnu.org
Subject: bug#69342: query-replace: ignore events not binded in query-replace-map
Date: Sun, 25 Feb 2024 09:28:52 +0200	[thread overview]
Message-ID: <864jdx11qx.fsf@mail.linkov.net> (raw)
In-Reply-To: <a7e2a917-ec11-4671-945f-9571dbb5ffb3@medialab.sissa.it> (Gabriele Nicolardi's message of "Fri, 23 Feb 2024 23:16:15 +0100")

> (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)))
> [...]
> 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?

Thanks for the feature request.  Or maybe this is a bug report,
since currently query-replace doesn't allow you using such a simple
configuration to ignore all unbound keys:

  (define-key query-replace-map [t] 'ignore)

To give you the freedom of using such configuration we need
to set the optional argument ACCEPT-DEFAULTS of 'lookup-key' to t
with this patch:

diff --git a/lisp/replace.el b/lisp/replace.el
index f8f5c415273..750ca9c1ee3 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -2924,7 +2924,7 @@ perform-replace
 
     ;; If last typed key in previous call of multi-buffer perform-replace
     ;; was `automatic-all', don't ask more questions in next files
-    (when (eq (lookup-key map (vector last-input-event)) 'automatic-all)
+    (when (eq (lookup-key map (vector last-input-event) t) 'automatic-all)
       (setq query-flag nil multi-buffer t))
 
     (cond
@@ -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





  parent reply	other threads:[~2024-02-25  7:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-23 22:16 bug#69342: query-replace: ignore events not binded in query-replace-map Gabriele Nicolardi
     [not found] ` <handler.69342.B.170872663926258.ack@debbugs.gnu.org>
2024-02-23 22:33   ` bug#69342: Acknowledgement (query-replace: ignore events not binded in query-replace-map) Gabriele Nicolardi
2024-02-25  7:28 ` Juri Linkov [this message]
2024-02-25  8:19   ` bug#69342: query-replace: ignore events not binded in query-replace-map Gabriele Nicolardi
2024-02-29 17:34     ` Juri Linkov
2024-03-02 17:22   ` Juri Linkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=864jdx11qx.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=69342@debbugs.gnu.org \
    --cc=gabriele@medialab.sissa.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).