From 6d9ec412addfc450f63487de0d90a1076cab47a0 Mon Sep 17 00:00:00 2001 From: Augusto Stoffel Date: Sat, 8 Jan 2022 13:15:40 +0100 Subject: [PATCH 2/2] Lazy highlight when reading query-replace text * lisp/replace.el (query-replace-read-from): Add lazy highlighting. --- lisp/replace.el | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lisp/replace.el b/lisp/replace.el index 60e507c642..241a97a3a2 100644 --- a/lisp/replace.el +++ b/lisp/replace.el @@ -244,6 +244,17 @@ query-replace-read-from (query-replace-descr (cdar query-replace-defaults))))) (t (format-prompt prompt nil)))) + ;; Set up lazy highlighting while reading FROM regexp + (isearch-lazy-highlight query-replace-highlight) + (isearch-regexp regexp-flag) + (isearch-regexp-function nil) + (isearch-case-fold-search case-fold-search) ;; TODO: the case-folding rule here is complicated... + (isearch-read-with-highlight-transform + (lambda (string) + (let ((from (query-replace--split-string string))) + (if (consp from) (car from) from)))) + (isearch-lazy-count-display-function + #'isearch-read-with-highlight-count) (from ;; The save-excursion here is in case the user marks and copies ;; a region in order to specify the minibuffer input. @@ -251,6 +262,7 @@ query-replace-read-from (save-excursion (minibuffer-with-setup-hook (lambda () + (isearch-read-with-highlight-setup) (setq-local text-property-default-nonsticky (append '((separator . t) (face . t)) text-property-default-nonsticky))) -- 2.33.1