Subject: Re: bug#79411: 31.0.50; describe-package does not show :readme after package installation, but sth else

From: Jens Schmidt <[email-masked]>
Date: Sat, 13 Sep 2025 12:04:04 +0200

On 2025-09-12  11:23, Philip Kaludercic wrote:

> In my previous message I suggested something like:
> 
> diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
> index ba9999c20e6..b9e2eb96389 100644
> --- a/lisp/emacs-lisp/package.el
> +++ b/lisp/emacs-lisp/package.el
> @@ -2162,7 +2162,15 @@ package-install-from-archive
>                 ;; Update the new (activated) pkg-desc as well.
>                 (when-let* ((pkg-descs (cdr (assq (package-desc-name pkg-desc)
>                                                   package-alist))))
> -                 (setf (package-desc-signed (car pkg-descs)) t))))))))))
> +                 (setf (package-desc-signed (car pkg-descs)) t)))))))
> +      ;; fetch a backup of the readme file from the server
> +      (let ((readme (expand-file-name "README-elpa" (package-desc-dir pkg-desc))))
> +        (unless (file-readable-p readme)
> +          (package--with-response-buffer (package-archive-base pkg-desc)
> +            :file (format "%s-readme.txt" (package-desc-name pkg-desc))
> +            :noerror t
> +            (write-region nil nil readme)))))))
> +
>  
>  ;;;###autoload
>  (defun package-installed-p (package &optional min-version)
> 
> As we store the README file inside the package directory, it should also
> be deleted when we delete the package -- unless I am missing something?

I like that approach, it should fix this issue, and it nicely
complements what elpa-admin.el already does for some readmes on server
side.  Some notes:

1. You probably should not write README-elpa when it would be empty
   (which can happen, see
   https://elpa.gnu.org/packages/bicep-ts-mode-readme.txt), as that
   would block the search of `package--get-description' for more
   readmes.

2. Alternatively or in addition, one could extend
   `package--get-description' to not consider empty files in its
   search for a readme.

3. I think a paragraph in "(elisp) Packaging Basics" and some tests in
   package-tests.el would still be required.  Do you want me to supply
   these?

Thanks!