Subject: Re: bug#5162: 23.1.90; display-time broken in non-X build

From: Stefan Monnier <[email-masked]>
Date: Thu, 10 Dec 2009 02:58:36 -0500

>>> The with and without-x loaddefs.el files are no longer identical.
>> Then we need to detect this situation somehow and cause loaddefs.el to
>> be updated correspondingly.
> The only idea I had was to regenerate loaddefs from scratch whenever
> src/config.h changes.

I think the way to make it work is to let autoload.el store the
autoload-excludes in the loaddefs.el file (as a special comment,
similar to the special comment listing the files that had no autoload
cookies).
Then autoload can compare the old list with the new one and force scan
any new unexcluded file, even if it's older than the timestamp.

Tho, maybe just not storing the auto-excludes in the "no-autoloads"
section might be enough to do the trick.  E.g. the patch below seems to
do the trick for me,

        Stefan

=== modified file 'lisp/emacs-lisp/autoload.el'
--- lisp/emacs-lisp/autoload.el	2009-11-07 01:55:16 +0000
+++ lisp/emacs-lisp/autoload.el	2009-12-10 07:52:26 +0000
@@ -457,8 +457,6 @@
           relfile
           ;; nil until we found a cookie.
           output-start)
-      (if (member absfile autoload-excludes)
-      	  (message "Generating autoloads for %s...skipped" file)
       (with-current-buffer (or visited
                                ;; It is faster to avoid visiting the file.
                                (autoload-find-file file))
@@ -572,7 +570,7 @@
           (message "Generating autoloads for %s...done" file))
         (or visited
             ;; We created this buffer, so we should kill it.
-            (kill-buffer (current-buffer)))))
+            (kill-buffer (current-buffer))))
       ;; If the entries were added to some other buffer, then the file
       ;; doesn't add entries to OUTFILE.
       (or (not output-start) otherbuf))))
@@ -729,8 +727,11 @@
 		  ((not (stringp file)))
 		  ((or (not (file-exists-p file))
                        ;; Remove duplicates as well, just in case.
-                       (member file done))
+                       (member file done)
+                       ;; If the file is actually excluded.
+                       (member (expand-file-name file) autoload-excludes))
                    ;; Remove the obsolete section.
+                   (setq changed t)
 		   (autoload-remove-section (match-beginning 0)))
 		  ((not (time-less-p (nth 4 form)
                                      (nth 5 (file-attributes file))))
@@ -746,9 +747,11 @@
 	    (setq files (delete file files)))))
       ;; Elements remaining in FILES have no existing autoload sections yet.
       (dolist (file files)
-        (if (autoload-generate-file-autoloads file nil buffer-file-name)
-            (push file no-autoloads)
-          (setq changed t)))
+        (cond
+         ((member (expand-file-name file) autoload-excludes) nil)
+         ((autoload-generate-file-autoloads file nil buffer-file-name)
+          (push file no-autoloads))
+         (t (setq changed t))))
 
       (when no-autoloads
 	;; Sort them for better readability.