Subject: bug#77075: [PATCH] Prepare package.el to be published on GNU ELPA, [PATCH] Prepare package.el to be published on GNU ELPA

From: Philip Kaludercic <[email-masked]>
Date: Mon, 17 Mar 2025 20:28:32 +0000

Daniel Mendler <[email-masked]> writes:

> Hi Philip,
> a few comments below.

Thanks for the reminders, I've update the patch!

>From 5943b2de9efe54dc6f5170ca2733460ada6a6385 Mon Sep 17 00:00:00 2001
From: Philip Kaludercic <[email-masked]>
Date: Wed, 5 Apr 2023 23:16:00 +0200
Subject: [PATCH] Prepare package.el to be published on GNU ELPA

* lisp/emacs-lisp/package.el: Add Compat as a dependency.
(lm-homepage, lm-website): Use backwards-compatible alias
'lm-homepage'.
(package-buffer-info): Call 'lm-maintainer' if 'lm-maintainers' is not
defined.
(package-report-bug): Expand 'custom--standard-value' definition.

For the background and motivation behind these changes, please consult
this thread:
https://lists.gnu.org/archive/html/emacs-devel/2023-03/msg00995.html.
---
 lisp/emacs-lisp/package.el | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index 8d2e2f09108..939289232d7 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -5,9 +5,12 @@
 ;; Author: Tom Tromey <[email-masked]>
 ;;         Daniel Hackney <[email-masked]>
 ;; Created: 10 Mar 2007
-;; Version: 1.1.0
+;; Version: 1.1.1-pre
 ;; Keywords: tools
-;; Package-Requires: ((tabulated-list "1.0"))
+;; Package-Requires: ((emacs "26.1") (compat "30"))
+
+;; This is a GNU ELPA :core package.  Avoid functionality that is not
+;; compatible with the version of Emacs recorded above.
 
 ;; This file is part of GNU Emacs.
 
@@ -147,6 +150,7 @@
 (eval-when-compile (require 'subr-x))
 (eval-when-compile (require 'epg))      ;For setf accessors.
 (eval-when-compile (require 'inline))   ;For `define-inline'
+(require 'compat)
 (require 'seq)
 
 (require 'tabulated-list)
@@ -1168,7 +1172,7 @@ package-read-from-string
 
 (declare-function lm-package-requires "lisp-mnt" (&optional file))
 (declare-function lm-package-version "lisp-mnt" (&optional file))
-(declare-function lm-website "lisp-mnt" (&optional file))
+(declare-function lm-homepage "lisp-mnt" (&optional file))
 (declare-function lm-keywords-list "lisp-mnt" (&optional file))
 (declare-function lm-maintainers "lisp-mnt" (&optional file))
 (declare-function lm-authors "lisp-mnt" (&optional file))
@@ -1188,7 +1192,7 @@ package-buffer-info
     (let* ((version-info (lm-package-version))
            (pkg-version (package-strip-rcs-id version-info))
            (keywords (lm-keywords-list))
-           (website (lm-website)))
+           (website (lm-homepage)))
       (unless pkg-version
         (if version-info
             (error "Unrecognized package version: %s" version-info)
@@ -4750,8 +4754,11 @@ package-report-bug
           (dolist (ent (get (cdr group) 'custom-group))
             (when (and (custom-variable-p (car ent))
                        (boundp (car ent))
-                       (not (eq (custom--standard-value (car ent))
-                                (default-toplevel-value (car ent)))))
+                       (not (eq
+                             ;; We are not using `custom--standard-value'
+                             ;; to retain compatibility for Emacs 27.
+                             (eval (car (get (car ent) 'standard-value)) t)
+                             (default-toplevel-value (car ent)))))
               (push (car ent) vars))))))
     (dlet ((reporter-prompt-for-summary-p t))
       (reporter-submit-bug-report maint name vars))))
-- 
2.47.2

>> diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
>> index 8d2e2f09108..7a69e680880 100644
>> --- a/lisp/emacs-lisp/package.el
>> +++ b/lisp/emacs-lisp/package.el
>> @@ -5,9 +5,12 @@
>>  ;; Author: Tom Tromey <[email-masked]>
>>  ;;         Daniel Hackney <[email-masked]>
>>  ;; Created: 10 Mar 2007
>> -;; Version: 1.1.0
>> +;; Version: 1.1.1-pre
>>  ;; Keywords: tools
>> -;; Package-Requires: ((tabulated-list "1.0"))
>> +;; Package-Requires: ((emacs "26.1") (compat "29"))
>
> I suggest to require the newest Compat 30.
>
>> +;; This is a GNU ELPA :core package.  Avoid functionality that is not
>> +;; compatible with the version of Emacs recorded above.
>>  
>>  ;; This file is part of GNU Emacs.
>>  
>> @@ -147,6 +150,7 @@
>>  (eval-when-compile (require 'subr-x))
>>  (eval-when-compile (require 'epg))      ;For setf accessors.
>>  (eval-when-compile (require 'inline))   ;For `define-inline'
>> +(require 'compat nil 'noerror)
>>  (require 'seq)
>
> (require 'compat) without the noerror argument should work, since we
> have the compat.el stub in Emacs.
>
>>  (require 'tabulated-list)
>> @@ -1151,7 +1155,8 @@ package--native-compile-async
>>    "Native compile installed package PKG-DESC asynchronously.
>>  This assumes that `pkg-desc' has already been activated with
>>  `package-activate-1'."
>> -  (when (native-comp-available-p)
>> +  (when (and (fboundp 'native-comp-available-p)
>> +             (native-comp-available-p))
>>      (let ((warning-minimum-level :error))
>>        (native-compile-async (package-desc-dir pkg-desc) t))))
>
> `native-comp-available-p' is provided by Compat. You can use it
> directly. It aliases `ignore' on Emacs 27 and older.
>
>>        ;; Insert news if available.
>>        (when news
>> -        (insert "\n" (make-separator-line) "\n"
>> -                (propertize "* News" 'face 'package-help-section-name)
>> +        (insert "\n" (make-separator-line) "\n")
>> +        (when (fboundp 'make-separator-line)
>> +          (insert (make-separator-line) "\n"))
>> +        (insert (propertize "* News" 'face 'package-help-section-name)
>>                  "\n\n")
>>          (insert-file-contents news))
>
> `make-separator-line' is provided by Compat.
>
> Daniel