Mercurial > emacs
comparison lisp/emacs-lisp/autoload.el @ 81731:6416cbdef0fa
(autoload-find-destination): Understand a new format of autoload block where
the file's time-stamp is replaced by its MD5 checksum.
(autoload-generate-file-autoloads): Use MD5 checksum instead of
time-stamp for secondary autoloads files.
(update-directory-autoloads): Remove duplicate entries.
Use time-less-p for time-stamps, as done in autoload-find-destination.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Sat, 07 Jul 2007 04:56:00 +0000 |
parents | 835baa7a130c |
children | 8aa7f1b66163 988f1edc9674 |
comparison
equal
deleted
inserted
replaced
81730:f6b5e814cb55 | 81731:6416cbdef0fa |
---|---|
407 (t | 407 (t |
408 (forward-sexp 1) | 408 (forward-sexp 1) |
409 (forward-line 1)))))) | 409 (forward-line 1)))))) |
410 | 410 |
411 (when output-start | 411 (when output-start |
412 (with-current-buffer outbuf | 412 (let ((secondary-autoloads-file-buf |
413 (save-excursion | 413 (if (local-variable-p 'generated-autoload-file) |
414 ;; Insert the section-header line which lists the file name | 414 (current-buffer)))) |
415 ;; and which functions are in it, etc. | 415 (with-current-buffer outbuf |
416 (goto-char output-start) | 416 (save-excursion |
417 (autoload-insert-section-header | 417 ;; Insert the section-header line which lists the file name |
418 outbuf autoloads-done load-name relfile | 418 ;; and which functions are in it, etc. |
419 (nth 5 (file-attributes relfile))) | 419 (goto-char output-start) |
420 (insert ";;; Generated autoloads from " relfile "\n")) | 420 (autoload-insert-section-header |
421 (insert generate-autoload-section-trailer))) | 421 outbuf autoloads-done load-name relfile |
422 (if secondary-autoloads-file-buf | |
423 ;; MD5 checksums are much better because they do not | |
424 ;; change unless the file changes (so they'll be | |
425 ;; equal on two different systems and will change | |
426 ;; less often than time-stamps, thus leading to fewer | |
427 ;; unneeded changes causing spurious conflicts), but | |
428 ;; using time-stamps is a very useful optimization, | |
429 ;; so we use time-stamps for the main autoloads file | |
430 ;; (loaddefs.el) where we have special ways to | |
431 ;; circumvent the "random change problem", and MD5 | |
432 ;; checksum in secondary autoload files where we do | |
433 ;; not need the time-stamp optimization because it is | |
434 ;; already provided by the primary autoloads file. | |
435 (md5 secondary-autoloads-file-buf nil nil 'emacs-mule) | |
436 (nth 5 (file-attributes relfile)))) | |
437 (insert ";;; Generated autoloads from " relfile "\n")) | |
438 (insert generate-autoload-section-trailer)))) | |
422 (message "Generating autoloads for %s...done" file)) | 439 (message "Generating autoloads for %s...done" file)) |
423 (or visited | 440 (or visited |
424 ;; We created this buffer, so we should kill it. | 441 ;; We created this buffer, so we should kill it. |
425 (kill-buffer (current-buffer)))) | 442 (kill-buffer (current-buffer)))) |
426 ;; If the entries were added to some other buffer, then the file | 443 ;; If the entries were added to some other buffer, then the file |
452 (defun autoload-find-destination (file) | 469 (defun autoload-find-destination (file) |
453 "Find the destination point of the current buffer's autoloads. | 470 "Find the destination point of the current buffer's autoloads. |
454 FILE is the file name of the current buffer. | 471 FILE is the file name of the current buffer. |
455 Returns a buffer whose point is placed at the requested location. | 472 Returns a buffer whose point is placed at the requested location. |
456 Returns nil if the file's autoloads are uptodate, otherwise | 473 Returns nil if the file's autoloads are uptodate, otherwise |
457 removes any prior now out-of-date autoload entries. | 474 removes any prior now out-of-date autoload entries." |
458 The current buffer only matters if it is visiting a file or if it has a buffer-local | |
459 value for some variables such as `generated-autoload-file', so it's OK | |
460 to call it from a dummy buffer if FILE is not currently visited." | |
461 (catch 'up-to-date | 475 (catch 'up-to-date |
462 (let ((load-name (autoload-file-load-name file)) | 476 (let* ((load-name (autoload-file-load-name file)) |
463 (existing-buffer (if buffer-file-name (current-buffer))) | 477 (buf (current-buffer)) |
464 (found nil)) | 478 (existing-buffer (if buffer-file-name buf)) |
479 (found nil)) | |
465 (with-current-buffer | 480 (with-current-buffer |
466 ;; We must read/write the file without any code conversion, | 481 ;; We must read/write the file without any code conversion, |
467 ;; but still decode EOLs. | 482 ;; but still decode EOLs. |
468 (let ((coding-system-for-read 'raw-text)) | 483 (let ((coding-system-for-read 'raw-text)) |
469 (find-file-noselect | 484 (find-file-noselect |
487 (let ((begin (match-beginning 0)) | 502 (let ((begin (match-beginning 0)) |
488 (last-time (nth 4 form)) | 503 (last-time (nth 4 form)) |
489 (file-time (nth 5 (file-attributes file)))) | 504 (file-time (nth 5 (file-attributes file)))) |
490 (if (and (or (null existing-buffer) | 505 (if (and (or (null existing-buffer) |
491 (not (buffer-modified-p existing-buffer))) | 506 (not (buffer-modified-p existing-buffer))) |
492 (listp last-time) (= (length last-time) 2) | 507 (or |
493 (not (time-less-p last-time file-time))) | 508 ;; last-time is the time-stamp (specifying |
509 ;; the last time we looked at the file) and | |
510 ;; the file hasn't been changed since. | |
511 (and (listp last-time) (= (length last-time) 2) | |
512 (not (time-less-p last-time file-time))) | |
513 ;; last-time is an MD5 checksum instead. | |
514 (and (stringp last-time) | |
515 (equal last-time | |
516 (md5 buf nil nil 'emacs-mule))))) | |
494 (throw 'up-to-date nil) | 517 (throw 'up-to-date nil) |
495 (autoload-remove-section begin) | 518 (autoload-remove-section begin) |
496 (setq found t)))) | 519 (setq found t)))) |
497 ((string< load-name (nth 2 form)) | 520 ((string< load-name (nth 2 form)) |
498 ;; We've come to a section alphabetically later than | 521 ;; We've come to a section alphabetically later than |
567 (not (time-less-p last-time file-time))) | 590 (not (time-less-p last-time file-time))) |
568 ;; file unchanged | 591 ;; file unchanged |
569 (push file no-autoloads) | 592 (push file no-autoloads) |
570 (setq files (delete file files))))))) | 593 (setq files (delete file files))))))) |
571 ((not (stringp file))) | 594 ((not (stringp file))) |
572 ((not (file-exists-p file)) | 595 ((not (and (file-exists-p file) |
596 ;; Remove duplicates as well, just in case. | |
597 (member file files))) | |
573 ;; Remove the obsolete section. | 598 ;; Remove the obsolete section. |
574 (autoload-remove-section (match-beginning 0))) | 599 (autoload-remove-section (match-beginning 0))) |
575 ((equal (nth 4 form) (nth 5 (file-attributes file))) | 600 ((not (time-less-p (nth 4 form) |
601 (nth 5 (file-attributes file)))) | |
576 ;; File hasn't changed. | 602 ;; File hasn't changed. |
577 nil) | 603 nil) |
578 (t | 604 (t |
579 (autoload-remove-section (match-beginning 0)) | 605 (autoload-remove-section (match-beginning 0)) |
580 (if (autoload-generate-file-autoloads | 606 (if (autoload-generate-file-autoloads |