diff options
| author | Juri Linkov | 2013-05-30 02:11:41 +0300 |
|---|---|---|
| committer | Juri Linkov | 2013-05-30 02:11:41 +0300 |
| commit | 3c9c9d38d0335e5e8a904e4342838fdcdded870f (patch) | |
| tree | 5be9eb37e04dc7569c62c29ab86c03877d15f21e | |
| parent | 38b787fa727fd98c3d61b9677a30e17d291d490c (diff) | |
| download | emacs-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/ChangeLog | 9 | ||||
| -rw-r--r-- | lisp/replace.el | 79 |
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 @@ | |||
| 1 | 2013-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 | |||
| 1 | 2013-05-29 Stefan Monnier <monnier@iro.umontreal.ca> | 10 | 2013-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 | |||
| 250 | matched is all caps, or capitalized, then its replacement is upcased | 250 | matched is all caps, or capitalized, then its replacement is upcased |
| 251 | or capitalized.) | 251 | or capitalized.) |
| 252 | 252 | ||
| 253 | Ignore read-only matches if `query-replace-skip-read-only' is non-nil, | ||
| 254 | ignore hidden matches if `search-invisible' is nil, and ignore more | ||
| 255 | matches using a non-nil `isearch-filter-predicates'. | ||
| 256 | |||
| 253 | If `replace-lax-whitespace' is non-nil, a space or spaces in the string | 257 | If `replace-lax-whitespace' is non-nil, a space or spaces in the string |
| 254 | to be replaced will match a sequence of whitespace chars defined by the | 258 | to be replaced will match a sequence of whitespace chars defined by the |
| 255 | regexp in `search-whitespace-regexp'. | 259 | regexp in `search-whitespace-regexp'. |
| @@ -300,6 +304,10 @@ pattern of the old text to the new text, if `case-replace' and | |||
| 300 | all caps, or capitalized, then its replacement is upcased or | 304 | all caps, or capitalized, then its replacement is upcased or |
| 301 | capitalized.) | 305 | capitalized.) |
| 302 | 306 | ||
| 307 | Ignore read-only matches if `query-replace-skip-read-only' is non-nil, | ||
| 308 | ignore hidden matches if `search-invisible' is nil, and ignore more | ||
| 309 | matches using a non-nil `isearch-filter-predicates'. | ||
| 310 | |||
| 303 | If `replace-regexp-lax-whitespace' is non-nil, a space or spaces in the regexp | 311 | If `replace-regexp-lax-whitespace' is non-nil, a space or spaces in the regexp |
| 304 | to be replaced will match a sequence of whitespace chars defined by the | 312 | to be replaced will match a sequence of whitespace chars defined by the |
| 305 | regexp in `search-whitespace-regexp'. | 313 | regexp in `search-whitespace-regexp'. |
| @@ -380,6 +388,10 @@ that reads REGEXP. | |||
| 380 | Preserves case in each replacement if `case-replace' and `case-fold-search' | 388 | Preserves case in each replacement if `case-replace' and `case-fold-search' |
| 381 | are non-nil and REGEXP has no uppercase letters. | 389 | are non-nil and REGEXP has no uppercase letters. |
| 382 | 390 | ||
| 391 | Ignore read-only matches if `query-replace-skip-read-only' is non-nil, | ||
| 392 | ignore hidden matches if `search-invisible' is nil, and ignore more | ||
| 393 | matches using a non-nil `isearch-filter-predicates'. | ||
| 394 | |||
| 383 | If `replace-regexp-lax-whitespace' is non-nil, a space or spaces in the regexp | 395 | If `replace-regexp-lax-whitespace' is non-nil, a space or spaces in the regexp |
| 384 | to be replaced will match a sequence of whitespace chars defined by the | 396 | to be replaced will match a sequence of whitespace chars defined by the |
| 385 | regexp in `search-whitespace-regexp'. | 397 | regexp 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, |
| 471 | then its replacement is upcased or capitalized.) | 483 | then its replacement is upcased or capitalized.) |
| 472 | 484 | ||
| 485 | Ignore read-only matches if `query-replace-skip-read-only' is non-nil, | ||
| 486 | ignore hidden matches if `search-invisible' is nil, and ignore more | ||
| 487 | matches using a non-nil `isearch-filter-predicates'. | ||
| 488 | |||
| 473 | If `replace-lax-whitespace' is non-nil, a space or spaces in the string | 489 | If `replace-lax-whitespace' is non-nil, a space or spaces in the string |
| 474 | to be replaced will match a sequence of whitespace chars defined by the | 490 | to be replaced will match a sequence of whitespace chars defined by the |
| 475 | regexp in `search-whitespace-regexp'. | 491 | regexp in `search-whitespace-regexp'. |
| @@ -512,6 +528,10 @@ and TO-STRING is also null.)" | |||
| 512 | Preserve case in each match if `case-replace' and `case-fold-search' | 528 | Preserve case in each match if `case-replace' and `case-fold-search' |
| 513 | are non-nil and REGEXP has no uppercase letters. | 529 | are non-nil and REGEXP has no uppercase letters. |
| 514 | 530 | ||
| 531 | Ignore read-only matches if `query-replace-skip-read-only' is non-nil, | ||
| 532 | ignore hidden matches if `search-invisible' is nil, and ignore more | ||
| 533 | matches using a non-nil `isearch-filter-predicates'. | ||
| 534 | |||
| 515 | If `replace-regexp-lax-whitespace' is non-nil, a space or spaces in the regexp | 535 | If `replace-regexp-lax-whitespace' is non-nil, a space or spaces in the regexp |
| 516 | to be replaced will match a sequence of whitespace chars defined by the | 536 | to be replaced will match a sequence of whitespace chars defined by the |
| 517 | regexp in `search-whitespace-regexp'. | 537 | regexp 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 |