Created
April 22, 2012 22:19
-
-
Save haxney/2467266 to your computer and use it in GitHub Desktop.
Simple way to find files recursively and evaluate a body there
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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