From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Marcin Borkowski Newsgroups: gmane.emacs.help Subject: Re: I'd like to marry while and mapcar... Date: Fri, 06 Feb 2015 14:53:20 +0100 Message-ID: <8761bf9men.fsf@wmi.amu.edu.pl> References: <87vbjfdwq7.fsf@wmi.amu.edu.pl> <87lhkbdvqc.fsf@gmx.us> 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 1423230829 6814 80.91.229.3 (6 Feb 2015 13:53:49 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 6 Feb 2015 13:53:49 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Feb 06 14:53:45 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 1YJjLr-0000wl-5K for geh-help-gnu-emacs@m.gmane.org; Fri, 06 Feb 2015 14:53:43 +0100 Original-Received: from localhost ([::1]:48383 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YJjLq-00030j-He for geh-help-gnu-emacs@m.gmane.org; Fri, 06 Feb 2015 08:53:42 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59397) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YJjLf-00030Y-3k for help-gnu-emacs@gnu.org; Fri, 06 Feb 2015 08:53:32 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YJjLX-00078s-Kh for help-gnu-emacs@gnu.org; Fri, 06 Feb 2015 08:53:31 -0500 Original-Received: from msg.wmi.amu.edu.pl ([2001:808:114:2::50]:43413) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YJjLX-00078g-Eb for help-gnu-emacs@gnu.org; Fri, 06 Feb 2015 08:53:23 -0500 Original-Received: from localhost (localhost [127.0.0.1]) by msg.wmi.amu.edu.pl (Postfix) with ESMTP id D470D4D72F for ; Fri, 6 Feb 2015 14:53:22 +0100 (CET) Original-Received: from msg.wmi.amu.edu.pl ([127.0.0.1]) by localhost (msg.wmi.amu.edu.pl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id PRNnFcGGM8Qe for ; Fri, 6 Feb 2015 14:53:22 +0100 (CET) Original-Received: from localhost (117-116.echostar.pl [213.156.117.116]) by msg.wmi.amu.edu.pl (Postfix) with ESMTPSA id 857494D721 for ; Fri, 6 Feb 2015 14:53:22 +0100 (CET) In-reply-to: <87lhkbdvqc.fsf@gmx.us> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:808:114:2::50 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:102534 Archived-At: On 2015-02-06, at 14:18, Rasmus wrote: > Marcin Borkowski writes: > >> Hello Emacsers and Elispers! >> >> What I'd need is kind of a marriage of while and mapcar: I'd like to r= un >> some function until it returns nil and make a list of all results it >> gives back until then. >> >> Mu use case is that I'm getting some info from a LaTeX file. For >> instance, assume that I want to make a list of all files \include'd by >> a LaTeX document. I've written a function `get-TeX-macro-arguments' >> which finds the next occurence of a given TeX command, moves point pas= t >> it and returns its arguments; if it does not find any such occurrence, >> it returns nil. So I can say something like this: >> >> (let (current-include (list-of-includes ())) >> (while (setq current-include (get-TeX-macro-arguments "include")) >> (setq list-of-includes (append list-of-includes current-include))) >> list-of-includes) > > How about: > > (cl-loop while (search-forward-regexp > "^[ \t]*\\\\include{\\([^}]+\\)}[ \t]*$" nil t) > collect (match-string 1)) > > =E2=80=93Rasmus Thanks, this is a nice idea, even though some might tsk-tsk the use of cl-loop. Best, --=20 Marcin Borkowski http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski Faculty of Mathematics and Computer Science Adam Mickiewicz University