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

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

Re: iterating over a list while removing elements


From: Michael Albinus
Subject: Re: iterating over a list while removing elements
Date: Wed, 19 Mar 2014 14:11:31 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

lee <address@hidden> 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.



reply via email to

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