GNU bug report logs -
#53126
29.0.50; [PATCH] Lazy highlight/count when reading query-replace string, etc.
Previous Next
Reported by: Augusto Stoffel <arstoffel <at> gmail.com>
Date: Sat, 8 Jan 2022 13:25:01 UTC
Severity: normal
Tags: patch
Merged with 53341
Fixed in version 29.0.50
Done: Juri Linkov <juri <at> linkov.net>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
> @@ -365,14 +372,49 @@ query-replace-read-args
> - (let* ((from (query-replace-read-from prompt regexp-flag))
> - (to (if (consp from) (prog1 (cdr from) (setq from (car from)))
> - (query-replace-read-to from prompt regexp-flag))))
> - (list from to
> - (or (and current-prefix-arg (not (eq current-prefix-arg '-)))
> - (and (plist-member (text-properties-at 0 from) 'isearch-regexp-function)
> - (get-text-property 0 'isearch-regexp-function from)))
> - (and current-prefix-arg (eq current-prefix-arg '-))))))
The name of the function is `query-replace-read-args'.
And now most of the function is dealing with highlighting:
> + (condition-case error
> + (let (;; Variables controlling lazy highlighting while reading
> + ;; FROM and TO.
> + (isearch-case-fold-search case-fold-search)
> + (isearch-lazy-highlight query-replace-lazy-highlight)
> + (isearch-regexp regexp-flag)
> + (isearch-regexp-function (or replace-regexp-function
> + (and current-prefix-arg
> + (not (eq current-prefix-arg '-)))
> + (and replace-char-fold
> + (not regexp-flag)
> + #'char-fold-to-regexp)))
> + (lazy-highlight-cleanup nil)
> + (minibuffer-lazy-highlight-transform
> + (lambda (string)
> + (let* ((split (query-replace--split-string string))
> + (from-string (if (consp split) (car split) split)))
> + (when (and case-fold-search search-upper-case)
> + (setq isearch-case-fold-search
> + (isearch-no-upper-case-p from-string regexp-flag)))
> + from-string)))
> + from to)
> + (when query-replace-lazy-highlight
> + (add-hook 'minibuffer-setup-hook #'minibuffer-lazy-highlight-setup)
> + (when (use-region-p)
> + (letrec ((region-filter (replace--region-filter
> + (funcall region-extract-function 'bounds)))
> + (cleanup (lambda ()
> + (remove-function isearch-filter-predicate region-filter)
> + (remove-hook 'minibuffer-exit-hook cleanup))))
> + (add-function :after-while isearch-filter-predicate region-filter)
> + (add-hook 'minibuffer-exit-hook cleanup))))
> + (setq from (query-replace-read-from prompt regexp-flag))
> + (setq to (if (consp from)
> + (prog1 (cdr from) (setq from (car from)))
> + (query-replace-read-to from prompt regexp-flag)))
> + (list from to
> + (or (and current-prefix-arg (not (eq current-prefix-arg '-)))
> + (and (plist-member (text-properties-at 0 from) 'isearch-regexp-function)
> + (get-text-property 0 'isearch-regexp-function from)))
> + (and current-prefix-arg (eq current-prefix-arg '-))))
> + (t (lazy-highlight-cleanup)
> + (signal (car error) (cdr error))))))
This highlighting needs to be refactored from `query-replace-read-args'
into a separate highlighting function.
This bug report was last modified 3 years and 39 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.