From: Michael Albinus <michael.albinus@gmx.de>
To: help-gnu-emacs@gnu.org
Subject: Re: iterating over a list while removing elements
Date: Wed, 19 Mar 2014 14:11:31 +0100 [thread overview]
Message-ID: <87zjkmuyd8.fsf@gmx.de> (raw)
In-Reply-To: <87mwgmwh6o.fsf@yun.yagibdah.de> (lee@yun.yagibdah.de's message of "Wed, 19 Mar 2014 12:39:43 +0100")
lee <lee@yun.yagibdah.de> 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.
next prev parent reply other threads:[~2014-03-19 13:11 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-19 11:39 iterating over a list while removing elements lee
2014-03-19 12:39 ` Stefan
2014-03-20 16:02 ` lee
2014-03-19 13:11 ` Michael Albinus [this message]
2014-03-20 16:10 ` lee
[not found] <mailman.17526.1395229207.10748.help-gnu-emacs@gnu.org>
2014-03-19 13:12 ` Pascal J. Bourguignon
2014-03-19 18:28 ` Joost Kremers
2014-03-20 17:34 ` lee
2014-03-20 20:16 ` Eli Zaretskii
2014-03-21 5:25 ` lee
2014-03-20 16:33 ` lee
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87zjkmuyd8.fsf@gmx.de \
--to=michael.albinus@gmx.de \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.