From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Romain Francoise Newsgroups: gmane.emacs.devel Subject: Re: Proposal for battery.el Date: Sat, 04 Nov 2006 19:23:31 +0100 Organization: orebokech dot com Message-ID: <87k62b9il8.fsf@pacem.orebokech.com> References: <87lkmwpjjn.fsf@lrde.org> <87u01hy0bk.fsf@lrde.org> <877iybm7ni.fsf@lrde.org> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: sea.gmane.org 1162664632 32218 80.91.229.2 (4 Nov 2006 18:23:52 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 4 Nov 2006 18:23:52 +0000 (UTC) Cc: rms@gnu.org, emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Nov 04 19:23:43 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1GgQBC-0008Gx-6O for ged-emacs-devel@m.gmane.org; Sat, 04 Nov 2006 19:23:42 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GgQBB-0007o5-G3 for ged-emacs-devel@m.gmane.org; Sat, 04 Nov 2006 13:23:41 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GgQB0-0007lE-9d for emacs-devel@gnu.org; Sat, 04 Nov 2006 13:23:30 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GgQAy-0007j9-RD for emacs-devel@gnu.org; Sat, 04 Nov 2006 13:23:30 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GgQAy-0007iv-Mn for emacs-devel@gnu.org; Sat, 04 Nov 2006 13:23:28 -0500 Original-Received: from [82.67.41.165] (helo=yeast.orebokech.com) by monty-python.gnu.org with esmtp (Exim 4.52) id 1GgQAx-00030G-1G; Sat, 04 Nov 2006 13:23:27 -0500 Original-Received: from pacem.orebokech.com (pacem.orebokech.com [192.168.1.3]) by yeast.orebokech.com (Postfix) with ESMTP id EC3E012D1A; Sat, 4 Nov 2006 19:23:25 +0100 (CET) Original-Received: by pacem.orebokech.com (Postfix, from userid 1000) id 20F6D52450; Sat, 4 Nov 2006 19:23:31 +0100 (CET) Original-To: michael@cadilhac.name (=?iso-8859-1?Q?Micha=EBl?= Cadilhac) X-Face: }9mYu,e_@+e!`Z-P5kVXa3\_b:hdJ"B)ww[&=b<2=awG:GOIM (=?iso-8859-1?Q?Micha=EBl?= Cadilhac's message of "Sat\, 04 Nov 2006 18\:41\:21 +0100") 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:61789 Archived-At: michael@cadilhac.name (Micha=EBl Cadilhac) writes: + (defun battery-search-for-one-match-in-files (files regexp match-num) + "Search REGEXP in content of the files listed in FILES. + If a match occured, return the parenthesized expression numbered by + MATCH-NUM in the match. Otherwise, return nil." + (with-temp-buffer + (while (and files + (not (or (ignore-errors + (insert-file-contents (car files)) + (re-search-forward regexp)) + (erase-buffer)))) + (setq files (cdr files))) + (when files + (match-string match-num)))) How about the following instead? Since battery.el requires cl at compilation time, you can safely use `dolist'... (defun battery-search-for-one-match-in-files (files regexp match-num) "Search REGEXP in content of the files listed in FILES. If a match occured, return the parenthesized expression numbered by MATCH-NUM in the match. Otherwise, return nil." (catch 'found (dolist (file files) (with-temp-buffer (insert-file-contents file) (when (re-search-forward regexp nil t) (throw 'found (match-string match-num))))))) --=20 Romain Francoise | The sea! the sea! the open it's a miracle -- http://orebokech.com/ | sea! The blue, the fresh, the | ever free! --Bryan W. Procter