]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/replace.el (perform-replace): Ignore invisible matches.
authorJuri Linkov <juri@jurta.org>
Mon, 27 May 2013 23:02:37 +0000 (02:02 +0300)
committerJuri Linkov <juri@jurta.org>
Mon, 27 May 2013 23:02:37 +0000 (02:02 +0300)
In addition to checking `query-replace-skip-read-only', also
filter out matches by calling `run-hook-with-args-until-failure'
on `isearch-filter-predicates', and also check `search-invisible'
for t or call `isearch-range-invisible'.
(replace-dehighlight): Call `isearch-clean-overlays'.

Fixes: debbugs:11746
etc/NEWS
lisp/ChangeLog
lisp/replace.el

index fbb32326dacb2be82dec82c57d5100806c11fc83..80546ce985af9e697dac121e99d16803c7ca1ced 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -236,11 +236,14 @@ callers to fit the image to a frame other than the selected frame.
 entries displayed by `Info-index-next', `Info-virtual-index' and
 `info-apropos'.
 
-** Isearch
+** Search and Replace
 
 *** `C-x 8 RET' in Isearch mode reads a character by its Unicode name
 and adds it to the search string.
 
+*** `query-replace' skips invisible text when `search-invisible' is nil,
+and opens overlays with hidden text when `search-invisible' is `open'.
+
 ** MH-E has been updated to MH-E version 8.5.
 See MH-E-NEWS for details.
 
index 486e5d75343d5b69e57d1badd15355a771ede1ac..cc3122f7e6fe7c3002095cdcf8db993d8d6d8e83 100644 (file)
@@ -1,3 +1,12 @@
+2013-05-27  Juri Linkov  <juri@jurta.org>
+
+       * replace.el (perform-replace): Ignore invisible matches.
+       In addition to checking `query-replace-skip-read-only', also
+       filter out matches by calling `run-hook-with-args-until-failure'
+       on `isearch-filter-predicates', and also check `search-invisible'
+       for t or call `isearch-range-invisible'.
+       (replace-dehighlight): Call `isearch-clean-overlays'.  (Bug#11746)
+
 2013-05-27  Juri Linkov  <juri@jurta.org>
 
        * isearch.el (isearch-filter-predicates): Rename from
index 1bebff448fa2fae9b3f47c92d4ae3cb034d561b1..7c26f1ed06345932697147b9a67a2f08a3f81fab 100644 (file)
@@ -2003,10 +2003,18 @@ make, or the user didn't cancel the call."
                                     match))))))
 
          ;; Optionally ignore matches that have a read-only property.
-         (unless (and query-replace-skip-read-only
-                      (text-property-not-all
-                       (nth 0 real-match-data) (nth 1 real-match-data)
-                       'read-only nil))
+         (when (and (or (not query-replace-skip-read-only)
+                        (not (text-property-not-all
+                              (nth 0 real-match-data) (nth 1 real-match-data)
+                              'read-only nil)))
+                    ;; Optionally filter out matches.
+                    (run-hook-with-args-until-failure
+                     'isearch-filter-predicates
+                     (nth 0 real-match-data) (nth 1 real-match-data))
+                    ;; Optionally ignore invisible matches.
+                    (or (eq search-invisible t)
+                        (not (isearch-range-invisible
+                              (nth 0 real-match-data) (nth 1 real-match-data)))))
 
            ;; Calculate the replacement string, if necessary.
            (when replacements
@@ -2251,6 +2259,8 @@ make, or the user didn't cancel the call."
     (delete-overlay replace-overlay))
   (when query-replace-lazy-highlight
     (lazy-highlight-cleanup lazy-highlight-cleanup)
-    (setq isearch-lazy-highlight-last-string nil)))
+    (setq isearch-lazy-highlight-last-string nil))
+  ;; Close overlays opened by `isearch-range-invisible' in `perform-replace'.
+  (isearch-clean-overlays))
 
 ;;; replace.el ends here