[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: I'd like to marry while and mapcar...

From: Marcin Borkowski
Subject: Re: I'd like to marry while and mapcar...
Date: Fri, 06 Feb 2015 14:53:20 +0100

On 2015-02-06, at 14:18, Rasmus <address@hidden> wrote:

> Marcin Borkowski <address@hidden> 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

Thanks, this is a nice idea, even though some might tsk-tsk the use of


Marcin Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University

reply via email to

[Prev in Thread] Current Thread [Next in Thread]