From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tassilo Horn Newsgroups: gmane.emacs.help Subject: Re: `looking-back' strange warning Date: Thu, 01 Oct 2015 11:29:36 +0200 Message-ID: <874mibhr7j.fsf@gnu.org> References: <560B9C7F.2060301@easy-emacs.de> <560CD7CE.4010404@yandex.ru> <560CE576.9030109@easy-emacs.de> <878u7nhueu.fsf@gnu.org> <560CF2F2.1060601@easy-emacs.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1443710409 21075 80.91.229.3 (1 Oct 2015 14:40:09 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 1 Oct 2015 14:40:09 +0000 (UTC) Cc: help-gnu-emacs , Dmitry Gutov To: Andreas =?utf-8?Q?R=C3=B6hler?= Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Oct 01 16:40:01 2015 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Zhf1a-0005Dq-Ra for geh-help-gnu-emacs@m.gmane.org; Thu, 01 Oct 2015 16:39:58 +0200 Original-Received: from localhost ([::1]:51039 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zhf1a-0006Lp-6c for geh-help-gnu-emacs@m.gmane.org; Thu, 01 Oct 2015 10:39:58 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37718) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZhaBK-0003S2-6A for help-gnu-emacs@gnu.org; Thu, 01 Oct 2015 05:29:43 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZhaBG-00017j-00 for help-gnu-emacs@gnu.org; Thu, 01 Oct 2015 05:29:42 -0400 Original-Received: from deliver.uni-koblenz.de ([141.26.64.15]:57097) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZhaBF-00017E-Mu for help-gnu-emacs@gnu.org; Thu, 01 Oct 2015 05:29:37 -0400 Original-Received: from thinkpad-t440p (dhcp145.uni-koblenz.de [141.26.71.145]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by deliver.uni-koblenz.de (Postfix) with ESMTPSA id CC40A1A8353; Thu, 1 Oct 2015 11:29:36 +0200 (CEST) Mail-Followup-To: Andreas =?utf-8?Q?R=C3=B6hler?= , Dmitry Gutov , help-gnu-emacs In-Reply-To: <560CF2F2.1060601@easy-emacs.de> ("Andreas \=\?utf-8\?Q\?R\=C3\=B6h\?\= \=\?utf-8\?Q\?ler\=22's\?\= message of "Thu, 01 Oct 2015 10:46:42 +0200") User-Agent: Gnus/5.130014 (Ma Gnus v0.14) Emacs/25.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 141.26.64.15 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:107418 Archived-At: Andreas R=C3=B6hler writes: >>>>> Docu bug? >>>> It's a feature: calling `looking-back' without LIMIT is slow, don't do= that. >>> Hmm, would volontier to make that fast instead - if write-permission >>> is given :) >> Looking at the code, I'd say `looking-back' is only slow if GREEDY is t >> in which case the start of the match may be before LIMIT anyhow. So I >> don't see how providing a LIMIT would help too much, or is >> `re-search-backward' already slow without LIMIT? > > AFAIK thats it. > > Also "greedy" seems not to work at all: > > (defun foo3 ()) > > (progn (re-search-backward "o+" nil t 3) > (message "%s" (match-beginning 0))) > > The first "o" is reported as match-beginning. Is it intended that you don't use `looking-back' here? But you are right that in the situation above, a string like "foo3" should account for only one single match because the greedy regex "o+" is allowed to consume any number of consecutive os. But that doesn't seem to work for backward searches, and that's probably the cause for the weird extension mechanism in the greedy case for `looking-back'. Well, it works fine with forward searches: (progn (re-search-forward "fo+?" nil t) ;non-greedy ;; (re-search-forward "fo+" nil t) ;greedy (message "%s %s" (match-beginning 0) (match-end 0))) (defun fooooo4 ()) ^ ^ ^ | | `--- end: greedy | `------- end: non-greedy `--------- beginning Bye, Tassilo