emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: highlight failed part of isearch input


From: Stefan Monnier
Subject: Re: highlight failed part of isearch input
Date: Wed, 11 Jul 2007 02:18:00 -0400
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1.50 (gnu/linux)

>>>> There is one inconsistence: when incrementally adding characters to the
>>>> search string it highlights one part (only failed) of the search string,
>>>> but when repeating the search with the same string from the search ring,
>>>> it highlights the whole string.  This is a minor inconsistence, and can
>>>> be tolerated if unavoidable.
>> 
>>> Yes. I don't know how to fix that.
>> 
>> We could simply try to find the longest prefix which does have a match.
>> Can't be that hard.

> When doing a regexp search for
> abc*de
> what is the longest matching prefix for
> abd?

I must be missing someting: what's hard about it?

> What is it for
> ab\(cdf\)?cgh matched to abcdc?  And what about character
> alternatives?

> "Can't be that hard" is always cause for fun...

I think you read too much in my suggestion.  I really meant "the longest
prefix of the user's input which does have a match", so you can simply start
from the user's input (which doesn't match) and iteratively remove the last
char until a search succeeds.  It may not always give you the very best
imaginable information, but least it gives you the same info as Drew's
proposed code in the case where the user just typed the text one char at
a time.
There may be performance issues (if the search text is long, the longest
prefix with a match is short (i.e. we need to iterate many times), and the
buffer is long (i.,e. each iteration's trial search takes a while)), but
other than that it should be pretty easy to code up.


        Stefan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]