From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Rolf Ade Newsgroups: gmane.emacs.help Subject: Re: List of buffers under version control? Date: Thu, 28 Jul 2016 23:52:24 +0200 Organization: Me Message-ID: <87d1lxv3af.fsf@linux-qg7d.fritz.box> References: <877fc6wrv7.fsf@linux-qg7d.fritz.box> <006fed39-43f3-40aa-a72b-c736ba9bf86c@googlegroups.com> <87shutv9tr.fsf@linux-qg7d.fritz.box> <87k2g5v5nk.fsf@linux-qg7d.fritz.box> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1469743010 4061 80.91.229.3 (28 Jul 2016 21:56:50 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 28 Jul 2016 21:56:50 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Jul 28 23:56:50 2016 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 1bStIP-0002JY-Ac for geh-help-gnu-emacs@m.gmane.org; Thu, 28 Jul 2016 23:56:49 +0200 Original-Received: from localhost ([::1]:55904 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bStIJ-0001mL-9V for geh-help-gnu-emacs@m.gmane.org; Thu, 28 Jul 2016 17:56:43 -0400 Original-Path: usenet.stanford.edu!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 31 Original-X-Trace: individual.net OOMAQHyIaQUBTMK6uR9hCQUUX2EznW5edPDwrV+vZ3pJJ5mZQ= Cancel-Lock: sha1:c6lnHRp8vZLVdA68PmMcrAXyDHM= sha1:N9wZiFPc8FXO7Ob1yQeGuj/LX34= User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) Original-Xref: usenet.stanford.edu gnu.emacs.help:218677 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 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" Xref: news.gmane.org gmane.emacs.help:110988 Archived-At: John Mastro writes: > Rolf Ade 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.)