diff options
| author | Johan Bockgård | 2010-08-08 16:55:52 -0400 |
|---|---|---|
| committer | Chong Yidong | 2010-08-08 16:55:52 -0400 |
| commit | e54a1075033073f835596ab666eeed099028beb8 (patch) | |
| tree | 34f6ce1c647bf19da012fa4effb309cf8ee34fe4 | |
| parent | f21a9669a44e1358e1f3164e4e1edd4e7000714e (diff) | |
| download | emacs-e54a1075033073f835596ab666eeed099028beb8.tar.gz emacs-e54a1075033073f835596ab666eeed099028beb8.zip | |
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.
| -rw-r--r-- | lisp/ChangeLog | 10 | ||||
| -rw-r--r-- | lisp/isearch.el | 19 | ||||
| -rw-r--r-- | lisp/replace.el | 4 |
3 files changed, 25 insertions, 8 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 2097f6c1973..3a37cf2dfb4 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,13 @@ | |||
| 1 | 2010-08-08 Johan Bockgård <bojohan@gnu.org> | ||
| 2 | |||
| 3 | * replace.el (replace-highlight): Bind isearch-forward and | ||
| 4 | isearch-error, ensuring that highlighting is updated if the user | ||
| 5 | switches the search direction (Bug#6808). | ||
| 6 | |||
| 7 | * isearch.el (isearch-lazy-highlight-forward): New var. | ||
| 8 | (isearch-lazy-highlight-new-loop, isearch-lazy-highlight-search): | ||
| 9 | (isearch-lazy-highlight-update): Use it. | ||
| 10 | |||
| 1 | 2010-08-06 Kenichi Handa <handa@m17n.org> | 11 | 2010-08-06 Kenichi Handa <handa@m17n.org> |
| 2 | 12 | ||
| 3 | * international/mule.el (define-charset): Store NAME as :base | 13 | * international/mule.el (define-charset): Store NAME as :base |
diff --git a/lisp/isearch.el b/lisp/isearch.el index d0ad330c5c0..7071497cbfb 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el | |||
| @@ -2574,6 +2574,7 @@ since they have special meaning in a regexp." | |||
| 2574 | (defvar isearch-lazy-highlight-case-fold-search nil) | 2574 | (defvar isearch-lazy-highlight-case-fold-search nil) |
| 2575 | (defvar isearch-lazy-highlight-regexp nil) | 2575 | (defvar isearch-lazy-highlight-regexp nil) |
| 2576 | (defvar isearch-lazy-highlight-space-regexp nil) | 2576 | (defvar isearch-lazy-highlight-space-regexp nil) |
| 2577 | (defvar isearch-lazy-highlight-forward nil) | ||
| 2577 | 2578 | ||
| 2578 | (defun lazy-highlight-cleanup (&optional force) | 2579 | (defun lazy-highlight-cleanup (&optional force) |
| 2579 | "Stop lazy highlighting and remove extra highlighting from current buffer. | 2580 | "Stop lazy highlighting and remove extra highlighting from current buffer. |
| @@ -2613,7 +2614,9 @@ by other Emacs features." | |||
| 2613 | (not (= (window-start) | 2614 | (not (= (window-start) |
| 2614 | isearch-lazy-highlight-window-start)) | 2615 | isearch-lazy-highlight-window-start)) |
| 2615 | (not (= (window-end) ; Window may have been split/joined. | 2616 | (not (= (window-end) ; Window may have been split/joined. |
| 2616 | isearch-lazy-highlight-window-end)))) | 2617 | isearch-lazy-highlight-window-end)) |
| 2618 | (not (eq isearch-forward | ||
| 2619 | isearch-lazy-highlight-forward)))) | ||
| 2617 | ;; something important did indeed change | 2620 | ;; something important did indeed change |
| 2618 | (lazy-highlight-cleanup t) ;kill old loop & remove overlays | 2621 | (lazy-highlight-cleanup t) ;kill old loop & remove overlays |
| 2619 | (when (not isearch-error) | 2622 | (when (not isearch-error) |
| @@ -2628,7 +2631,8 @@ by other Emacs features." | |||
| 2628 | isearch-lazy-highlight-case-fold-search isearch-case-fold-search | 2631 | isearch-lazy-highlight-case-fold-search isearch-case-fold-search |
| 2629 | isearch-lazy-highlight-regexp isearch-regexp | 2632 | isearch-lazy-highlight-regexp isearch-regexp |
| 2630 | isearch-lazy-highlight-wrapped nil | 2633 | isearch-lazy-highlight-wrapped nil |
| 2631 | isearch-lazy-highlight-space-regexp search-whitespace-regexp) | 2634 | isearch-lazy-highlight-space-regexp search-whitespace-regexp |
| 2635 | isearch-lazy-highlight-forward isearch-forward) | ||
| 2632 | (unless (equal isearch-string "") | 2636 | (unless (equal isearch-string "") |
| 2633 | (setq isearch-lazy-highlight-timer | 2637 | (setq isearch-lazy-highlight-timer |
| 2634 | (run-with-idle-timer lazy-highlight-initial-delay nil | 2638 | (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 | (search-invisible nil) ; don't match invisible text | 2648 | (search-invisible nil) ; don't match invisible text |
| 2645 | (retry t) | 2649 | (retry t) |
| 2646 | (success nil) | 2650 | (success nil) |
| 2647 | (bound (if isearch-forward | 2651 | (isearch-forward isearch-lazy-highlight-forward) |
| 2652 | (bound (if isearch-lazy-highlight-forward | ||
| 2648 | (min (or isearch-lazy-highlight-end-limit (point-max)) | 2653 | (min (or isearch-lazy-highlight-end-limit (point-max)) |
| 2649 | (if isearch-lazy-highlight-wrapped | 2654 | (if isearch-lazy-highlight-wrapped |
| 2650 | isearch-lazy-highlight-start | 2655 | isearch-lazy-highlight-start |
| @@ -2678,7 +2683,7 @@ Attempt to do the search exactly the way the pending Isearch would." | |||
| 2678 | (select-window isearch-lazy-highlight-window)) | 2683 | (select-window isearch-lazy-highlight-window)) |
| 2679 | (save-excursion | 2684 | (save-excursion |
| 2680 | (save-match-data | 2685 | (save-match-data |
| 2681 | (goto-char (if isearch-forward | 2686 | (goto-char (if isearch-lazy-highlight-forward |
| 2682 | isearch-lazy-highlight-end | 2687 | isearch-lazy-highlight-end |
| 2683 | isearch-lazy-highlight-start)) | 2688 | isearch-lazy-highlight-start)) |
| 2684 | (while looping | 2689 | (while looping |
| @@ -2691,7 +2696,7 @@ Attempt to do the search exactly the way the pending Isearch would." | |||
| 2691 | (let ((mb (match-beginning 0)) | 2696 | (let ((mb (match-beginning 0)) |
| 2692 | (me (match-end 0))) | 2697 | (me (match-end 0))) |
| 2693 | (if (= mb me) ;zero-length match | 2698 | (if (= mb me) ;zero-length match |
| 2694 | (if isearch-forward | 2699 | (if isearch-lazy-highlight-forward |
| 2695 | (if (= mb (if isearch-lazy-highlight-wrapped | 2700 | (if (= mb (if isearch-lazy-highlight-wrapped |
| 2696 | isearch-lazy-highlight-start | 2701 | isearch-lazy-highlight-start |
| 2697 | (window-end))) | 2702 | (window-end))) |
| @@ -2711,7 +2716,7 @@ Attempt to do the search exactly the way the pending Isearch would." | |||
| 2711 | (overlay-put ov 'priority 1000) | 2716 | (overlay-put ov 'priority 1000) |
| 2712 | (overlay-put ov 'face lazy-highlight-face) | 2717 | (overlay-put ov 'face lazy-highlight-face) |
| 2713 | (overlay-put ov 'window (selected-window)))) | 2718 | (overlay-put ov 'window (selected-window)))) |
| 2714 | (if isearch-forward | 2719 | (if isearch-lazy-highlight-forward |
| 2715 | (setq isearch-lazy-highlight-end (point)) | 2720 | (setq isearch-lazy-highlight-end (point)) |
| 2716 | (setq isearch-lazy-highlight-start (point))))) | 2721 | (setq isearch-lazy-highlight-start (point))))) |
| 2717 | 2722 | ||
| @@ -2721,7 +2726,7 @@ Attempt to do the search exactly the way the pending Isearch would." | |||
| 2721 | (setq looping nil | 2726 | (setq looping nil |
| 2722 | nomore t) | 2727 | nomore t) |
| 2723 | (setq isearch-lazy-highlight-wrapped t) | 2728 | (setq isearch-lazy-highlight-wrapped t) |
| 2724 | (if isearch-forward | 2729 | (if isearch-lazy-highlight-forward |
| 2725 | (progn | 2730 | (progn |
| 2726 | (setq isearch-lazy-highlight-end (window-start)) | 2731 | (setq isearch-lazy-highlight-end (window-start)) |
| 2727 | (goto-char (max (or isearch-lazy-highlight-start-limit (point-min)) | 2732 | (goto-char (max (or isearch-lazy-highlight-start-limit (point-min)) |
diff --git a/lisp/replace.el b/lisp/replace.el index 57b29442605..12263cf5aa6 100644 --- a/lisp/replace.el +++ b/lisp/replace.el | |||
| @@ -1893,7 +1893,9 @@ make, or the user didn't cancel the call." | |||
| 1893 | (let ((isearch-string string) | 1893 | (let ((isearch-string string) |
| 1894 | (isearch-regexp regexp) | 1894 | (isearch-regexp regexp) |
| 1895 | (search-whitespace-regexp nil) | 1895 | (search-whitespace-regexp nil) |
| 1896 | (isearch-case-fold-search case-fold)) | 1896 | (isearch-case-fold-search case-fold) |
| 1897 | (isearch-forward t) | ||
| 1898 | (isearch-error nil)) | ||
| 1897 | (isearch-lazy-highlight-new-loop range-beg range-end)))) | 1899 | (isearch-lazy-highlight-new-loop range-beg range-end)))) |
| 1898 | 1900 | ||
| 1899 | (defun replace-dehighlight () | 1901 | (defun replace-dehighlight () |