From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Kastrup Newsgroups: gmane.emacs.devel Subject: Re: What is the difference between looking-at and an anchored search? Date: Thu, 17 Jul 2008 14:33:33 +0200 Message-ID: <86vdz43d2a.fsf@lola.quinscape.zz> References: <487F2985.9080103@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1216298072 7898 80.91.229.12 (17 Jul 2008 12:34:32 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 17 Jul 2008 12:34:32 +0000 (UTC) Cc: "Lennart Borgman \(gmail\)" , Emacs Devel To: Miles Bader Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jul 17 14:35:20 2008 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 1KJShY-0001LH-NY for ged-emacs-devel@m.gmane.org; Thu, 17 Jul 2008 14:35:16 +0200 Original-Received: from localhost ([127.0.0.1]:58479 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KJSgf-00058O-Tr for ged-emacs-devel@m.gmane.org; Thu, 17 Jul 2008 08:34:21 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KJSg0-0004O3-I8 for emacs-devel@gnu.org; Thu, 17 Jul 2008 08:33:40 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KJSfy-0004Ku-M8 for emacs-devel@gnu.org; Thu, 17 Jul 2008 08:33:39 -0400 Original-Received: from [199.232.76.173] (port=42009 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KJSfy-0004JN-GZ for emacs-devel@gnu.org; Thu, 17 Jul 2008 08:33:38 -0400 Original-Received: from mail.quinscape.de ([212.29.44.217]:46881) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KJSfv-0002hA-Jy for emacs-devel@gnu.org; Thu, 17 Jul 2008 08:33:36 -0400 Original-Received: (qmail-ldap/ctrl 20757 invoked from network); 17 Jul 2008 12:33:33 -0000 Original-Received: from unknown (HELO lola.quinscape.zz) ([10.0.3.43]) (envelope-sender ) by quinx.quinscape.de (qmail-ldap-1.03) with SMTP for ; 17 Jul 2008 12:33:33 -0000 Original-Received: by lola.quinscape.zz (Postfix, from userid 1001) id C35538F047; Thu, 17 Jul 2008 14:33:33 +0200 (CEST) In-Reply-To: (Miles Bader's message of "Thu, 17 Jul 2008 21:17:49 +0900") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) X-AntiVirus: checked by AntiVir MailGate (version: 2.1.3-2; AVE: 7.8.0.68; VDF: 7.0.5.132; host: quinx) X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 3) 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:100882 Archived-At: Miles Bader writes: > "Lennart Borgman (gmail)" writes: >> looking-at does not have a BOUND parameter, but re-search-forward >> have. This makes re-search-forward a bit more flexible. >> >> I am looking at some code where I would have use for that flexibility, >> but I wonder if there is any drawback with replacing looking-at with >> re-search-forward (with an achored pattern). >> >> Is there any? Performance? > > If you want to reject matches that extend past some point, just do > something like: > > (and (looking-at REGEXP) (<= (match-end 0) BOUND)) That is not the same. (with-temp-buffer (insert "abc") (goto-char 1) (list (re-search-forward ".*" 2) (progn (goto-char 1) (and (looking-at ".*") (<= (match-end 0) 2))))) => (2 nil) -- David Kastrup