Subject: update-directory-autoloads and MD5 checksums

From: Sheda <[email-masked]>
Date: Sun, 8 Mar 2015 23:33:12 +0100

Hi,

It seems that autoload.el's update-directory-autoloads fails when
instead of a time struct, an MD5 checksum is found in (nth 4 form).
Attached are both the .loaddefs.el that made me fall onto what looks
like a bug (the file was generated by el-get AFAIK) and a patch that
partially fix the problem (at least for me ;).

The following discussion helped me narrow down the problem:
  https://github.com/dimitri/el-get/issues/1352

Feedbacks of all kinds welcome.

Regards,

Sheda
--- autoload.el.orig	2015-03-08 23:10:06.623228668 +0100
+++ autoload.el	2015-03-08 23:23:24.203961615 +0100
@@ -713,6 +713,17 @@
   (search-forward generate-autoload-section-trailer)
   (delete-region begin (point)))
 
+(defun was-file-modified (md5-or-mtime file) 
+	(if (stringp md5-or-mtime)
+			; md5-or-mtime is an MD5 checksum.
+			(let ((last-md5 md5-or-mtime)
+						(file-md5 (md5 file))) 
+				(string= last-md5 file-md5))
+		; md5-or-mtime is a time structure.
+		(let ((last-time md5-or-mtime) 
+					(file-time (nth 5 (file-attriutes file)))) 
+			(not (time-less-p last-time file-time)))))
+
 ;;;###autoload
 (defun update-directory-autoloads (&rest dirs)
   "Update autoload definitions for Lisp files in the directories DIRS.
@@ -781,8 +792,7 @@
                        (member (expand-file-name file) autoload-excludes))
                    ;; Remove the obsolete section.
 		   (autoload-remove-section (match-beginning 0)))
-		  ((not (time-less-p (nth 4 form)
-                                     (nth 5 (file-attributes file))))
+		  ((was-file-modified (nth 4 form) file)
 		   ;; File hasn't changed.
 		   nil)
 		  (t