From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Lars Ingebrigtsen Newsgroups: gmane.emacs.bugs Subject: bug#39823: 26.3; update-directory-autoloads regression from Emacs 26 to Emacs 27 Date: Thu, 01 Oct 2020 19:20:01 +0200 Message-ID: <87h7rdq2wu.fsf@gnus.org> References: <87zhd2lpad.fsf@gmail.com> <87o8t16q5e.fsf@gmail.com> <87y2rz4tgb.fsf@gmail.com> <87blo2k4wp.fsf@gmail.com> <83369eqyij.fsf@gnu.org> <87wo6qhqvd.fsf@gmail.com> <835ze9pzfq.fsf@gnu.org> <87mu78jhgz.fsf@gmail.com> <868sir8y85.fsf@gmail.com> <87mu4vn3kz.fsf@gmail.com> <87a6x747bq.fsf@gnus.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="303"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: 39823@debbugs.gnu.org, rms@gnu.org, Noam Postavsky To: Maxim Cournoyer Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Oct 01 19:21:20 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kO2Ge-000AV0-9Z for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 01 Oct 2020 19:21:20 +0200 Original-Received: from localhost ([::1]:42166 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kO2Gd-0007ew-95 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 01 Oct 2020 13:21:19 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:58398) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kO2GM-0007ds-Qe for bug-gnu-emacs@gnu.org; Thu, 01 Oct 2020 13:21:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:54841) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kO2GM-0003Zm-G3 for bug-gnu-emacs@gnu.org; Thu, 01 Oct 2020 13:21:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kO2GM-0001o6-98 for bug-gnu-emacs@gnu.org; Thu, 01 Oct 2020 13:21:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 01 Oct 2020 17:21:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 39823 X-GNU-PR-Package: emacs Original-Received: via spool by 39823-submit@debbugs.gnu.org id=B39823.16015728156867 (code B ref 39823); Thu, 01 Oct 2020 17:21:02 +0000 Original-Received: (at 39823) by debbugs.gnu.org; 1 Oct 2020 17:20:15 +0000 Original-Received: from localhost ([127.0.0.1]:38154 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kO2Fa-0001mh-CX for submit@debbugs.gnu.org; Thu, 01 Oct 2020 13:20:15 -0400 Original-Received: from quimby.gnus.org ([95.216.78.240]:33192) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kO2FY-0001mR-56 for 39823@debbugs.gnu.org; Thu, 01 Oct 2020 13:20:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=tEaeG90NnSZerfxHeENYVG4CxC9XHeMUDMqZYgds8/A=; b=PszmLN69dLX8ou5SNfiRQAdmV8 +jJ/c7vrmfJoaEvRq3NY8VnnsRy4mcczibmfKfuRbcSciBVjizWXxuA9cXxUF+oFHTIRieCB21UV1 NXuLuRVyTHZ5mNAYuMOvpBsiFPDegk0MPrreUht+L0s8ffsquAHgURuLrdLwZ/Th8x0Q=; Original-Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kO2FO-0000xQ-Id; Thu, 01 Oct 2020 19:20:05 +0200 Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAACBj SFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAFVBMVEWeojOusVi0sqPW 1NH29vFsaWH///9lFNI9AAAAAWJLR0QGYWa4fQAAAAd0SU1FB+QKARA6Ge7pWTkAAAGkSURBVDjL nZJNetwgDIYhTffgpPtYwD6DNAcYUC9g1/e/SiX8h/NMs6gMLHiRvk8YY9bwMq0PfETbdW2YH8wX 4Lw33gm6gg9jRuu10hdwk/oOvKrYC9Dj/vZpXiT1/aIxeP8iU4YZeqDSw9jC2UuGdX70IwyDM54u dtWSXbt5v4Az7NtzYP0/gFjrXa0CK+jUzWcHehHzWK+8XbIVUHfAzvpDPQBn2sHDu0M+FsIDMG7A Om2wKqAGdvL6YeIG1gzmx2jdqOYQueIJxAiV0fy82T+y3wFGBFx+LW95RoBAJ6gAsCyLrNOUU+5A ntKSFg6BC0BqMg1wniFhZALmQJPUPjWmScyrqZxjxbq5oprCEokJZcDhqjmsQIRBjmKmE0gnNSDi PSNjPTNIwSQH7zmEHuj4PSsoMdS6/hLTrlJLiel7mWJl3DKUI5WZOUFhLryLU/tY2uJ7UtCCjFSJ CrRAggOgANLOMItfCIyFNiBNyBWAdJElQ5oNsmSM4qqdkR2orFxfQ0Uy518WT/P+3GoPEsBzELDE p6CPr6DiHvwdeBb1P8BfcTXhhZ9aEUQAAAAldEVYdGRhdGU6Y3JlYXRlADIwMjAtMTAtMDFUMTY6 NTg6MjUrMDA6MDCI5DbiAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDIwLTEwLTAxVDE2OjU4OjI1KzAw OjAw+bmOXgAAAABJRU5ErkJggg== X-Now-Playing: Static's _Re: Talking About Memories_: "Point Of Hope" In-Reply-To: <87a6x747bq.fsf@gnus.org> (Lars Ingebrigtsen's message of "Wed, 30 Sep 2020 17:23:21 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:189539 Archived-At: Lars Ingebrigtsen writes: > I think it would make more sense to introduce a new function, say, > `make-directory-autoloads' (because it doesn't so much update the > autoloads as create an autoload file, I think?) with a sane function > signature, and then deprecate update-directory-autoloads (which is only > used a handful of place in the Emacs tree). Man, that was a lot more invasive than I thought, because the dynamically bound variable was used all over the place. But with the following patch (make-directory-autoloads "~/src/emacs/trunk/lisp/calc" "/tmp/autofoo.el") works. Emacs builds after applying the patch, and starts, and no tests fail. Does this look OK to everybody? diff --git a/doc/lispref/loading.texi b/doc/lispref/loading.texi index 6833af9c26..aa6ef307b1 100644 --- a/doc/lispref/loading.texi +++ b/doc/lispref/loading.texi @@ -577,7 +577,7 @@ Autoload define function @var{function-name}"}. @findex update-file-autoloads -@findex update-directory-autoloads +@findex make-directory-autoloads @cindex magic autoload comment @cindex autoload cookie @anchor{autoload cookie} @@ -590,7 +590,7 @@ Autoload file generated by @code{update-file-autoloads} can be changed from the above defaults, see below.) Building Emacs loads @file{loaddefs.el} and thus calls @code{autoload}. -@kbd{M-x update-directory-autoloads} is even more powerful; it updates +@kbd{M-x make-directory-autoloads} is even more powerful; it updates autoloads for all files in the current directory. The same magic comment can copy any kind of form into diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el index 0bcd7b7dcd..fe6a72c0a1 100644 --- a/lisp/emacs-lisp/autoload.el +++ b/lisp/emacs-lisp/autoload.el @@ -254,13 +254,12 @@ make-autoload ;; the doc-string in FORM. ;; Those properties are now set in lisp-mode.el. -(defun autoload-find-generated-file () +(defun autoload-find-generated-file (file) "Visit the autoload file for the current buffer, and return its buffer." (let ((enable-local-variables :safe) (enable-local-eval nil) (find-file-hook nil) - (delay-mode-hooks t) - (file (autoload-generated-file))) + (delay-mode-hooks t)) ;; We used to use `raw-text' to read this file, but this causes ;; problems when the file contains non-ASCII characters. (with-current-buffer (find-file-noselect @@ -268,11 +267,13 @@ autoload-find-generated-file (if (zerop (buffer-size)) (insert (autoload-rubric file nil t))) (current-buffer)))) -(defun autoload-generated-file () +(defun autoload-generated-file (outfile) "Return `generated-autoload-file' as an absolute name. If local to the current buffer, expand using the default directory; otherwise, using `source-directory'/lisp." - (expand-file-name generated-autoload-file + (expand-file-name (if (local-variable-p 'generated-autoload-file) + generated-autoload-file + outfile) ;; File-local settings of generated-autoload-file should ;; be interpreted relative to the file's location, ;; of course. @@ -454,13 +455,12 @@ autoload-find-file (defvar no-update-autoloads nil "File local variable to prevent scanning this file for autoload cookies.") -(defun autoload-file-load-name (file) +(defun autoload-file-load-name (file outfile) "Compute the name that will be used to load FILE." ;; OUTFILE should be the name of the global loaddefs.el file, which ;; is expected to be at the root directory of the files we're ;; scanning for autoloads and will be in the `load-path'. - (let* ((outfile (default-value 'generated-autoload-file)) - (name (file-relative-name file (file-name-directory outfile))) + (let* ((name (file-relative-name file (file-name-directory outfile))) (names '()) (dir (file-name-directory outfile))) ;; If `name' has directory components, only keep the @@ -608,7 +608,7 @@ autoload--make-defs-autoload `(register-definition-prefixes ,file ',(sort (delq nil strings) 'string<)))))) -(defun autoload--setup-output (otherbuf outbuf absfile load-name) +(defun autoload--setup-output (otherbuf outbuf absfile load-name output-file) (let ((outbuf (or (if otherbuf ;; A file-local setting of @@ -616,7 +616,7 @@ autoload--setup-output ;; should ignore OUTBUF. nil outbuf) - (autoload-find-destination absfile load-name) + (autoload-find-destination absfile load-name output-file) ;; The file has autoload cookies, but they're ;; already up-to-date. If OUTFILE is nil, the ;; entries are in the expected OUTBUF, @@ -717,7 +717,7 @@ autoload-generate-file-autoloads (setq load-name (if (stringp generated-autoload-load-name) generated-autoload-load-name - (autoload-file-load-name absfile))) + (autoload-file-load-name absfile outfile))) ;; FIXME? Comparing file-names for equality with just equal ;; is fragile, eg if one has an automounter prefix and one ;; does not, but both refer to the same physical file. @@ -725,8 +725,10 @@ autoload-generate-file-autoloads (not (if (memq system-type '(ms-dos windows-nt)) (equal (downcase outfile) - (downcase (autoload-generated-file))) - (equal outfile (autoload-generated-file))))) + (downcase (autoload-generated-file + outfile))) + (equal outfile (autoload-generated-file + outfile))))) (setq otherbuf t)) (save-excursion (save-restriction @@ -740,7 +742,8 @@ autoload-generate-file-autoloads (file-name-sans-extension (file-name-nondirectory file)))) (setq output-start (autoload--setup-output - otherbuf outbuf absfile load-name)) + otherbuf outbuf absfile + load-name outfile)) (let ((standard-output (marker-buffer output-start)) (print-quoted t)) (princ `(push (purecopy @@ -758,7 +761,8 @@ autoload-generate-file-autoloads ;; If not done yet, figure out where to insert this text. (unless output-start (setq output-start (autoload--setup-output - otherbuf outbuf absfile load-name))) + otherbuf outbuf absfile + load-name outfile))) (autoload--print-cookie-text output-start load-name file)) ((= (following-char) ?\;) ;; Don't read the comment. @@ -789,7 +793,7 @@ autoload-generate-file-autoloads ((not otherbuf) (unless output-start (setq output-start (autoload--setup-output - nil outbuf absfile load-name))) + nil outbuf absfile load-name outfile))) (let ((autoload-print-form-outbuf (marker-buffer output-start))) (autoload-print-form form))) @@ -801,9 +805,8 @@ autoload-generate-file-autoloads ;; then passing otherbuf=nil is enough, but if ;; outbuf is nil, that won't cut it, so we ;; locally bind generated-autoload-file. - (let ((generated-autoload-file - (default-value 'generated-autoload-file))) - (autoload--setup-output nil outbuf absfile load-name))) + (autoload--setup-output nil outbuf absfile load-name + outfile)) (autoload-print-form-outbuf (marker-buffer other-output-start))) (autoload-print-form form) @@ -937,7 +940,7 @@ update-file-autoloads (message "Autoload section for %s is up to date." file))) (if no-autoloads file))) -(defun autoload-find-destination (file load-name) +(defun autoload-find-destination (file load-name output-file) "Find the destination point of the current buffer's autoloads. FILE is the file name of the current buffer. LOAD-NAME is the name as it appears in the output. @@ -947,12 +950,12 @@ autoload-find-destination (catch 'up-to-date (let* ((buf (current-buffer)) (existing-buffer (if buffer-file-name buf)) - (output-file (autoload-generated-file)) + (output-file (autoload-generated-file output-file)) (output-time (if (file-exists-p output-file) (file-attribute-modification-time (file-attributes output-file)))) (found nil)) - (with-current-buffer (autoload-find-generated-file) + (with-current-buffer (autoload-find-generated-file output-file) ;; This is to make generated-autoload-file have Unix EOLs, so ;; that it is portable to all platforms. (or (eq 0 (coding-system-eol-type buffer-file-coding-system)) @@ -1038,7 +1041,20 @@ update-directory-autoloads use the existing value of `generated-autoload-file'. If any Lisp file binds `generated-autoload-file' as a file-local variable, write its autoloads into the specified file instead." - (interactive "DUpdate autoloads from directory: ") + (declare (obsolete make-directory-autoloads "28.1")) + (make-directory-autoloads dirs generated-autoload-file)) + +;;;###autoload +(defun make-directory-autoloads (dir output-file) + "Update autoload definitions for Lisp files in the directories DIRS. +DIR can be either a single directory or a list of +directories. (The latter usage is discouraged.) + +The autoloads will be written to OUTPUT-FILE. + +The function does NOT recursively descend into subdirectories of the +directory or directories specified." + (interactive "DUpdate autoloads from directory: \nfWrite to file: ") (let* ((files-re (let ((tmp nil)) (dolist (suf (get-load-suffixes)) ;; We don't use module-file-suffix below because @@ -1049,10 +1065,10 @@ update-directory-autoloads (push suf tmp))) (concat "\\`[^=.].*" (regexp-opt tmp t) "\\'"))) (files (apply #'nconc - (mapcar (lambda (dir) - (directory-files (expand-file-name dir) - t files-re)) - dirs))) + (mapcar (lambda (d) + (directory-files (expand-file-name d) + t files-re)) + (if (consp dir) dir (list dir))))) (done ()) ;Files processed; to remove duplicates. (changed nil) ;Non-nil if some change occurred. (last-time) @@ -1060,16 +1076,12 @@ update-directory-autoloads ;; files because of file-local autoload-generated-file settings. (no-autoloads nil) (autoload-modified-buffers nil) - (generated-autoload-file - (if (called-interactively-p 'interactive) - (read-file-name "Write autoload definitions to file: ") - generated-autoload-file)) (output-time - (if (file-exists-p generated-autoload-file) - (file-attribute-modification-time - (file-attributes generated-autoload-file))))) + (and (file-exists-p output-file) + (file-attribute-modification-time + (file-attributes output-file))))) - (with-current-buffer (autoload-find-generated-file) + (with-current-buffer (autoload-find-generated-file output-file) (save-excursion ;; Canonicalize file names and remove the autoload file itself. (setq files (delete (file-relative-name buffer-file-name) @@ -1126,8 +1138,7 @@ update-directory-autoloads (progress (make-progress-reporter (byte-compile-info (concat "Scraping files for " - (file-relative-name - generated-autoload-file))) + (file-relative-name output-file))) 0 (length files) nil 10)) (file-count 0) file-time) @@ -1190,6 +1201,8 @@ batch-update-autoloads ;; Exclude those files that are preloaded on ALL platforms. ;; These are the ones in loadup.el where "(load" is at the start ;; of the line (crude, but it works). + (message "FOOOO") + (setq debug-on-error t) (unless autoload-excludes (let ((default-directory (file-name-directory generated-autoload-file)) file) @@ -1205,7 +1218,7 @@ batch-update-autoloads (let ((args command-line-args-left)) (batch-update-autoloads--summary args) (setq command-line-args-left nil) - (apply #'update-directory-autoloads args))) + (make-directory-autoloads args generated-autoload-file))) (provide 'autoload) diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index a173fc060a..e77077fc52 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el @@ -1013,7 +1013,6 @@ package-autoload-ensure-default-file (write-region (autoload-rubric file "package" nil) nil file nil 'silent)) file) -(defvar generated-autoload-file) (defvar autoload-timestamps) (defvar version-control) @@ -1021,14 +1020,14 @@ package-generate-autoloads "Generate autoloads in PKG-DIR for package named NAME." (let* ((auto-name (format "%s-autoloads.el" name)) ;;(ignore-name (concat name "-pkg.el")) - (generated-autoload-file (expand-file-name auto-name pkg-dir)) + (output-file (expand-file-name auto-name pkg-dir)) ;; We don't need 'em, and this makes the output reproducible. (autoload-timestamps nil) (backup-inhibited t) (version-control 'never)) - (package-autoload-ensure-default-file generated-autoload-file) - (update-directory-autoloads pkg-dir) - (let ((buf (find-buffer-visiting generated-autoload-file))) + (package-autoload-ensure-default-file output-file) + (make-directory-autoloads pkg-dir output-file) + (let ((buf (find-buffer-visiting output-file))) (when buf (kill-buffer buf))) auto-name)) diff --git a/test/lisp/vc/vc-bzr-tests.el b/test/lisp/vc/vc-bzr-tests.el index b68a694512..408d6e8e23 100644 --- a/test/lisp/vc/vc-bzr-tests.el +++ b/test/lisp/vc/vc-bzr-tests.el @@ -131,7 +131,6 @@ vc-bzr-test-faulty-bzr-autoloads (make-directory bzrdir) (expand-file-name "foo.el" bzrdir))) (default-directory (file-name-as-directory bzrdir)) - (generated-autoload-file (expand-file-name "loaddefs.el" bzrdir)) (process-environment (cons (format "HOME=%s" homedir) process-environment))) (unwind-protect @@ -148,7 +147,9 @@ vc-bzr-test-faulty-bzr-autoloads ;; causes bzr status to fail. This simulates a broken bzr ;; installation. (delete-file ".bzr/checkout/dirstate") - (should (progn (update-directory-autoloads default-directory) + (should (progn (make-directory-autoloads + default-directory + (expand-file-name "loaddefs.el" bzrdir)) t))) (delete-directory homedir t)))) -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no