unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Question about dired-do-find-regexp and xref-collect-matches
@ 2019-07-09 23:18 Eric Abrahamsen
  2019-07-09 23:33 ` Drew Adams
  2019-07-30 14:50 ` Dmitry Gutov
  0 siblings, 2 replies; 5+ messages in thread
From: Eric Abrahamsen @ 2019-07-09 23:18 UTC (permalink / raw)
  To: emacs-devel

A while ago I switched to the fish shell, which I generally like better
than bash.

A bit after that I noticed that marking files in Dired and using "A"
(dired-do-find-regexp) to search them was extraordinarily slow. Going up
a level to the parent directory and only marking the child directory,
the search was nearly instantaneous. But that meant I had to search all
the files in the child directory.

I suspected it was something to do with fish, and indeed setting
shell-file-name to "/usr/bin/bash" sped it up a little -- but that's a
bug report for another day.

While poking around I also noticed that dired-do-find-regexp calls
xref-collect-matches once per marked file. That means a full find+grep
call for each file, when a single find+grep call (or even just a single
grep call!) would do the trick.

The search hits are collected as:

(mapcan
 (lambda (file)
   (xref-collect-matches regexp "*" file
                         (and (file-directory-p file)
                              ignores)))
 files)

But the second argument to `xref-collect-matches' can be a
space-separated string of file names -- wouldn't it be easier just to
call `xref-collect-matches' once?

Eric




^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: Question about dired-do-find-regexp and xref-collect-matches
  2019-07-09 23:18 Question about dired-do-find-regexp and xref-collect-matches Eric Abrahamsen
@ 2019-07-09 23:33 ` Drew Adams
  2019-07-10  0:30   ` Eric Abrahamsen
  2019-07-30 14:50 ` Dmitry Gutov
  1 sibling, 1 reply; 5+ messages in thread
From: Drew Adams @ 2019-07-09 23:33 UTC (permalink / raw)
  To: Eric Abrahamsen, emacs-devel

> I noticed that marking files in Dired and using "A"
> (dired-do-find-regexp) to search them was extraordinarily slow. Going up
> a level to the parent directory and only marking the child directory,
> the search was nearly instantaneous. But that meant I had to search all
> the files in the child directory.
> 
> I suspected it was something to do with fish, and indeed setting
> shell-file-name to "/usr/bin/bash" sped it up a little -- but that's a
> bug report for another day.
> 
> While poking around I also noticed that dired-do-find-regexp calls
> xref-collect-matches once per marked file. That means a full find+grep
> call for each file, when a single find+grep call (or even just a single
> grep call!) would do the trick.
> 
> The search hits are collected as:
> 
> (mapcan
>  (lambda (file)
>    (xref-collect-matches regexp "*" file
>                          (and (file-directory-p file)
>                               ignores)))
>  files)
> 
> But the second argument to `xref-collect-matches' can be a
> space-separated string of file names -- wouldn't it be easier just to
> call `xref-collect-matches' once?

Meanwhile (fortunately), you can still use
`dired-do-search' (which used to be bound to `A').

If that wasn't "extraordinarily slow" for you
before, it still might not be.  Maybe try it.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Question about dired-do-find-regexp and xref-collect-matches
  2019-07-09 23:33 ` Drew Adams
@ 2019-07-10  0:30   ` Eric Abrahamsen
  0 siblings, 0 replies; 5+ messages in thread
From: Eric Abrahamsen @ 2019-07-10  0:30 UTC (permalink / raw)
  To: Drew Adams; +Cc: emacs-devel

Drew Adams <drew.adams@oracle.com> writes:


[...]

> Meanwhile (fortunately), you can still use
> `dired-do-search' (which used to be bound to `A').
>
> If that wasn't "extraordinarily slow" for you
> before, it still might not be. Maybe try it.

That returns instantly! At least, for the first result. But the xref
interface is so nice to use...



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Question about dired-do-find-regexp and xref-collect-matches
  2019-07-09 23:18 Question about dired-do-find-regexp and xref-collect-matches Eric Abrahamsen
  2019-07-09 23:33 ` Drew Adams
@ 2019-07-30 14:50 ` Dmitry Gutov
  2019-07-30 17:22   ` Eric Abrahamsen
  1 sibling, 1 reply; 5+ messages in thread
From: Dmitry Gutov @ 2019-07-30 14:50 UTC (permalink / raw)
  To: Eric Abrahamsen, emacs-devel

Hi Eric,

On 10.07.2019 2:18, Eric Abrahamsen wrote:
> A while ago I switched to the fish shell, which I generally like better
> than bash.

I also like fish, a lot. I don't use it inside Emacs, though.

> While poking around I also noticed that dired-do-find-regexp calls
> xref-collect-matches once per marked file. That means a full find+grep
> call for each file, when a single find+grep call (or even just a single
> grep call!) would do the trick.

That sounds like a bug report material. Up until now I figured a few 
extra shell process calls wouldn't matter, but maybe they can.

Just how many files are you marking in the given example?

> The search hits are collected as:
> 
> (mapcan
>   (lambda (file)
>     (xref-collect-matches regexp "*" file
>                           (and (file-directory-p file)
>                                ignores)))
>   files)
> 
> But the second argument to `xref-collect-matches' can be a
> space-separated string of file names -- wouldn't it be easier just to
> call `xref-collect-matches' once?

Not exactly. That FILES argument is something different (a list of globs).

Overall, this shouldn't be too hard to fix. Could you send your response 
to the bug tracker as a new report?



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Question about dired-do-find-regexp and xref-collect-matches
  2019-07-30 14:50 ` Dmitry Gutov
@ 2019-07-30 17:22   ` Eric Abrahamsen
  0 siblings, 0 replies; 5+ messages in thread
From: Eric Abrahamsen @ 2019-07-30 17:22 UTC (permalink / raw)
  To: emacs-devel

Dmitry Gutov <dgutov@yandex.ru> writes:

> Hi Eric,
>
> On 10.07.2019 2:18, Eric Abrahamsen wrote:
>> A while ago I switched to the fish shell, which I generally like better
>> than bash.
>
> I also like fish, a lot. I don't use it inside Emacs, though.

Yeah, I just set Emacs' shell to bash, seems safer.

>> While poking around I also noticed that dired-do-find-regexp calls
>> xref-collect-matches once per marked file. That means a full find+grep
>> call for each file, when a single find+grep call (or even just a single
>> grep call!) would do the trick.
>
> That sounds like a bug report material. Up until now I figured a few
> extra shell process calls wouldn't matter, but maybe they can.
>
> Just how many files are you marking in the given example?

This was somewhere between 250-300 XML files.

>> The search hits are collected as:
>>
>> (mapcan
>>   (lambda (file)
>>     (xref-collect-matches regexp "*" file
>>                           (and (file-directory-p file)
>>                                ignores)))
>>   files)
>>
>> But the second argument to `xref-collect-matches' can be a
>> space-separated string of file names -- wouldn't it be easier just to
>> call `xref-collect-matches' once?
>
> Not exactly. That FILES argument is something different (a list of globs).
>
> Overall, this shouldn't be too hard to fix. Could you send your
> response to the bug tracker as a new report?

Done, as bug#36857. Thanks for looking at this.




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-07-30 17:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-07-09 23:18 Question about dired-do-find-regexp and xref-collect-matches Eric Abrahamsen
2019-07-09 23:33 ` Drew Adams
2019-07-10  0:30   ` Eric Abrahamsen
2019-07-30 14:50 ` Dmitry Gutov
2019-07-30 17:22   ` Eric Abrahamsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).