aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2016-01-06 23:33:33 -0800
committerGlenn Morris2016-01-06 23:33:33 -0800
commit3517db2d39fc5a95d478d906b11903a7d70e4873 (patch)
treebda24202522bf08be63ea0b5721f86c9d27ff02e
parent8d329be865e5875960fe400e6679bf5738d7ac35 (diff)
downloademacs-3517db2d39fc5a95d478d906b11903a7d70e4873.tar.gz
emacs-3517db2d39fc5a95d478d906b11903a7d70e4873.zip
Allow creation of loaddefs files without timestamps.
* lisp/emacs-lisp/autoload.el (autoload-timestamps): New variable. (autoload-generate-file-autoloads, update-directory-autoloads): If autoload-timestamps is nil, write "t" instead of file timestamp. (autoload-find-destination, update-directory-autoloads): If timestamp is "t", use the modtime of the output file instead. ; * etc/NEWS: Mention this.
-rw-r--r--etc/NEWS3
-rw-r--r--lisp/emacs-lisp/autoload.el62
2 files changed, 54 insertions, 11 deletions
diff --git a/etc/NEWS b/etc/NEWS
index 232f4970cc9..8907f7ad453 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -68,6 +68,9 @@ in these situations.
68 68
69* Lisp Changes in Emacs 25.2 69* Lisp Changes in Emacs 25.2
70 70
71** Autoload files can be generated without timestamps,
72by setting `autoload-timestamps' to nil.
73
71 74
72* Changes in Emacs 25.2 on Non-Free Operating Systems 75* Changes in Emacs 25.2 on Non-Free Operating Systems
73 76
diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el
index 12d0a94127f..98b05a382aa 100644
--- a/lisp/emacs-lisp/autoload.el
+++ b/lisp/emacs-lisp/autoload.el
@@ -87,6 +87,21 @@ that text will be copied verbatim to `generated-autoload-file'.")
87(defconst generate-autoload-section-continuation ";;;;;; " 87(defconst generate-autoload-section-continuation ";;;;;; "
88 "String to add on each continuation of the section header form.") 88 "String to add on each continuation of the section header form.")
89 89
90(defvar autoload-timestamps t
91 "Non-nil means insert a timestamp for each input file into the output.
92We use these in incremental updates of the output file to decide
93if we need to rescan an input file. If you set this to nil,
94then we use the timestamp of the output file instead. As a result:
95 - for fixed inputs, the output will be the same every time
96 - incremental updates of the output file might not be correct if:
97 i) the timestamp of the output file cannot be trusted (at least
98 relative to that of the input files)
99 ii) any of the input files can be modified during the time it takes
100 to create the output
101 iii) only a subset of the input files are scanned
102 These issues are unlikely to happen in practice, and would arguably
103 represent bugs in the build system.")
104
90(defvar autoload-modified-buffers) ;Dynamically scoped var. 105(defvar autoload-modified-buffers) ;Dynamically scoped var.
91 106
92(defun make-autoload (form file &optional expansion) 107(defun make-autoload (form file &optional expansion)
@@ -624,7 +639,9 @@ FILE's modification time."
624 ;; We'd really want to just use 639 ;; We'd really want to just use
625 ;; `emacs-internal' instead. 640 ;; `emacs-internal' instead.
626 nil nil 'emacs-mule-unix) 641 nil nil 'emacs-mule-unix)
627 (nth 5 (file-attributes relfile)))) 642 (if autoload-timestamps
643 (nth 5 (file-attributes relfile))
644 t)))
628 (insert ";;; Generated autoloads from " relfile "\n"))) 645 (insert ";;; Generated autoloads from " relfile "\n")))
629 (insert generate-autoload-section-trailer)))) 646 (insert generate-autoload-section-trailer))))
630 (or noninteractive 647 (or noninteractive
@@ -688,6 +705,9 @@ removes any prior now out-of-date autoload entries."
688 (catch 'up-to-date 705 (catch 'up-to-date
689 (let* ((buf (current-buffer)) 706 (let* ((buf (current-buffer))
690 (existing-buffer (if buffer-file-name buf)) 707 (existing-buffer (if buffer-file-name buf))
708 (output-file (autoload-generated-file))
709 (output-time (if (file-exists-p output-file)
710 (nth 5 (file-attributes output-file))))
691 (found nil)) 711 (found nil))
692 (with-current-buffer (autoload-find-generated-file) 712 (with-current-buffer (autoload-find-generated-file)
693 ;; This is to make generated-autoload-file have Unix EOLs, so 713 ;; This is to make generated-autoload-file have Unix EOLs, so
@@ -712,16 +732,26 @@ removes any prior now out-of-date autoload entries."
712 (file-time (nth 5 (file-attributes file)))) 732 (file-time (nth 5 (file-attributes file))))
713 (if (and (or (null existing-buffer) 733 (if (and (or (null existing-buffer)
714 (not (buffer-modified-p existing-buffer))) 734 (not (buffer-modified-p existing-buffer)))
715 (or 735 (cond
716 ;; last-time is the time-stamp (specifying 736 ;; last-time is the time-stamp (specifying
717 ;; the last time we looked at the file) and 737 ;; the last time we looked at the file) and
718 ;; the file hasn't been changed since. 738 ;; the file hasn't been changed since.
719 (and (listp last-time) (= (length last-time) 2) 739 ((listp last-time)
720 (not (time-less-p last-time file-time))) 740 (not (time-less-p last-time file-time)))
741 ;; FIXME? Arguably we should throw a
742 ;; user error, or some kind of warning,
743 ;; if we were called from update-file-autoloads,
744 ;; which can update only a single input file.
745 ;; It's not appropriate to use the output
746 ;; file modtime in such a case,
747 ;; if there are multiple input files
748 ;; contributing to the output.
749 ((and output-time (eq t last-time))
750 (not (time-less-p output-time file-time)))
721 ;; last-time is an MD5 checksum instead. 751 ;; last-time is an MD5 checksum instead.
722 (and (stringp last-time) 752 ((stringp last-time)
723 (equal last-time 753 (equal last-time
724 (md5 buf nil nil 'emacs-mule))))) 754 (md5 buf nil nil 'emacs-mule)))))
725 (throw 'up-to-date nil) 755 (throw 'up-to-date nil)
726 (autoload-remove-section begin) 756 (autoload-remove-section begin)
727 (setq found t)))) 757 (setq found t))))
@@ -781,7 +811,10 @@ write its autoloads into the specified file instead."
781 (generated-autoload-file 811 (generated-autoload-file
782 (if (called-interactively-p 'interactive) 812 (if (called-interactively-p 'interactive)
783 (read-file-name "Write autoload definitions to file: ") 813 (read-file-name "Write autoload definitions to file: ")
784 generated-autoload-file))) 814 generated-autoload-file))
815 (output-time
816 (if (file-exists-p generated-autoload-file)
817 (nth 5 (file-attributes generated-autoload-file)))))
785 818
786 (with-current-buffer (autoload-find-generated-file) 819 (with-current-buffer (autoload-find-generated-file)
787 (save-excursion 820 (save-excursion
@@ -799,6 +832,8 @@ write its autoloads into the specified file instead."
799 ;; Remove the obsolete section. 832 ;; Remove the obsolete section.
800 (autoload-remove-section (match-beginning 0)) 833 (autoload-remove-section (match-beginning 0))
801 (setq last-time (nth 4 form)) 834 (setq last-time (nth 4 form))
835 (if (equal t last-time)
836 (setq last-time output-time))
802 (dolist (file file) 837 (dolist (file file)
803 (let ((file-time (nth 5 (file-attributes file)))) 838 (let ((file-time (nth 5 (file-attributes file))))
804 (when (and file-time 839 (when (and file-time
@@ -814,7 +849,10 @@ write its autoloads into the specified file instead."
814 (member (expand-file-name file) autoload-excludes)) 849 (member (expand-file-name file) autoload-excludes))
815 ;; Remove the obsolete section. 850 ;; Remove the obsolete section.
816 (autoload-remove-section (match-beginning 0))) 851 (autoload-remove-section (match-beginning 0)))
817 ((not (time-less-p (nth 4 form) 852 ((not (time-less-p (let ((oldtime (nth 4 form)))
853 (if (equal t oldtime)
854 output-time
855 oldtime))
818 (nth 5 (file-attributes file)))) 856 (nth 5 (file-attributes file))))
819 ;; File hasn't changed. 857 ;; File hasn't changed.
820 nil) 858 nil)
@@ -830,7 +868,7 @@ write its autoloads into the specified file instead."
830 (let ((no-autoloads-time (or last-time '(0 0 0 0))) file-time) 868 (let ((no-autoloads-time (or last-time '(0 0 0 0))) file-time)
831 (dolist (file files) 869 (dolist (file files)
832 (cond 870 (cond
833 ((member (expand-file-name file) autoload-excludes) nil) 871 ((member (expand-file-name file) autoload-excludes nil))
834 ;; Passing nil as second argument forces 872 ;; Passing nil as second argument forces
835 ;; autoload-generate-file-autoloads to look for the right 873 ;; autoload-generate-file-autoloads to look for the right
836 ;; spot where to insert each autoloads section. 874 ;; spot where to insert each autoloads section.
@@ -847,7 +885,9 @@ write its autoloads into the specified file instead."
847 (goto-char (point-max)) 885 (goto-char (point-max))
848 (search-backward "\f" nil t) 886 (search-backward "\f" nil t)
849 (autoload-insert-section-header 887 (autoload-insert-section-header
850 (current-buffer) nil nil no-autoloads no-autoloads-time) 888 (current-buffer) nil nil no-autoloads (if autoload-timestamps
889 no-autoloads-time
890 t))
851 (insert generate-autoload-section-trailer))) 891 (insert generate-autoload-section-trailer)))
852 892
853 (let ((version-control 'never)) 893 (let ((version-control 'never))