unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#21423: 24.5; (package-initialize) added to init.el without (setq package-enable-at-startup nil)
@ 2015-09-06 11:01 Phil Sainty
  2015-09-06 11:10 ` Phil Sainty
  0 siblings, 1 reply; 8+ messages in thread
From: Phil Sainty @ 2015-09-06 11:01 UTC (permalink / raw)
  To: 21423

[-- Attachment #1: Type: text/plain, Size: 827 bytes --]

package--ensure-init-file inserts (package-initialize) into the user's
init file, but it does not also insert (setq package-enable-at-startup nil),
which means that (according to (emacs) Package Installation) Emacs will
re-initialize the packages post-init:

 > In some circumstances, you may want to load packages explicitly in
 > your init file (usually because some other code in your init file
 > depends on a package).  In that case, your init file should call the
 > function ‘package-initialize’.  It is up to you to ensure that
 > relevant user options, such as ‘package-load-list’ (see below), are
 > set up prior to the ‘package-initialize’ call.  You should also set
 > ‘package-enable-at-startup’ to ‘nil’, to avoid loading the packages
 > again after processing the init file.



[-- Attachment #2: 0001-Disable-package-enable-at-startup-when-forcing-packa.patch --]
[-- Type: text/x-patch, Size: 978 bytes --]

From 297f2d5555ba0efb0afc3412f49d1c728ebb5700 Mon Sep 17 00:00:00 2001
From: Phil Sainty <phil@orcon.net.nz>
Date: Sun, 6 Sep 2015 22:48:40 +1200
Subject: [PATCH] Disable package-enable-at-startup when forcing
 package-initialize

---
 lisp/emacs-lisp/package.el | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index d4a2f02..baa4ab6 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -1856,6 +1856,7 @@ add a call to it along with some explanatory comments."
                ";; 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"
+               "(setq package-enable-at-startup nil)\n")
                "(package-initialize)\n")
               (unless (looking-at-p "$")
                 (insert "\n"))
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* bug#21423: 24.5; (package-initialize) added to init.el without (setq package-enable-at-startup nil)
  2015-09-06 11:01 bug#21423: 24.5; (package-initialize) added to init.el without (setq package-enable-at-startup nil) Phil Sainty
@ 2015-09-06 11:10 ` Phil Sainty
  2015-09-06 12:59   ` Artur Malabarba
  2015-09-06 13:18   ` Phil Sainty
  0 siblings, 2 replies; 8+ messages in thread
From: Phil Sainty @ 2015-09-06 11:10 UTC (permalink / raw)
  To: 21423

[-- Attachment #1: Type: text/plain, Size: 112 bytes --]

I managed to configure an incorrect email address for myself.

I've attached the corrected patch to this reply.

[-- Attachment #2: 0001-Disable-package-enable-at-startup-when-forcing-packa.patch --]
[-- Type: text/x-patch, Size: 981 bytes --]

From 2931c2e427a83d6c5ddcc1853626e4f11f25b6bd Mon Sep 17 00:00:00 2001
From: Phil Sainty <psainty@orcon.net.nz>
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 | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index d4a2f02..baa4ab6 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -1856,6 +1856,7 @@ add a call to it along with some explanatory comments."
                ";; 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"
+               "(setq package-enable-at-startup nil)\n")
                "(package-initialize)\n")
               (unless (looking-at-p "$")
                 (insert "\n"))
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* bug#21423: 24.5; (package-initialize) added to init.el without (setq package-enable-at-startup nil)
  2015-09-06 11:10 ` Phil Sainty
@ 2015-09-06 12:59   ` Artur Malabarba
  2015-09-06 13:29     ` Phil Sainty
  2015-09-06 13:18   ` Phil Sainty
  1 sibling, 1 reply; 8+ messages in thread
From: Artur Malabarba @ 2015-09-06 12:59 UTC (permalink / raw)
  To: Phil Sainty; +Cc: 21423

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 <bruce.connor.am@gmail.com>
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





^ permalink raw reply related	[flat|nested] 8+ messages in thread

* bug#21423: 24.5; (package-initialize) added to init.el without (setq package-enable-at-startup nil)
  2015-09-06 11:10 ` Phil Sainty
  2015-09-06 12:59   ` Artur Malabarba
@ 2015-09-06 13:18   ` Phil Sainty
  1 sibling, 0 replies; 8+ messages in thread
From: Phil Sainty @ 2015-09-06 13:18 UTC (permalink / raw)
  To: 21423

[-- Attachment #1: Type: text/plain, Size: 386 bytes --]

...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.


[-- Attachment #2: 0001-Disable-package-enable-at-startup-when-forcing-packa.patch --]
[-- Type: text/x-patch, Size: 2230 bytes --]

From c8287af963e5de462c572c7b0a95554fb96bba7d Mon Sep 17 00:00:00 2001
From: Phil Sainty <psainty@orcon.net.nz>
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


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* bug#21423: 24.5; (package-initialize) added to init.el without (setq package-enable-at-startup nil)
  2015-09-06 12:59   ` Artur Malabarba
@ 2015-09-06 13:29     ` Phil Sainty
  2015-09-06 15:21       ` Artur Malabarba
  0 siblings, 1 reply; 8+ messages in thread
From: Phil Sainty @ 2015-09-06 13:29 UTC (permalink / raw)
  To: bruce.connor.am; +Cc: 21423

On 07/09/15 00:59, Artur Malabarba wrote:
 > 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?

I did always think it odd that your proposed change wasn't how it
worked to begin with.

That said, this change would seem to be an issue for anyone who is
performing a partial initialisation in their init file (for specific
packages), and then depending on the default initialisation to deal
with the remainder, post-init.

I can only imagine that's a very small proportion of users indeed,
but I presume the scenario ought to be considered (even if only for
the purposes of documenting it in NEWS).







^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#21423: 24.5; (package-initialize) added to init.el without (setq package-enable-at-startup nil)
  2015-09-06 13:29     ` Phil Sainty
@ 2015-09-06 15:21       ` Artur Malabarba
  2015-09-06 22:33         ` Stefan Monnier
  0 siblings, 1 reply; 8+ messages in thread
From: Artur Malabarba @ 2015-09-06 15:21 UTC (permalink / raw)
  To: Phil Sainty; +Cc: 21423

2015-09-06 14:29 GMT+01:00 Phil Sainty <psainty@orcon.net.nz>:
> On 07/09/15 00:59, Artur Malabarba wrote:
>> 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?
>
> I did always think it odd that your proposed change wasn't how it
> worked to begin with.
>
> That said, this change would seem to be an issue for anyone who is
> performing a partial initialisation in their init file (for specific
> packages), and then depending on the default initialisation to deal
> with the remainder, post-init.
>
> I can only imagine that's a very small proportion of users indeed,
> but I presume the scenario ought to be considered (even if only for
> the purposes of documenting it in NEWS).

Yes, they'll have to add (setq package-enable-at-startup t) after
calling initialize. That should definitely go in the NEWS.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#21423: 24.5; (package-initialize) added to init.el without (setq package-enable-at-startup nil)
  2015-09-06 15:21       ` Artur Malabarba
@ 2015-09-06 22:33         ` Stefan Monnier
  2015-09-07 10:26           ` Artur Malabarba
  0 siblings, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2015-09-06 22:33 UTC (permalink / raw)
  To: Artur Malabarba; +Cc: Phil Sainty, 21423

>> That said, this change would seem to be an issue for anyone who is
>> performing a partial initialisation in their init file (for specific
>> packages), and then depending on the default initialisation to deal
>> with the remainder, post-init.
>> 
>> I can only imagine that's a very small proportion of users indeed,
>> but I presume the scenario ought to be considered (even if only for
>> the purposes of documenting it in NEWS).

> Yes, they'll have to add (setq package-enable-at-startup t) after
> calling initialize. That should definitely go in the NEWS.

I have a hard time imagining many users doing that.  As a user, if I'm
picky enough to try and do a partial initialization in my init file,
I'll probably also want to do the final full initialization explicitly
in my init file.


        Stefan





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#21423: 24.5; (package-initialize) added to init.el without (setq package-enable-at-startup nil)
  2015-09-06 22:33         ` Stefan Monnier
@ 2015-09-07 10:26           ` Artur Malabarba
  0 siblings, 0 replies; 8+ messages in thread
From: Artur Malabarba @ 2015-09-07 10:26 UTC (permalink / raw)
  To: 21423-done

Pushed the patch above plus some documentation in the NEWS and the manual.

2015-09-06 23:33 GMT+01:00 Stefan Monnier <monnier@iro.umontreal.ca>:
>>> That said, this change would seem to be an issue for anyone who is
>>> performing a partial initialisation in their init file (for specific
>>> packages), and then depending on the default initialisation to deal
>>> with the remainder, post-init.
>>>
>>> I can only imagine that's a very small proportion of users indeed,
>>> but I presume the scenario ought to be considered (even if only for
>>> the purposes of documenting it in NEWS).
>
>> Yes, they'll have to add (setq package-enable-at-startup t) after
>> calling initialize. That should definitely go in the NEWS.
>
> I have a hard time imagining many users doing that.  As a user, if I'm
> picky enough to try and do a partial initialization in my init file,
> I'll probably also want to do the final full initialization explicitly
> in my init file.

Now that it's pushed, I'm sure _someone_ will be affected by this and
will politely let us know. :)





^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-09-07 10:26 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-06 11:01 bug#21423: 24.5; (package-initialize) added to init.el without (setq package-enable-at-startup nil) Phil Sainty
2015-09-06 11:10 ` Phil Sainty
2015-09-06 12:59   ` Artur Malabarba
2015-09-06 13:29     ` Phil Sainty
2015-09-06 15:21       ` Artur Malabarba
2015-09-06 22:33         ` Stefan Monnier
2015-09-07 10:26           ` Artur Malabarba
2015-09-06 13:18   ` Phil Sainty

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).