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: I'd like to marry while and mapcar... Date: Fri, 06 Feb 2015 13:56:48 +0100 Message-ID: <87vbjfdwq7.fsf@wmi.amu.edu.pl> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1423227441 11674 80.91.229.3 (6 Feb 2015 12:57:21 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 6 Feb 2015 12:57:21 +0000 (UTC) To: Help Gnu Emacs mailing list Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Feb 06 13:57:17 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 1YJiTF-0000t2-BU for geh-help-gnu-emacs@m.gmane.org; Fri, 06 Feb 2015 13:57:17 +0100 Original-Received: from localhost ([::1]:48000 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YJiTE-0007US-VS for geh-help-gnu-emacs@m.gmane.org; Fri, 06 Feb 2015 07:57:16 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46306) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YJiT0-0007U6-F4 for help-gnu-emacs@gnu.org; Fri, 06 Feb 2015 07:57:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YJiSw-0004eo-Dk for help-gnu-emacs@gnu.org; Fri, 06 Feb 2015 07:57:02 -0500 Original-Received: from msg.wmi.amu.edu.pl ([2001:808:114:2::50]:41161) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YJiSw-0004e7-6d for help-gnu-emacs@gnu.org; Fri, 06 Feb 2015 07:56:58 -0500 Original-Received: from localhost (localhost [127.0.0.1]) by msg.wmi.amu.edu.pl (Postfix) with ESMTP id 11C014D730 for ; Fri, 6 Feb 2015 13:56:56 +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 Ju99O0ax8488 for ; Fri, 6 Feb 2015 13:56:55 +0100 (CET) Original-Received: from localhost (117-116.echostar.pl [213.156.117.116]) by msg.wmi.amu.edu.pl (Postfix) with ESMTPSA id C31A64D72F for ; Fri, 6 Feb 2015 13:56:55 +0100 (CET) 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:102529 Archived-At: Hello Emacsers and Elispers! What I'd need is kind of a marriage of while and mapcar: I'd like to run 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 past 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) This, however, looks a bit, let's say, Fortran-ish;-); I'm after a more Lispy way. (Of course, one step would be to use anaphoric while, but that doesn't help my main problem of ditching list-of-includes.) Yes, I know, I have too much time on my hands, and I bother about style. But I'm also curious whether there is any "standard" way, or whether I should indeed wrap something like the above code in a macro, or something. (Or maybe just don't care...) TIA, -- Marcin Borkowski This email was proudly sent http://mbork.pl from my Emacs.