help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: List of buffers under version control?


From: Rolf Ade
Subject: Re: List of buffers under version control?
Date: Thu, 28 Jul 2016 23:52:24 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

John Mastro <address@hidden> writes:
> Rolf Ade <address@hidden> wrote:
>>
>> (loop for buffer in (buffer-list)
>>       until (if (vc-backend (buffer-file-name buffer))
>>                 (buffer-modified-p buffer))
>>       finally return (if (and (buffer-modified-p buffer)
>>                               (vc-backend (buffer-file-name buffer)))
>>                          1
>>                        0))
>>
>
> Glad it helps. You could do something like this to avoid repeating the
> calls to `vc-backend' and `buffer-modified-p':
>
> (if (loop for buffer in (buffer-list)
>           thereis (and (vc-backend (buffer-file-name buffer))
>                        (buffer-modified-p buffer)))
>     1
>   0)

It's probably not so much about avoiding unnecessary calls (my version
does only 1 call of vc-backend and 1 call of buffer-modified-p more than
yours, no matter how long the buffer-list is (mine currently is 385)).

Your version is not only lesser code but also more to the point written
and better to understand. Thanks again.

(And learned about thereis. And tooked the opportunity, to refresh my
understanding of (the capabilities of) loop.)


reply via email to

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