aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuri Linkov2013-05-30 02:11:41 +0300
committerJuri Linkov2013-05-30 02:11:41 +0300
commit3c9c9d38d0335e5e8a904e4342838fdcdded870f (patch)
tree5be9eb37e04dc7569c62c29ab86c03877d15f21e
parent38b787fa727fd98c3d61b9677a30e17d291d490c (diff)
downloademacs-3c9c9d38d0335e5e8a904e4342838fdcdded870f.tar.gz
emacs-3c9c9d38d0335e5e8a904e4342838fdcdded870f.zip
* lisp/replace.el (perform-replace): Add `skip-read-only-count',
`skip-filtered-count', `skip-invisible-count' let-bound to 0. Increment them for corresponding conditions and report the number of skipped occurrences in the final message. (query-replace, query-replace-regexp, query-replace-regexp-eval) (replace-string, replace-regexp): Doc fix. Fixes: debbugs:11746
-rw-r--r--lisp/ChangeLog9
-rw-r--r--lisp/replace.el79
2 files changed, 71 insertions, 17 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index e4708639514..bcf8462d864 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,12 @@
12013-05-29 Juri Linkov <juri@jurta.org>
2
3 * replace.el (perform-replace): Add `skip-read-only-count',
4 `skip-filtered-count', `skip-invisible-count' let-bound to 0.
5 Increment them for corresponding conditions and report the number
6 of skipped occurrences in the final message. (Bug#11746)
7 (query-replace, query-replace-regexp, query-replace-regexp-eval)
8 (replace-string, replace-regexp): Doc fix.
9
12013-05-29 Stefan Monnier <monnier@iro.umontreal.ca> 102013-05-29 Stefan Monnier <monnier@iro.umontreal.ca>
2 11
3 * emacs-lisp/trace.el (trace--read-args): Provide a default. 12 * emacs-lisp/trace.el (trace--read-args): Provide a default.
diff --git a/lisp/replace.el b/lisp/replace.el
index 86956a614cd..ae6622958d3 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -250,6 +250,10 @@ letters. \(Transferring the case pattern means that if the old text
250matched is all caps, or capitalized, then its replacement is upcased 250matched is all caps, or capitalized, then its replacement is upcased
251or capitalized.) 251or capitalized.)
252 252
253Ignore read-only matches if `query-replace-skip-read-only' is non-nil,
254ignore hidden matches if `search-invisible' is nil, and ignore more
255matches using a non-nil `isearch-filter-predicates'.
256
253If `replace-lax-whitespace' is non-nil, a space or spaces in the string 257If `replace-lax-whitespace' is non-nil, a space or spaces in the string
254to be replaced will match a sequence of whitespace chars defined by the 258to be replaced will match a sequence of whitespace chars defined by the
255regexp in `search-whitespace-regexp'. 259regexp in `search-whitespace-regexp'.
@@ -300,6 +304,10 @@ pattern of the old text to the new text, if `case-replace' and
300all caps, or capitalized, then its replacement is upcased or 304all caps, or capitalized, then its replacement is upcased or
301capitalized.) 305capitalized.)
302 306
307Ignore read-only matches if `query-replace-skip-read-only' is non-nil,
308ignore hidden matches if `search-invisible' is nil, and ignore more
309matches using a non-nil `isearch-filter-predicates'.
310
303If `replace-regexp-lax-whitespace' is non-nil, a space or spaces in the regexp 311If `replace-regexp-lax-whitespace' is non-nil, a space or spaces in the regexp
304to be replaced will match a sequence of whitespace chars defined by the 312to be replaced will match a sequence of whitespace chars defined by the
305regexp in `search-whitespace-regexp'. 313regexp in `search-whitespace-regexp'.
@@ -380,6 +388,10 @@ that reads REGEXP.
380Preserves case in each replacement if `case-replace' and `case-fold-search' 388Preserves case in each replacement if `case-replace' and `case-fold-search'
381are non-nil and REGEXP has no uppercase letters. 389are non-nil and REGEXP has no uppercase letters.
382 390
391Ignore read-only matches if `query-replace-skip-read-only' is non-nil,
392ignore hidden matches if `search-invisible' is nil, and ignore more
393matches using a non-nil `isearch-filter-predicates'.
394
383If `replace-regexp-lax-whitespace' is non-nil, a space or spaces in the regexp 395If `replace-regexp-lax-whitespace' is non-nil, a space or spaces in the regexp
384to be replaced will match a sequence of whitespace chars defined by the 396to be replaced will match a sequence of whitespace chars defined by the
385regexp in `search-whitespace-regexp'. 397regexp in `search-whitespace-regexp'.
@@ -470,6 +482,10 @@ are non-nil and FROM-STRING has no uppercase letters.
470\(Preserving case means that if the string matched is all caps, or capitalized, 482\(Preserving case means that if the string matched is all caps, or capitalized,
471then its replacement is upcased or capitalized.) 483then its replacement is upcased or capitalized.)
472 484
485Ignore read-only matches if `query-replace-skip-read-only' is non-nil,
486ignore hidden matches if `search-invisible' is nil, and ignore more
487matches using a non-nil `isearch-filter-predicates'.
488
473If `replace-lax-whitespace' is non-nil, a space or spaces in the string 489If `replace-lax-whitespace' is non-nil, a space or spaces in the string
474to be replaced will match a sequence of whitespace chars defined by the 490to be replaced will match a sequence of whitespace chars defined by the
475regexp in `search-whitespace-regexp'. 491regexp in `search-whitespace-regexp'.
@@ -512,6 +528,10 @@ and TO-STRING is also null.)"
512Preserve case in each match if `case-replace' and `case-fold-search' 528Preserve case in each match if `case-replace' and `case-fold-search'
513are non-nil and REGEXP has no uppercase letters. 529are non-nil and REGEXP has no uppercase letters.
514 530
531Ignore read-only matches if `query-replace-skip-read-only' is non-nil,
532ignore hidden matches if `search-invisible' is nil, and ignore more
533matches using a non-nil `isearch-filter-predicates'.
534
515If `replace-regexp-lax-whitespace' is non-nil, a space or spaces in the regexp 535If `replace-regexp-lax-whitespace' is non-nil, a space or spaces in the regexp
516to be replaced will match a sequence of whitespace chars defined by the 536to be replaced will match a sequence of whitespace chars defined by the
517regexp in `search-whitespace-regexp'. 537regexp in `search-whitespace-regexp'.
@@ -1934,6 +1954,9 @@ make, or the user didn't cancel the call."
1934 (keep-going t) 1954 (keep-going t)
1935 (stack nil) 1955 (stack nil)
1936 (replace-count 0) 1956 (replace-count 0)
1957 (skip-read-only-count 0)
1958 (skip-filtered-count 0)
1959 (skip-invisible-count 0)
1937 (nonempty-match nil) 1960 (nonempty-match nil)
1938 (multi-buffer nil) 1961 (multi-buffer nil)
1939 (recenter-last-op nil) ; Start cycling order with initial position. 1962 (recenter-last-op nil) ; Start cycling order with initial position.
@@ -2042,20 +2065,24 @@ make, or the user didn't cancel the call."
2042 (and (/= (nth 0 match) (nth 1 match)) 2065 (and (/= (nth 0 match) (nth 1 match))
2043 match)))))) 2066 match))))))
2044 2067
2045 ;; Optionally ignore matches that have a read-only property. 2068 (cond
2046 (when (and (or (not query-replace-skip-read-only) 2069 ;; Optionally ignore matches that have a read-only property.
2047 (not (text-property-not-all 2070 ((not (or (not query-replace-skip-read-only)
2048 (nth 0 real-match-data) (nth 1 real-match-data) 2071 (not (text-property-not-all
2049 'read-only nil))) 2072 (nth 0 real-match-data) (nth 1 real-match-data)
2050 ;; Optionally filter out matches. 2073 'read-only nil))))
2051 (run-hook-with-args-until-failure 2074 (setq skip-read-only-count (1+ skip-read-only-count)))
2052 'isearch-filter-predicates 2075 ;; Optionally filter out matches.
2053 (nth 0 real-match-data) (nth 1 real-match-data)) 2076 ((not (run-hook-with-args-until-failure
2054 ;; Optionally ignore invisible matches. 2077 'isearch-filter-predicates
2055 (or (eq search-invisible t) 2078 (nth 0 real-match-data) (nth 1 real-match-data)))
2056 (not (isearch-range-invisible 2079 (setq skip-filtered-count (1+ skip-filtered-count)))
2057 (nth 0 real-match-data) (nth 1 real-match-data))))) 2080 ;; Optionally ignore invisible matches.
2058 2081 ((not (or (eq search-invisible t)
2082 (not (isearch-range-invisible
2083 (nth 0 real-match-data) (nth 1 real-match-data)))))
2084 (setq skip-invisible-count (1+ skip-invisible-count)))
2085 (t
2059 ;; Calculate the replacement string, if necessary. 2086 ;; Calculate the replacement string, if necessary.
2060 (when replacements 2087 (when replacements
2061 (set-match-data real-match-data) 2088 (set-match-data real-match-data)
@@ -2260,13 +2287,31 @@ make, or the user didn't cancel the call."
2260 (match-end 0) 2287 (match-end 0)
2261 (current-buffer)) 2288 (current-buffer))
2262 (match-data t))) 2289 (match-data t)))
2263 stack))))) 2290 stack))))))
2264 2291
2265 (replace-dehighlight)) 2292 (replace-dehighlight))
2266 (or unread-command-events 2293 (or unread-command-events
2267 (message "Replaced %d occurrence%s" 2294 (message "Replaced %d occurrence%s%s"
2268 replace-count 2295 replace-count
2269 (if (= replace-count 1) "" "s"))) 2296 (if (= replace-count 1) "" "s")
2297 (if (> (+ skip-read-only-count
2298 skip-filtered-count
2299 skip-invisible-count) 0)
2300 (format " (skipped %s)"
2301 (mapconcat
2302 'identity
2303 (delq nil (list
2304 (if (> skip-read-only-count 0)
2305 (format "%s read-only"
2306 skip-read-only-count))
2307 (if (> skip-invisible-count 0)
2308 (format "%s invisible"
2309 skip-invisible-count))
2310 (if (> skip-filtered-count 0)
2311 (format "%s filtered out"
2312 skip-filtered-count))))
2313 ", "))
2314 "")))
2270 (or (and keep-going stack) multi-buffer))) 2315 (or (and keep-going stack) multi-buffer)))
2271 2316
2272;;; replace.el ends here 2317;;; replace.el ends here