Skip to content

Instantly share code, notes, and snippets.

@pkkm
Last active December 14, 2015 10:29
Show Gist options
  • Save pkkm/5072706 to your computer and use it in GitHub Desktop.
Save pkkm/5072706 to your computer and use it in GitHub Desktop.
Recursively load all Elisp files in a directory.
(defun load-recursively (dir-to-load &optional exclude-list)
"Load all .el files in DIR-TO-LOAD and its subdirectories (and their subdirectories, ...).
Exclude files (or directories) that are in EXCLUDE-LIST."
(let ((excluded-file-names (append exclude-list '("." ".."))))
(dolist (file (directory-files dir-to-load 'absolute-file-names))
(unless (member (file-relative-name file dir-to-load) excluded-file-names)
(cond
((file-directory-p file) (load-recursively file exclude-list))
((string= (file-name-extension file) "el") (load file)))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment