[Geany-devel] Find in files - Re: Patches required by gproject

Jiří Techet techet at xxxxx
Mon Jun 21 18:53:58 UTC 2010

On Mon, Jun 21, 2010 at 16:08, Nick Treleaven
<nick.treleaven at btinternet.com> wrote:
> On Mon, 21 Jun 2010 08:47:54 +1000
> Lex Trotman <elextr at gmail.com> wrote:
>> > I like your idea in general, the only thing I don't like about it is
>> > that you wouldn't see the patterns in the FIF dialog, which would make
>> > it a bit unclear what you are searching for. I would propose to have a
>> > "file types" edit box that would be editable by the user even if no
>> > project is opened - this makes sense because users might want to
>> > search for restricted set of files even if they don't use any project.
>> > By default the pattern could be * to search in every file like now
>> > (empty edit box should do the same too). Then there would be the 'Use
>> > project patterns' you propose (not active when no project is open).
>> > When checked, the "file types" edit box would become inactive but
>> > filled with the project patterns so it would be visible directly in
>> > the dialog what the user is searching for. What do you think about it?
> Sounds good.
>> Having a filetype pattern in the find in files dialog could be useful.
>>  Note that --include is a GNU grep extension, so a blank file pattern
>> should be the default and should not generate the option to grep so as
>> to maintain portability.
> Geany currently passes a list of all files and directories to Grep. I

Does it? To me it looks it only calls grep in the given directory.

> think it may be best if Geany does the filtering (and hence also the
> recursing). Also we may want to always filter out hidden files and
> broken links.

There is one problem here - the command line may be too long. By posix
ARG_MAX is at least 4096 but this will be definitely too little for
thousands of files. There are three options how to solve this:

1. Call grep separately for every single file. This is too slow. I
tested something like that some time ago and for about 10000 source
files it takes 30 seconds just to execute grep so many times. To find
e.g. "torvalds" in all *.c;*.h files of linux kernel using -r and
--include it takes only 2 seconds (the first search is always slow
because the files have to be read from disk, but any subsequent search
is really fast as the files are cached by the OS). The speed is very
important for me.

2. Use xargs - this introduces one more external dependency for geany
so it probably isn't the preferable solution.

3. Implement some alternative to xargs and call grep repeatably only
for as many files that can be passed on command line.

Only (3) seems to be a reasonable solution but it means some extra
work. Right now I find the easiest way to implement it using --include
- if no pattern or * pattern is specified, --include will be omitted
(as Lex suggested) and no error reported if the grep doesn't support



> Regards,
> Nick
> _______________________________________________
> Geany-devel mailing list
> Geany-devel at uvena.de
> http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel

More information about the Devel mailing list