From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Davis Herring" Newsgroups: gmane.emacs.devel Subject: Re: `completion-in-region' Date: Mon, 12 Apr 2010 07:50:40 -0700 (PDT) Message-ID: <33121.130.55.118.19.1271083840.squirrel@webmail.lanl.gov> References: <493575A8A83B43BCB1AF49E239599A77@us.oracle.com> Reply-To: herring@lanl.gov NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: dough.gmane.org 1271083980 21485 80.91.229.12 (12 Apr 2010 14:53:00 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 12 Apr 2010 14:53:00 +0000 (UTC) Cc: emacs-devel@gnu.org, Stefan Monnier , Drew Adams , Leo To: "Lennart Borgman" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Apr 12 16:52:58 2010 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.69) (envelope-from ) id 1O1L0O-00060i-Vd for ged-emacs-devel@m.gmane.org; Mon, 12 Apr 2010 16:52:53 +0200 Original-Received: from localhost ([127.0.0.1]:39767 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O1L0L-0007Ch-2V for ged-emacs-devel@m.gmane.org; Mon, 12 Apr 2010 10:52:49 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O1KyP-0006hJ-Aa for emacs-devel@gnu.org; Mon, 12 Apr 2010 10:50:49 -0400 Original-Received: from [140.186.70.92] (port=54224 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O1KyN-0006h9-JL for emacs-devel@gnu.org; Mon, 12 Apr 2010 10:50:48 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O1KyL-00010b-OG for emacs-devel@gnu.org; Mon, 12 Apr 2010 10:50:47 -0400 Original-Received: from proofpoint2.lanl.gov ([204.121.3.26]:44576) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O1KyL-000103-Ac for emacs-devel@gnu.org; Mon, 12 Apr 2010 10:50:45 -0400 Original-Received: from mailrelay1.lanl.gov (mailrelay1.lanl.gov [128.165.4.101]) by proofpoint2.lanl.gov (8.14.3/8.14.3) with ESMTP id o3CEoe9c017576; Mon, 12 Apr 2010 08:50:40 -0600 Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by mailrelay1.lanl.gov (Postfix) with ESMTP id 7ED0B341D41; Mon, 12 Apr 2010 08:50:40 -0600 (MDT) X-NIE-2-Virus-Scanner: amavisd-new at mailrelay1.lanl.gov Original-Received: from webmail1.lanl.gov (webmail1.lanl.gov [128.165.4.106]) by mailrelay1.lanl.gov (Postfix) with ESMTP id 68EAF341D3F; Mon, 12 Apr 2010 08:50:40 -0600 (MDT) Original-Received: by webmail1.lanl.gov (Postfix, from userid 48) id 66AFE1CA80BA; Mon, 12 Apr 2010 08:50:40 -0600 (MDT) Original-Received: from 130.55.118.19 (SquirrelMail authenticated user 196434) by webmail.lanl.gov with HTTP; Mon, 12 Apr 2010 07:50:40 -0700 (PDT) In-Reply-To: User-Agent: SquirrelMail/1.4.8-5.el5_4.10.lanl1 X-Priority: 3 (Normal) Importance: Normal X-Proofpoint-Virus-Version: vendor=fsecure engine=1.12.8161:2.4.5, 1.2.40, 4.0.166 definitions=2010-04-12_10:2010-02-06, 2010-04-12, 2010-04-12 signatures=0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) 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:123520 Archived-At: > I do not understand the "for each" here. I thought that since ".*?" is > greedy that means that only the first "a" could match. (Stefan spoke to this.) > But maybe I am missing that the first ".*?" is not anchored. Would > "^.*?a.*?b.*?c" behave differently? You're right, actually, that this would help (though again the ?s are irrelevant). A search (as opposed to a match; `looking-at' is a match, but (confusingly) `string-match' is a search) with the regexp ".*a.*b.*c" will be O(N^4) in the length of the subject string because the search will look for a c for each b match, a b for each a match, and an a for each distance from the search point, and will search starting from each position in the string. Anchoring the search (which turns it into a match, effectively) removes that last, outermost layer, and so reduces the complexity to N^3. However, I would implement this "fuzzy" search with just "a.*b.*c", which has the same N^3 behavior without the "^.*" prefix that doesn't get you anything. (Of course, if it were implemented as a match, then the leading .* would be necessary, the ^ would be superfluous, and the complexity would still be N^3.) Davis -- This product is sold by volume, not by mass. If it appears too dense or too sparse, it is because mass-energy conversion has occurred during shipping.