Commit e54a1075 authored by Johan Bockgård's avatar Johan Bockgård Committed by Chong Yidong
Browse files

Fix query-replace-regexp incomplete highlighting (Bug#6808).

* replace.el (replace-highlight): Bind isearch-forward and
isearch-error, ensuring that highlighting is updated if the user
switches the search direction (Bug#6808).

* isearch.el (isearch-lazy-highlight-forward): New var.
(isearch-lazy-highlight-new-loop, isearch-lazy-highlight-search):
(isearch-lazy-highlight-update): Use it.
parent f21a9669
2010-08-08 Johan Bockgård <bojohan@gnu.org>
* replace.el (replace-highlight): Bind isearch-forward and
isearch-error, ensuring that highlighting is updated if the user
switches the search direction (Bug#6808).
* isearch.el (isearch-lazy-highlight-forward): New var.
(isearch-lazy-highlight-new-loop, isearch-lazy-highlight-search):
(isearch-lazy-highlight-update): Use it.
2010-08-06 Kenichi Handa <handa@m17n.org> 2010-08-06 Kenichi Handa <handa@m17n.org>
* international/mule.el (define-charset): Store NAME as :base * international/mule.el (define-charset): Store NAME as :base
......
...@@ -2574,6 +2574,7 @@ since they have special meaning in a regexp." ...@@ -2574,6 +2574,7 @@ since they have special meaning in a regexp."
(defvar isearch-lazy-highlight-case-fold-search nil) (defvar isearch-lazy-highlight-case-fold-search nil)
(defvar isearch-lazy-highlight-regexp nil) (defvar isearch-lazy-highlight-regexp nil)
(defvar isearch-lazy-highlight-space-regexp nil) (defvar isearch-lazy-highlight-space-regexp nil)
(defvar isearch-lazy-highlight-forward nil)
(defun lazy-highlight-cleanup (&optional force) (defun lazy-highlight-cleanup (&optional force)
"Stop lazy highlighting and remove extra highlighting from current buffer. "Stop lazy highlighting and remove extra highlighting from current buffer.
...@@ -2613,7 +2614,9 @@ by other Emacs features." ...@@ -2613,7 +2614,9 @@ by other Emacs features."
(not (= (window-start) (not (= (window-start)
isearch-lazy-highlight-window-start)) isearch-lazy-highlight-window-start))
(not (= (window-end) ; Window may have been split/joined. (not (= (window-end) ; Window may have been split/joined.
isearch-lazy-highlight-window-end)))) isearch-lazy-highlight-window-end))
(not (eq isearch-forward
isearch-lazy-highlight-forward))))
;; something important did indeed change ;; something important did indeed change
(lazy-highlight-cleanup t) ;kill old loop & remove overlays (lazy-highlight-cleanup t) ;kill old loop & remove overlays
(when (not isearch-error) (when (not isearch-error)
...@@ -2628,7 +2631,8 @@ by other Emacs features." ...@@ -2628,7 +2631,8 @@ by other Emacs features."
isearch-lazy-highlight-case-fold-search isearch-case-fold-search isearch-lazy-highlight-case-fold-search isearch-case-fold-search
isearch-lazy-highlight-regexp isearch-regexp isearch-lazy-highlight-regexp isearch-regexp
isearch-lazy-highlight-wrapped nil isearch-lazy-highlight-wrapped nil
isearch-lazy-highlight-space-regexp search-whitespace-regexp) isearch-lazy-highlight-space-regexp search-whitespace-regexp
isearch-lazy-highlight-forward isearch-forward)
(unless (equal isearch-string "") (unless (equal isearch-string "")
(setq isearch-lazy-highlight-timer (setq isearch-lazy-highlight-timer
(run-with-idle-timer lazy-highlight-initial-delay nil (run-with-idle-timer lazy-highlight-initial-delay nil
...@@ -2644,7 +2648,8 @@ Attempt to do the search exactly the way the pending Isearch would." ...@@ -2644,7 +2648,8 @@ Attempt to do the search exactly the way the pending Isearch would."
(search-invisible nil) ; don't match invisible text (search-invisible nil) ; don't match invisible text
(retry t) (retry t)
(success nil) (success nil)
(bound (if isearch-forward (isearch-forward isearch-lazy-highlight-forward)
(bound (if isearch-lazy-highlight-forward
(min (or isearch-lazy-highlight-end-limit (point-max)) (min (or isearch-lazy-highlight-end-limit (point-max))
(if isearch-lazy-highlight-wrapped (if isearch-lazy-highlight-wrapped
isearch-lazy-highlight-start isearch-lazy-highlight-start
...@@ -2678,7 +2683,7 @@ Attempt to do the search exactly the way the pending Isearch would." ...@@ -2678,7 +2683,7 @@ Attempt to do the search exactly the way the pending Isearch would."
(select-window isearch-lazy-highlight-window)) (select-window isearch-lazy-highlight-window))
(save-excursion (save-excursion
(save-match-data (save-match-data
(goto-char (if isearch-forward (goto-char (if isearch-lazy-highlight-forward
isearch-lazy-highlight-end isearch-lazy-highlight-end
isearch-lazy-highlight-start)) isearch-lazy-highlight-start))
(while looping (while looping
...@@ -2691,7 +2696,7 @@ Attempt to do the search exactly the way the pending Isearch would." ...@@ -2691,7 +2696,7 @@ Attempt to do the search exactly the way the pending Isearch would."
(let ((mb (match-beginning 0)) (let ((mb (match-beginning 0))
(me (match-end 0))) (me (match-end 0)))
(if (= mb me) ;zero-length match (if (= mb me) ;zero-length match
(if isearch-forward (if isearch-lazy-highlight-forward
(if (= mb (if isearch-lazy-highlight-wrapped (if (= mb (if isearch-lazy-highlight-wrapped
isearch-lazy-highlight-start isearch-lazy-highlight-start
(window-end))) (window-end)))
...@@ -2711,7 +2716,7 @@ Attempt to do the search exactly the way the pending Isearch would." ...@@ -2711,7 +2716,7 @@ Attempt to do the search exactly the way the pending Isearch would."
(overlay-put ov 'priority 1000) (overlay-put ov 'priority 1000)
(overlay-put ov 'face lazy-highlight-face) (overlay-put ov 'face lazy-highlight-face)
(overlay-put ov 'window (selected-window)))) (overlay-put ov 'window (selected-window))))
(if isearch-forward (if isearch-lazy-highlight-forward
(setq isearch-lazy-highlight-end (point)) (setq isearch-lazy-highlight-end (point))
(setq isearch-lazy-highlight-start (point))))) (setq isearch-lazy-highlight-start (point)))))
...@@ -2721,7 +2726,7 @@ Attempt to do the search exactly the way the pending Isearch would." ...@@ -2721,7 +2726,7 @@ Attempt to do the search exactly the way the pending Isearch would."
(setq looping nil (setq looping nil
nomore t) nomore t)
(setq isearch-lazy-highlight-wrapped t) (setq isearch-lazy-highlight-wrapped t)
(if isearch-forward (if isearch-lazy-highlight-forward
(progn (progn
(setq isearch-lazy-highlight-end (window-start)) (setq isearch-lazy-highlight-end (window-start))
(goto-char (max (or isearch-lazy-highlight-start-limit (point-min)) (goto-char (max (or isearch-lazy-highlight-start-limit (point-min))
......
...@@ -1893,7 +1893,9 @@ make, or the user didn't cancel the call." ...@@ -1893,7 +1893,9 @@ make, or the user didn't cancel the call."
(let ((isearch-string string) (let ((isearch-string string)
(isearch-regexp regexp) (isearch-regexp regexp)
(search-whitespace-regexp nil) (search-whitespace-regexp nil)
(isearch-case-fold-search case-fold)) (isearch-case-fold-search case-fold)
(isearch-forward t)
(isearch-error nil))
(isearch-lazy-highlight-new-loop range-beg range-end)))) (isearch-lazy-highlight-new-loop range-beg range-end))))
(defun replace-dehighlight () (defun replace-dehighlight ()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment