[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: Rasmus
Subject: Re: I'd like to marry while and mapcar...
Date: Fri, 06 Feb 2015 14:18:19 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

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))


It was you, Jezebel, it was you

reply via email to

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