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

From: Phil Sainty <[email-masked]>
Date: Mon, 07 Sep 2015 01:18:46 +1200

...and I'd copied and pasted an unwanted paren from the original line,
so that patch was broken anyway. Now fixed and tested.

In addition I realised the comments needed tweaking to match the change;
and I spotted another (related) bug whereby the code which looks for
calls to (package-initialize) doesn't take its optional argument into
account, so I've modified those searches too.

>From c8287af963e5de462c572c7b0a95554fb96bba7d Mon Sep 17 00:00:00 2001
From: Phil Sainty <[email-masked]>
Date: Sun, 6 Sep 2015 23:05:34 +1200
Subject: [PATCH] Disable package-enable-at-startup when forcing
 package-initialize

---
 lisp/emacs-lisp/package.el | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index d4a2f02..3b70880 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -1833,12 +1833,12 @@ add a call to it along with some explanatory comments."
                     (save-restriction
                       (widen)
                       (goto-char (point-min))
-                      (search-forward "(package-initialize)" nil 'noerror))))
+                      (re-search-forward "(package-initialize\\_>" nil 'noerror))))
               ;; Don't visit the file if we don't have to.
               (with-temp-buffer
                 (insert-file-contents user-init-file)
                 (goto-char (point-min))
-                (search-forward "(package-initialize)" nil 'noerror)))))
+                (re-search-forward "(package-initialize\\_>" nil 'noerror)))))
       (unless contains-init
         (with-current-buffer (or buffer
                                  (let ((delay-mode-hooks t))
@@ -1853,9 +1853,10 @@ add a call to it along with some explanatory comments."
               (insert
                "\n"
                ";; Added by Package.el.  This must come before configurations of\n"
-               ";; installed packages.  Don't delete this line.  If you don't want it,\n"
-               ";; just comment it out by adding a semicolon to the start of the line.\n"
-               ";; You may delete these explanatory comments.\n"
+               ";; installed packages.  Don't delete these lines.  If you don't want\n"
+               ";; them, just comment them out by adding a semicolon to the start of\n"
+               ";; each line.  You may delete these explanatory comments.\n"
+               "(setq package-enable-at-startup nil)\n"
                "(package-initialize)\n")
               (unless (looking-at-p "$")
                 (insert "\n"))
-- 
2.1.0