Created
March 24, 2016 03:30
-
-
Save xeechou/7e9aed2245c2c08b77ea to your computer and use it in GitHub Desktop.
simple load-dir in elisp
This file contains hidden or 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
| ;; 2016-3-23, the simple but good enough load-dir function. | |
| ;; I won't run into the argument error anymore | |
| (provide 'load-dir) | |
| (defun load-dir (dir) | |
| "load-lisp files from a directory" | |
| (interactive) | |
| (let* ((expanded-dir (expand-file-name (substitute-in-file-name dir))) | |
| (files (directory-files expanded-dir))) | |
| (message "load-dir: files are %s" files) | |
| (while files | |
| (let* ((file (car files)) | |
| (abs-file (concat expanded-dir "/" file))) | |
| (if (string-match "\.elc?$" file) ;;it is a lisp file | |
| ;; don't load file if elc exists | |
| (prog2 | |
| (if (file-exists-p (concat abs-file "c")) | |
| ()) | |
| (load-file abs-file) | |
| ) | |
| ) | |
| ) | |
| (setq files (cdr files))) | |
| ) | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment