Subject: Re: bug#62767: 29.0.90; [PATCH] *lisp/emacs-lisp/package.el: set variables after info package

From: lin Sun <[email-masked]>
Date: Mon, 17 Apr 2023 06:13:16 +0000

Hi Philip,

I had researched these three calls with the "require 'info", and
updated the patch for better performance.
The 1 th and 3rd can be rewritten with the new form, but the 2nd one
is necessary, and should not be changed.
Please help review the new attached patch file. Thanks.

Hi Eli,
> And this is the only place in Emacs where we have (require 'FOO) and
> FOO is not necessary for Emacs to start up?
My configuration will load the package.el at startup, so I tracked the
initial packages, and found the "require `info" will take ~1 seconds
on my old PC.
I didn't pay attention to other packages, if I found a heavy one, I'll
post it on the mail list.
From 91a4bdbccc6f3210f43f46891077c57afd128830 Mon Sep 17 00:00:00 2001
From: Lin Sun <[email-masked]>
Date: Tue, 11 Apr 2023 00:00:13 +0000
Subject: [PATCH] *lisp/emacs-lisp/package.el: better way to load the info
 package

---
 lisp/emacs-lisp/package.el | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index f92afe56b7..98153a49c7 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -892,10 +892,9 @@ package-activate-1
         (add-to-list 'load-path (directory-file-name pkg-dir)))
       ;; Add info node.
       (when (file-exists-p (expand-file-name "dir" pkg-dir))
-        ;; FIXME: not the friendliest, but simple.
-        (require 'info)
-        (info-initialize)
-        (add-to-list 'Info-directory-list pkg-dir))
+        (with-eval-after-load 'info
+          (info-initialize)
+          (add-to-list 'Info-directory-list pkg-dir)))
       (push name package-activated-list)
       ;; Don't return nil.
       t)))
@@ -4427,7 +4426,7 @@ package-quickstart-refresh
   "(Re)Generate the `package-quickstart-file'."
   (interactive)
   (package-initialize 'no-activate)
-  (require 'info)
+  (require 'info) ; insure Info-directory-list avaliable for package-activate
   (let ((package--quickstart-pkgs ())
         ;; Pretend we haven't activated anything yet!
         (package-activated-list ())
@@ -4472,10 +4471,10 @@ package-quickstart-refresh
           (current-buffer))
       (let ((info-dirs (butlast Info-directory-list)))
         (when info-dirs
-          (pp `(progn (require 'info)
-                      (info-initialize)
-                      (setq Info-directory-list
-                            (append ',info-dirs Info-directory-list)))
+          (pp `(with-eval-after-load 'info
+                 (info-initialize)
+                 (setq Info-directory-list
+                       (append ',info-dirs Info-directory-list)))
               (current-buffer))))
       ;; Use `\s' instead of a space character, so this code chunk is not
       ;; mistaken for an actual file-local section of package.el.
-- 
2.20.5