bugfix: yas/recompile-directory-maybe messed up sometimes

This commit is contained in:
João Távora 2012-07-02 01:27:44 +01:00
parent 209cf81f04
commit 4713bba467

View File

@ -1684,8 +1684,10 @@ Optional USE-JIT use jit-loading of snippets."
(secure-hash 'md5 (mapconcat #'(lambda (c) (format "%s%f" (car c) (float-time (cdr c)))) files-and-mtimes " "))) (secure-hash 'md5 (mapconcat #'(lambda (c) (format "%s%f" (car c) (float-time (cdr c)))) files-and-mtimes " ")))
(defun yas/recompile-directory-maybe (directory mode-sym) (defun yas/recompile-directory-maybe (directory mode-sym)
(flet ((recompile () (yas/with-compilation-flets (flet ((recompile ()
(yas/load-directory-2 directory mode-sym))) (yas/with-compilation-flets
(yas/compile-directory-1 directory mode-sym))
(yas/message 2 ".yas-compiled-snippet.el out of date. Recompiling %s" directory))
(most-recent-mtime (mtimes) (reduce #'(lambda (t1 t2) (most-recent-mtime (mtimes) (reduce #'(lambda (t1 t2)
(if (time-less-p t1 t2) t2 t1)) (if (time-less-p t1 t2) t2 t1))
mtimes))) mtimes)))
@ -1700,18 +1702,19 @@ Optional USE-JIT use jit-loading of snippets."
((null compiled) ((null compiled)
(recompile)) (recompile))
((let* ((files-and-mtimes (yas/compile-snippet-files-and-mtimes directory))) ((let* ((files-and-mtimes (yas/compile-snippet-files-and-mtimes directory)))
(or (time-less-p (nth 5 (file-attributes compiled)) (and files-and-mtimes
(most-recent-mtime (mapcar #'cdr files-and-mtimes))) (or (time-less-p (nth 5 (file-attributes compiled))
(not (string= (yas/compile-calculate-md5 files-and-mtimes) (most-recent-mtime (mapcar #'cdr files-and-mtimes)))
(with-temp-buffer (not (string= (yas/compile-calculate-md5 files-and-mtimes)
(insert-file-contents compiled) (with-temp-buffer
(when (search-forward-regexp "md5:[[:space:]]\\(.*\\)" nil 'noerror) (insert-file-contents compiled)
(match-string 1))))))) (when (search-forward-regexp "md5:[[:space:]]\\(.*\\)" nil 'noerror)
(match-string 1))))))))
(recompile)) (recompile))
(t ; do not recompile (t ; do not recompile
)) ))
(when (and compiled (when (and compiled
(load (file-name-sans-extension compiled) 'noerror (<= yas/verbosity 2))) (load (expand-file-name (file-name-sans-extension compiled)) 'noerror (<= yas/verbosity 2)))
(yas/message 2 "Loading much faster .yas-compiled-snippets from %s" directory) (yas/message 2 "Loading much faster .yas-compiled-snippets from %s" directory)
t)))) t))))