[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#69342: query-replace: ignore events not binded in query-replace-map
From: |
Juri Linkov |
Subject: |
bug#69342: query-replace: ignore events not binded in query-replace-map |
Date: |
Sun, 25 Feb 2024 09:28:52 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) |
> (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