From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Michael Albinus Newsgroups: gmane.emacs.help Subject: Re: iterating over a list while removing elements Date: Wed, 19 Mar 2014 14:11:31 +0100 Message-ID: <87zjkmuyd8.fsf@gmx.de> References: <87mwgmwh6o.fsf@yun.yagibdah.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1395234717 2920 80.91.229.3 (19 Mar 2014 13:11:57 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 19 Mar 2014 13:11:57 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Mar 19 14:12:05 2014 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 1WQGHo-0002iJ-HN for geh-help-gnu-emacs@m.gmane.org; Wed, 19 Mar 2014 14:12:01 +0100 Original-Received: from localhost ([::1]:41134 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQGHo-0008KL-25 for geh-help-gnu-emacs@m.gmane.org; Wed, 19 Mar 2014 09:12:00 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38703) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQGHX-0008K5-Ne for help-gnu-emacs@gnu.org; Wed, 19 Mar 2014 09:11:49 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WQGHR-0003Ri-Ib for help-gnu-emacs@gnu.org; Wed, 19 Mar 2014 09:11:43 -0400 Original-Received: from mout.gmx.net ([212.227.15.15]:50592) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQGHR-0003Qi-9p for help-gnu-emacs@gnu.org; Wed, 19 Mar 2014 09:11:37 -0400 Original-Received: from detlef.gmx.de ([87.146.36.208]) by mail.gmx.com (mrgmx002) with ESMTPS (Nemesis) id 0MhAAr-1Wm2IJ3Bwn-00MKuH for ; Wed, 19 Mar 2014 14:11:35 +0100 In-Reply-To: <87mwgmwh6o.fsf@yun.yagibdah.de> (lee@yun.yagibdah.de's message of "Wed, 19 Mar 2014 12:39:43 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-Provags-ID: V03:K0:AFaDtqAvykpUKzKJIulBjKL+vaQoWgSSRN3z1lCaSOct66MnuKx eI6tor8DtVCaPRCV+mfa8JjqRksSqXU8rfoo1ol2WU7+Jf3H5mlS8d9he6gF5Z3ij98BSrX 6PFQ8rmewGDq/uZMrEUbxFPYgZIxcWb9HC1gY4iJnw1awBv2cIpnRMSPCLxAYSiXxUaErho YYi1MIeFKzOPyfFgP0iNw== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 212.227.15.15 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:96629 Archived-At: lee writes: > Hi, Hi, > what is the defined behaviour when you iterate over a list and remove > elements from that very list? For example: > > > (defsubst multisearch-directory-ref-p (dots) > "Return t when the string DOTS ends in a directory reference." > (or > (string-match "\\.$" dots) > (string-match "\\.\\.$" dots))) > > (defun multisearch-make-files-list (directory) > "Return a list of files in DIRECTORY, with directory references > and directories removed." > (let ((files-list (directory-files directory t))) > (dolist (entry files-list files-list) > (unless (and > (not (multisearch-directory-ref-p entry)) > (file-directory-p entry) > (file-readable-p entry)) > (setq files-list (delete entry files-list)))))) Side remark: You don't need `multisearch-directory-ref-p' when applying (let ((files-list (directory-files directory t directory-files-no-dot-files-regexp))) Best regards, Michael.