Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 32 lines (26 sloc) 1.313 kb
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
(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)))

;;; load all the files in the initializers.enabled/ directory
(let* ((ini-directory (concat dotfiles-dir "initializers.enabled/"))
       (files (sort (directory-files ini-directory nil "^.*\\.el$") 'string<)))
  (dolist (file files)
    (ini-load (concat ini-directory file))))

Something went wrong with that request. Please try again.