forked from technomancy/emacs-starter-kit
-
Notifications
You must be signed in to change notification settings - Fork 3
/
initializers.el
34 lines (28 loc) · 1.39 KB
/
initializers.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
(add-to-list 'load-path (concat user-emacs-directory "vendor"))
(defun ini-mtime (filename)
"Return the mtime of the specified filename, following symlinks as appropriate"
(let* ((attributes (file-attributes filename))
(mtime (nth 5 attributes))
(symlink-dest (nth 0 attributes)))
(if symlink-dest
(ini-mtime (concat (file-name-directory filename) symlink-dest))
(+ (* (car mtime) 65536) (cadr mtime)))))
(defun ini-pick-latest-version (filename)
"Given a .el file, compare the mtime of the corresponding .elc file, following symlinks to get the mtime
If the .elc file is out-dated, delete it"
(let ((elc-filename (concat filename "c")))
(if (file-readable-p elc-filename)
(if (> (ini-mtime filename) (ini-mtime elc-filename))
(progn (message "Detected that %S is newer than %S. Deleting %S" filename elc-filename elc-filename)
(delete-file elc-filename)
filename)
elc-filename)
filename)))
(defun ini-load (filename)
(load-file (ini-pick-latest-version filename)))
(defun ini-load-all ()
;;; load all the files in the initializers.enabled/ directory
(let* ((ini-directory (concat user-emacs-directory "initializers.enabled/"))
(files (sort (directory-files ini-directory nil "^.*\\.el$") 'string<)))
(dolist (file files)
(ini-load (concat ini-directory file)))))