From 99704a7b41f9c3c6c2215cf5c47bc161df05cfa4 Mon Sep 17 00:00:00 2001 From: Visuwesh Date: Sun, 28 Jul 2024 10:27:33 +0530 Subject: [PATCH] Add new optional argument NO-HIGHLIGHT to query-replace-read-args * lisp/replace.el (query-replace-read-args): Add new optional argument to disable regexp highlighting. * lisp/dired-aux.el (dired-do-query-replace-regexp) (dired-do-replace-regexp-as-diff) (dired-do-find-regexp-and-replace): Revert last change, and use the new argument instead. (bug#72147) --- lisp/dired-aux.el | 19 ++++++++----------- lisp/replace.el | 4 ++-- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el index decd9702eaf..cd948bd7dd9 100644 --- a/lisp/dired-aux.el +++ b/lisp/dired-aux.el @@ -3801,10 +3801,9 @@ Third arg DELIMITED (prefix arg) means replace only word-delimited matches. If you exit the query-replace loop (\\[keyboard-quit], RET or q), you can resume the query replace with the command \\[fileloop-continue]." (interactive - (let* ((query-replace-lazy-highlight) - (common - (query-replace-read-args - "Query replace regexp in marked files" t t))) + (let ((common + (query-replace-read-args + "Query replace regexp in marked files" t t t))) (list (nth 0 common) (nth 1 common) (nth 2 common))) dired-mode) (dolist (file (dired-get-marked-files nil nil #'dired-nondirectory-p nil t)) @@ -3826,10 +3825,9 @@ Third arg DELIMITED (prefix arg) means replace only word-delimited matches. The replacements are displayed in the buffer *replace-diff* that you can later apply as a patch after reviewing the changes." (interactive - (let* ((query-replace-lazy-highlight) - (common - (query-replace-read-args - "Replace regexp as diff in marked files" t t))) + (let ((common + (query-replace-read-args + "Replace regexp as diff in marked files" t t t))) (list (nth 0 common) (nth 1 common) (nth 2 common)))) (dired-post-do-command) (multi-file-replace-regexp-as-diff @@ -3903,10 +3901,9 @@ REGEXP should use constructs supported by your local `grep' command. Also see `query-replace' for user options that affect how this function works." (interactive - (let* ((query-replace-lazy-highlight) - (common + (let ((common (query-replace-read-args - "Query replace regexp in marked files" t t))) + "Query replace regexp in marked files" t t t))) (list (nth 0 common) (nth 1 common))) dired-mode) (require 'xref) diff --git a/lisp/replace.el b/lisp/replace.el index 01a892bbba7..2285b19b519 100644 --- a/lisp/replace.el +++ b/lisp/replace.el @@ -352,7 +352,7 @@ should a regexp." to)) regexp-flag)) -(defun query-replace-read-args (prompt regexp-flag &optional noerror) +(defun query-replace-read-args (prompt regexp-flag &optional noerror no-highlight) (unless noerror (barf-if-buffer-read-only)) (save-mark-and-excursion @@ -364,7 +364,7 @@ should a regexp." :filter (when (use-region-p) (replace--region-filter (funcall region-extract-function 'bounds))) - :highlight query-replace-lazy-highlight + :highlight (and query-replace-lazy-highlight (not no-highlight)) :regexp regexp-flag :regexp-function (or replace-regexp-function delimited-flag