Subject: Re: bug#21423: 24.5; (package-initialize) added to init.el without (setq package-enable-at-startup nil)

From: Artur Malabarba <[email-masked]>
Date: Sun, 6 Sep 2015 13:59:22 +0100

I think I'd rather do the patch below.
This will not only help the situation where we automatically add
`(package-initialize)' to the init file, but it will also help those
users who have manually added it without knowing about this caveat.

Does anyone foresee problems with this?

>From 94dafb46f7f258cb19929efc8bb9c123f428bcc5 Mon Sep 17 00:00:00 2001
From: Artur Malabarba <[email-masked]>
Date: Sun, 6 Sep 2015 13:52:54 +0100
Subject: [PATCH] * lisp/emacs-lisp/package.el (package-initialize): Set
 enable-at-startup

When `package-initialize' is called as part of loading the init file,
the user probably doesn't want it to be called again afterwards. In this
situation, `package-initialize' now sets `package-enable-at-startup' to
nil to prevent that. The user can have the old behaviour by setting this
variable to t after the call to `package-initialize'.  (Bug#21423)
---
 lisp/emacs-lisp/package.el | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index 7c4f21f..57b35ca 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -1378,7 +1378,9 @@ it to the file."
   (if (equal user-init-file load-file-name)
       ;; If `package-initialize' is being called as part of loading
       ;; the init file, it's obvious we don't need to ensure-init.
-      (setq package--init-file-ensured t)
+      (setq package--init-file-ensured t
+            ;; And likely we don't need to run it again after init.
+            package-enable-at-startup nil)
     (package--ensure-init-file))
   (package-load-all-descriptors)
   (package-read-all-archive-contents)
-- 
2.5.1