Subject: bug#6362: Emacs command `dired-isearch-filenames-regexp' cause CPU usage 100%

From: Juri Linkov <[email-masked]>
Date: Mon, 07 Jun 2010 21:09:42 +0300

> You can observe the same problem with query-replace in wdired.
> For instance, type:
>
> 1. M-x wdired-change-to-wdired-mode RET
> 2. M-x query-replace-regexp RET ^f RET replacement RET

BTW, there is another bug in query-replace lazy-highlighting in dired.
Wdired sets `query-replace-skip-read-only' to replace only in
file names, but during replacement all read-only matches are
lazy-highlighted too.  This can be fixed with this patch:

=== modified file 'lisp/wdired.el'
--- lisp/wdired.el	2010-01-13 08:35:10 +0000
+++ lisp/wdired.el	2010-06-06 18:09:04 +0000
@@ -243,6 +243,8 @@ (defun wdired-change-to-wdired-mode ()
        (buffer-substring (point-min) (point-max)))
   (set (make-local-variable 'wdired-old-point) (point))
   (set (make-local-variable 'query-replace-skip-read-only) t)
+  (set (make-local-variable 'isearch-filter-predicate)
+       'wdired-isearch-filter-read-only)
   (use-local-map wdired-mode-map)
   (force-mode-line-update)
   (setq buffer-read-only nil)
@@ -268,6 +270,11 @@ (defun wdired-change-to-wdired-mode ()
 		 "Press \\[wdired-finish-edit] when finished \
 or \\[wdired-abort-changes] to abort changes")))
 
+(defun wdired-isearch-filter-read-only (beg end)
+  "Skip matches that have a read-only property."
+  (and (isearch-filter-visible beg end)
+       (not (text-property-not-all (min beg end) (max beg end)
+				   'read-only nil))))
 
 ;; Protect the buffer so only the filenames can be changed, and put
 ;; properties so filenames (old and new) can be easily found.

-- 
Juri Linkov
http://www.jurta.org/emacs/