Skip to content

Instantly share code, notes, and snippets.

@haxney
Created April 22, 2012 22:19
Show Gist options
  • Save haxney/2467266 to your computer and use it in GitHub Desktop.
Save haxney/2467266 to your computer and use it in GitHub Desktop.
Simple way to find files recursively and evaluate a body there
(defmacro go-files (base-dir &rest body)
"Recursively open files, visiting each one and running BODY there."
`(recursive-files ,base-dir '(progn ,@body)))
(defun recursive-files (dir form)
(loop
for (file is-dir) in (directory-files-and-attributes
dir
t
;; Ignore "." and ".." directories, but is too aggressive
"^[^.]+$")
if is-dir
do (recursive-files file form)
else
do (with-current-buffer (find-file-noselect file)
(eval form))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment