From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: highlight failed part of isearch input Date: Wed, 11 Jul 2007 02:18:00 -0400 Message-ID: References: <85lkdno6hm.fsf@lola.goethe.zz> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1184134717 918 80.91.229.12 (11 Jul 2007 06:18:37 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 11 Jul 2007 06:18:37 +0000 (UTC) Cc: Juri Linkov , Drew Adams , emacs-devel@gnu.org To: David Kastrup Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Jul 11 08:18:29 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1I8VWv-0006ZH-20 for ged-emacs-devel@m.gmane.org; Wed, 11 Jul 2007 08:18:29 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1I8VWu-0003xK-H4 for ged-emacs-devel@m.gmane.org; Wed, 11 Jul 2007 02:18:28 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1I8VWr-0003xE-Vl for emacs-devel@gnu.org; Wed, 11 Jul 2007 02:18:26 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1I8VWq-0003wu-AO for emacs-devel@gnu.org; Wed, 11 Jul 2007 02:18:25 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1I8VWq-0003wr-4n for emacs-devel@gnu.org; Wed, 11 Jul 2007 02:18:24 -0400 Original-Received: from tomts36.bellnexxia.net ([209.226.175.93] helo=tomts36-srv.bellnexxia.net) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1I8VWn-0000uN-0j; Wed, 11 Jul 2007 02:18:21 -0400 Original-Received: from ceviche.home ([70.53.192.15]) by tomts36-srv.bellnexxia.net (InterMail vM.5.01.06.13 201-253-122-130-113-20050324) with ESMTP id <20070711061816.LISW1657.tomts36-srv.bellnexxia.net@ceviche.home>; Wed, 11 Jul 2007 02:18:16 -0400 Original-Received: by ceviche.home (Postfix, from userid 20848) id B0B8F704BA; Wed, 11 Jul 2007 02:18:00 -0400 (EDT) In-Reply-To: <85lkdno6hm.fsf@lola.goethe.zz> (David Kastrup's message of "Wed\, 11 Jul 2007 07\:27\:01 +0200") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1.50 (gnu/linux) X-detected-kernel: Solaris 8 (1) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:74634 Archived-At: >>>> 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