GNU bug report logs - #63260
29.0.90; Regression installing/activating packages without autoloads

Previous Next

Package: emacs;

Reported by: Basil Contovounesios <contovob <at> tcd.ie>

Date: Thu, 4 May 2023 10:16:02 UTC

Severity: normal

Merged with 63298

Found in version 29.0.90

Done: Philip Kaludercic <philipk <at> posteo.net>

Bug is archived. No further changes may be made.

Full log


Message #58 received at 63260 <at> debbugs.gnu.org (full text, mbox):

From: Philip Kaludercic <philipk <at> posteo.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: contovob <at> tcd.ie, 63260 <at> debbugs.gnu.org, rpluim <at> gmail.com
Subject: Re: bug#63260: 29.0.90; Regression installing/activating packages
 without autoloads
Date: Sun, 07 May 2023 19:37:26 +0000
[Message part 1 (text/plain, inline)]
Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: Philip Kaludercic <philipk <at> posteo.net>
>> Cc: contovob <at> tcd.ie,  63260 <at> debbugs.gnu.org,  rpluim <at> gmail.com
>> Date: Sun, 07 May 2023 13:12:47 +0000
>> 
>> One hack might just be to check if `loaddefs-generate' has generated
>> anything at all or not, and if that is not the case to do so manually in
>> package.el.  The reason this doesn't seem nice, is that we'd have to
>> make the fact that `loaddefs-generate' does not generate a OUTPUT-FILE
>> if there is no file with autoloads explicit, and finding a justification
>> for that is difficult.  Alternatively, this could be done inside of
>> `loaddefs-generate'?  Something like
>
> Assuming it solves the issue and doesn't break anything, the latter
> sounds good to me, better than the alternatives.
>
>> +    ;; HACK: If no file with autoloads were found, but EXTRA-DATA was
>> +    ;; passed, we still want to generate a file.
>
> The comment says "EXTRA-DATA was passed", but this added snipped will
> also run if EXTRA-DATA was NOT passed, but the OUTPUT-FILE doesn't
> exist, right?

Right, the code was not tested as I was in a hurry.  I've changed it to

    ;; HACK: If no file with autoloads were found, but EXTRA-DATA was
    ;; passed, we still want to generate a file.
    (when (and extra-data (not (file-exists-p output-file)))


and this file is generated when installing the SICP package:

--8<---------------cut here---------------start------------->8---
;;; sicp-autoloads.el --- automatically extracted autoloads (do not edit)   -*- lexical-binding: t -*-
;; Generated by the `loaddefs-generate' function.

;; This file is part of GNU Emacs.

;;; Code:

(add-to-list 'load-path (or (and load-file-name (file-name-directory load-file-name)) (car load-path)))


;;; End of scraped data

(provide 'sicp-autoloads)

;; Local Variables:
;; version-control: never
;; no-byte-compile: t
;; no-update-autoloads: t
;; no-native-compile: t
;; coding: utf-8-emacs-unix
;; End:

;;; sicp-autoloads.el ends here
--8<---------------cut here---------------end--------------->8---

and this does not break anything when installing packages.

> And I would explain in the comment the real-life situations where this
> is needed, and why, rather than just explaining in English what the
> code does.

You are right.  How does this patch look like:

[0001-Ensure-that-EXTRA-DATA-are-always-written-when-gener.patch (text/x-diff, inline)]
From 08c914abaa37bfb1f84ca7a357cc6e01ccfd254f Mon Sep 17 00:00:00 2001
From: Philip Kaludercic <philipk <at> posteo.net>
Date: Sun, 7 May 2023 21:37:01 +0200
Subject: [PATCH] Ensure that EXTRA-DATA are always written when generating
 autoloads

* lisp/emacs-lisp/loaddefs-gen.el (loaddefs-generate): Handle
edge-case where no autoloads are found.  (Bug#63260)
---
 lisp/emacs-lisp/loaddefs-gen.el | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/lisp/emacs-lisp/loaddefs-gen.el b/lisp/emacs-lisp/loaddefs-gen.el
index 2a46fb7a022..5db9af21508 100644
--- a/lisp/emacs-lisp/loaddefs-gen.el
+++ b/lisp/emacs-lisp/loaddefs-gen.el
@@ -656,7 +656,20 @@ loaddefs-generate
             (write-region (point-min) (point-max) loaddefs-file nil 'silent)
             (byte-compile-info
              (file-relative-name loaddefs-file (car (ensure-list dir)))
-             t "GEN")))))))
+             t "GEN")))))
+
+    ;; If processing files without any autoloads, the above loop will
+    ;; not generate any files.  If the function was invoked with
+    ;; EXTRA-DATA, we want to ensure that even if no autoloads were
+    ;; found, that at least a file will have been generated containing
+    ;; the contents of EXTRA-DATA:
+    (when (and extra-data (not (file-exists-p output-file)))
+      (with-temp-buffer
+        (insert (loaddefs-generate--rubric output-file nil t))
+        (search-backward "\f")
+        (insert extra-data)
+        (ensure-empty-lines 1)
+        (write-region (point-min) (point-max) output-file nil 'silent)))))
 
 (defun loaddefs-generate--print-form (def)
   "Print DEF in a format that makes sense for version control."
-- 
2.39.2

[Message part 3 (text/plain, inline)]
> Thanks.

This bug report was last modified 2 years and 15 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.