all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* iterating over a list while removing elements
@ 2014-03-19 11:39 lee
  2014-03-19 12:39 ` Stefan
  2014-03-19 13:11 ` Michael Albinus
  0 siblings, 2 replies; 11+ messages in thread
From: lee @ 2014-03-19 11:39 UTC (permalink / raw)
  To: help-gnu-emacs

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))))))


Surprisingly, this /appears/ to work.  Can I take that for granted, or
is this a stupid thing to do?  It`s like someone pulling the chair
you`re about to sit on from underneath you ...


-- 
Knowledge is volatile and fluid.  Software is power.



^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2014-03-21  5:25 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.17526.1395229207.10748.help-gnu-emacs@gnu.org>
2014-03-19 13:12 ` iterating over a list while removing elements 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
2014-03-19 11:39 lee
2014-03-19 12:39 ` Stefan
2014-03-20 16:02   ` lee
2014-03-19 13:11 ` Michael Albinus
2014-03-20 16:10   ` lee

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.