[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Choose whether to load *.el or *.elc by modification time.
From: |
Davin Pearson |
Subject: |
Choose whether to load *.el or *.elc by modification time. |
Date: |
Mon, 20 Jun 2016 00:10:35 -0700 (PDT) |
User-agent: |
G2/1.0 |
The following hack uses the time of last modification to
choose which of *.el or *.elc to load, choosing the most
recently edited file, which is probably what the user wants.
(defadvice load-file (around dlisp activate)
(when (string-match "\\.\\(el\\|elc\\)$" file)
(setq name-sans-extension (substring file 0 (match-beginning 0)))
(setq name-plus-el (concat name-sans-extension ".el" ))
(setq name-plus-elc (concat name-sans-extension ".elc"))
(setq date-el (nth 5 (file-attributes name-plus-el )))
(setq date-elc (nth 5 (file-attributes name-plus-elc)))
(setq time-el (+ (* 65536.0 (or (car date-el ) 1)) (or (cadr date-el ) 0)))
(setq time-elc (+ (* 65536.0 (or (car date-elc) 1)) (or (cadr date-elc) 0)))
(if (> time-el time-elc)
(progn
(message "loaded file=%s" name-plus-el)
(setq file name-plus-el)
ad-do-it)
(message "loaded file=%s" name-plus-elc)
(setq file name-plus-elc)
ad-do-it)))
- Choose whether to load *.el or *.elc by modification time.,
Davin Pearson <=