From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Rasmus Newsgroups: gmane.emacs.help Subject: Re: I'd like to marry while and mapcar... Date: Fri, 06 Feb 2015 14:18:19 +0100 Message-ID: <87lhkbdvqc.fsf@gmx.us> References: <87vbjfdwq7.fsf@wmi.amu.edu.pl> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1423228736 2536 80.91.229.3 (6 Feb 2015 13:18:56 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 6 Feb 2015 13:18:56 +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:18:52 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 1YJio6-0006V7-DK for geh-help-gnu-emacs@m.gmane.org; Fri, 06 Feb 2015 14:18:50 +0100 Original-Received: from localhost ([::1]:48231 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YJio5-00044z-L1 for geh-help-gnu-emacs@m.gmane.org; Fri, 06 Feb 2015 08:18:49 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51340) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YJinr-00044j-G3 for help-gnu-emacs@gnu.org; Fri, 06 Feb 2015 08:18:36 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YJinm-000454-9b for help-gnu-emacs@gnu.org; Fri, 06 Feb 2015 08:18:35 -0500 Original-Received: from plane.gmane.org ([80.91.229.3]:37818) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YJinm-00044m-3K for help-gnu-emacs@gnu.org; Fri, 06 Feb 2015 08:18:30 -0500 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1YJinh-0006Es-7f for help-gnu-emacs@gnu.org; Fri, 06 Feb 2015 14:18:25 +0100 Original-Received: from tsn109-201-154-162.dyn.nltelcom.net ([109.201.154.162]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 06 Feb 2015 14:18:25 +0100 Original-Received: from rasmus by tsn109-201-154-162.dyn.nltelcom.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 06 Feb 2015 14:18:25 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 30 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: tsn109-201-154-162.dyn.nltelcom.net Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAAAAAByaaZbAAAAAmJLR0QA/4ePzL8AAAAJcEhZ cwAAAEgAAABIAEbJaz4AAAE1SURBVEgN1cHBYcIwEADBrehquUrUiypRJdfRPiISGwzImG9m+A+i l3+Sa+lULYjM0s4FHcFDaOeDbvEiNTgz7LzTwVrZWSmLFe2slcU7bZzpdl6VDTCZglfN5Fm3Aw4m 5U0zeKJAl0lZGHJUMimTgxXlwMYU3NhYSXlIuWZw56AZLKX8qeJOuo21UH6l3MkwOKPBjcEmhJIT TeXGziaEkBOKnWkUmxAoWVI2KZswAA3eNItdyM5kKk2eNE0eZGfjVzmNljFlVxtHsrOxiV7lZvBC dna+IbuSb8gu5AshdzaujeIu5ZrJg4NLcmRwwcFRGHwU8mzIRyYvSj5Q3pScUhZKTihLysowOTEs Xg3lAzV5SJULXUcyRXMK2hhlOVVPbqJlyzGV5ejNgxqjZQTnYiL4V34ArFoDSH8mOYQAAAAASUVO RK5CYII= User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) Cancel-Lock: sha1:lvfJA7VIWdb04B+Q6mg4bvZluZw= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 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:102530 Archived-At: Marcin Borkowski writes: > 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) How about: (cl-loop while (search-forward-regexp "^[ \t]*\\\\include{\\([^}]+\\)}[ \t]*$" nil t) collect (match-string 1)) –Rasmus -- It was you, Jezebel, it was you