[prev in list] [next in list] [prev in thread] [next in thread] 

List:       lyx-devel
Subject:    Re: New search engine
From:       Alfredo Braunstein <abr () mailandnews ! com>
Date:       2000-02-29 10:09:31
[Download RAW message or body]

[Como Dekel Tsur dijo:]
> It is good to have people contributing to the LyX project, but why are you
> using your own code for regexp searching? I think that you should use the
> GNU regex library using the LyX class LRegex (file /support/LRegex.C),
> but I may be wrong.

Well, I have thinked about it, but:

1)If I'm not wrong, the regex library only allows searches in a chunk of
memory. As I like to have multi-line searches (treating the document as a
whole, not a line at a time), I think it will be some work and lost of
efficiency in doing necesary conversions between formats. (Please tell me if
I'm wrong, I probably do. I know little about Lyx internals.)

2)I had implemented searches in a stream. I have coded most of it before
(while studying the subject), so I have thinked it would be easier use mine
than some other's. And I like my code. (I know, it's selfish. But I do this
for fun!). Besides, this way is very easy to adapt to Lyx par,pos
structure, because I read 1 char at a time). And...

2a)I am learning C++ while doing it (so please, if my code ever gets to
somewhere, feel free to teach me)

3)I do not think that the 'regular expression sintax' is suitable as is for
searches in a text document (think about having to escape dots for example).
I don't liked it very much, so i changed it a bit.
It can be changed further to make it nicer.

4) My code i reasonably fast (not as fast as grep, because it do not use 100
fancy tricks, but... it is simple). The time is bounded by a linear function
on the lenght of the document (constant depending on the expression). I can
search a 1.5 meg doc with a regex search in about 3 sec in my amdk6-3. It
does not consume memory, almost. And I am improving it. So it is useable.
Standard searches don't make a difference in time with the actual functions
(which, by the way, aren't very optimal).

5) I have yesterday coded the Lyx-related parts (well, 2 loops, actually)
and it works like a charm!

> On the subject of searching, I would like to see an option to do 
> search & replace on insets. For example, for changing a label in the
> document, I need to do search/replace on all the label and reference insets.

I'd like it too. I think that 2) makes it more feasible (But only if 1) is
right, though). Right now, I think it is easy to implement searches of types
of insets (without messing inside them).

6) I don't know if the regex library can do a regexp search backwards, I
will check. (Otherwise, it is a matter of rewriting a reg expression
backwards, what it's not as easy as it may sound). Mine can, by the way. 

So, what do you think?

			Alfredo

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic