GNU bug report logs - #6362
Emacs command `dired-isearch-filenames-regexp' cause CPU usage 100%

Previous Next

Package: emacs;

Reported by: Li Zhai <mrzhaili <at> gmail.com>

Date: Sun, 6 Jun 2010 03:37:01 UTC

Severity: normal

Found in version 23.2.1

Done: Juri Linkov <juri <at> jurta.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 6362 in the body.
You can then email your comments to 6362 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6362; Package emacs. (Sun, 06 Jun 2010 03:37:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Li Zhai <mrzhaili <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 06 Jun 2010 03:37:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Li Zhai <mrzhaili <at> gmail.com>
To: "bug.gnu.submit" <submit <at> debbugs.gnu.org>
Subject: Emacs command `dired-isearch-filenames-regexp' cause CPU usage 100%
Date: Sun, 6 Jun 2010 11:36:00 +0800
Package: Emacs
Version: 23.2.1

I use the command `dired-isearch-filenames-regexp' to find some files
in a directory. I use the the anchor `^' to match the files start with
something. Emacs is suspended and the CPU usage is 100%.Here is a
transcript:

1. Open a directory in dired mode.
2. Input `M-x dired-isearch-filenames-regexp RET  ^ f RET'

Emacs will suspend rather than match the file names start with `f'.

I'm using Windows XP, Emacs version 23.2.

Bye,

Li Zhai




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6362; Package emacs. (Sun, 06 Jun 2010 09:57:02 GMT) Full text and rfc822 format available.

Message #8 received at 6362 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: Li Zhai <mrzhaili <at> gmail.com>
Cc: 6362 <at> debbugs.gnu.org
Subject: Re: bug#6362: Emacs command `dired-isearch-filenames-regexp' cause
	CPU usage 100%
Date: Sun, 06 Jun 2010 12:54:55 +0300
> I use the command `dired-isearch-filenames-regexp' to find some files
> in a directory. I use the the anchor `^' to match the files start with
> something. Emacs is suspended and the CPU usage is 100%.Here is a
> transcript:
>
> 1. Open a directory in dired mode.
> 2. Input `M-x dired-isearch-filenames-regexp RET  ^ f RET'
>
> Emacs will suspend rather than match the file names start with `f'.

Thanks for the report.  I fixed looping in lazy-highlighting.
Now the loop in `isearch-lazy-highlight-search' is exactly like
in `isearch-search' that checks for the empty match (and
`isearch-lazy-highlight-update' takes care about forwarding
point to the next character in this case).

As for implementing matching at the beginning of file names with `^',
it seems this is not possible to do.  `re-search-forward' matches only
at the beginning of a line, not in the middle of a line.

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

Do you expect that query-replace will rename file names
that start with `f'?

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




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6362; Package emacs. (Sun, 06 Jun 2010 12:31:02 GMT) Full text and rfc822 format available.

Message #11 received at 6362 <at> debbugs.gnu.org (full text, mbox):

From: Li Zhai <mrzhaili <at> gmail.com>
To: Juri Linkov <juri <at> jurta.org>
Cc: 6362 <at> debbugs.gnu.org
Subject: Re: bug#6362: Emacs command `dired-isearch-filenames-regexp' cause 
	CPU usage 100%
Date: Sun, 6 Jun 2010 20:30:42 +0800
Yes, I expect that query-replace will rename file names start with
`f'. As the search process just matched the file names, it is a simple
thought that `^' means the beginning of the file name.

If we could add some special syntax properties to the white-space
before the file name, it is possible to match the file names start
with `f'. For instance, type :

dired-isearch-filenames-regexp RET \sxf  RET

At here, the `x' means the special syntax class.

It's just my random thought. At most times, a white-space can solve my
problem, like `dired-isearch-filenames-regexp RET SPC f  RET'.

On Sun, Jun 6, 2010 at 5:54 PM, Juri Linkov <juri <at> jurta.org> wrote:
>> I use the command `dired-isearch-filenames-regexp' to find some files
>> in a directory. I use the the anchor `^' to match the files start with
>> something. Emacs is suspended and the CPU usage is 100%.Here is a
>> transcript:
>>
>> 1. Open a directory in dired mode.
>> 2. Input `M-x dired-isearch-filenames-regexp RET  ^ f RET'
>>
>> Emacs will suspend rather than match the file names start with `f'.
>
> Thanks for the report.  I fixed looping in lazy-highlighting.
> Now the loop in `isearch-lazy-highlight-search' is exactly like
> in `isearch-search' that checks for the empty match (and
> `isearch-lazy-highlight-update' takes care about forwarding
> point to the next character in this case).
>
> As for implementing matching at the beginning of file names with `^',
> it seems this is not possible to do.  `re-search-forward' matches only
> at the beginning of a line, not in the middle of a line.
>
> 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
>
> Do you expect that query-replace will rename file names
> that start with `f'?
>
> --
> Juri Linkov
> http://www.jurta.org/emacs/
>




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6362; Package emacs. (Mon, 07 Jun 2010 18:53:02 GMT) Full text and rfc822 format available.

Message #14 received at 6362 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: Li Zhai <mrzhaili <at> gmail.com>
Cc: 6362 <at> debbugs.gnu.org
Subject: Re: bug#6362: Emacs command `dired-isearch-filenames-regexp' cause
	CPU usage 100%
Date: Mon, 07 Jun 2010 21:05:09 +0300
> Yes, I expect that query-replace will rename file names start with
> `f'. As the search process just matched the file names, it is a simple
> thought that `^' means the beginning of the file name.
>
> If we could add some special syntax properties to the white-space
> before the file name, it is possible to match the file names start
> with `f'. For instance, type :
>
> dired-isearch-filenames-regexp RET \sxf  RET
>
> At here, the `x' means the special syntax class.

`\sx' matches a character, but it would be better to match the empty string
like `^' does.

One variant is to narrow the dired buffer so the beginning of a line
will be the beginning of a file name.  Unfortunately, it's impossible
to narrow to columns, only to lines.

Another variant is to add a new predicate function in regex.c
that will specify where ^ should match, so dired will set it
to a function that returns non-nil at the beginning of a file name.

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




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6362; Package emacs. (Mon, 07 Jun 2010 18:53:02 GMT) Full text and rfc822 format available.

Message #17 received at 6362 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: 6362 <at> debbugs.gnu.org
Subject: Re: bug#6362: Emacs command `dired-isearch-filenames-regexp' cause
	CPU usage 100%
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/




Reply sent to Juri Linkov <juri <at> jurta.org>:
You have taken responsibility. (Fri, 09 Sep 2011 15:55:02 GMT) Full text and rfc822 format available.

Notification sent to Li Zhai <mrzhaili <at> gmail.com>:
bug acknowledged by developer. (Fri, 09 Sep 2011 15:55:03 GMT) Full text and rfc822 format available.

Message #22 received at 6362-done <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: 6362-done <at> debbugs.gnu.org
Subject: Re: bug#6362: Emacs command `dired-isearch-filenames-regexp' cause
	CPU usage 100%
Date: Fri, 09 Sep 2011 18:49:19 +0300
> 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:
> [...]
> +(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))))

I installed this old patch and closed this bug.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 08 Oct 2011 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 12 years and 197 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.