unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Radon Rosborough <radon.neon@gmail.com>
To: Noam Postavsky <npostavs@gmail.com>
Cc: emacs-devel <emacs-devel@gnu.org>
Subject: Re: [PATCH] Various fixes for early init file changes
Date: Thu, 8 Mar 2018 22:07:05 -0800	[thread overview]
Message-ID: <CADB4rJFVWH615DMzBnPaqrQUf5yWfbygHeN3q2Oa0UTo9BgC_g@mail.gmail.com> (raw)
In-Reply-To: <CAM-tV-9id1QfuyjipxNCUihsegOJxRd2b5s==ca-R=FGZ-w+SA@mail.gmail.com>

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

> the warning could be suppressed by adding '(package
> reinitialize) to warning-suppress-types instead of creating a new
> custom option.

I just typed up a whole email explaining why it would be better for
novice users if the process for this was not so complicated.

Then I realized that novice users should not be suppressing this
warning, and should instead be taking the extra call to
`package-initialize' out of their init-files.

As a result, I now wholeheartedly agree with your idea, and I've
attached a revised patch. Thanks for the feedback.

[-- Attachment #2: 0001-Warn-if-package-initialize-is-called-twice.patch --]
[-- Type: application/octet-stream, Size: 1770 bytes --]

From 53067f7b3d471ff0e993293bebe5f865ca69b43a Mon Sep 17 00:00:00 2001
From: Radon Rosborough <radon.neon@gmail.com>
Date: Fri, 2 Mar 2018 21:06:53 -0800
Subject: [PATCH] Warn if `package-initialize' is called twice

* lisp/emacs-lisp/package.el (package-initialize): Conditionally
signal a warning.

See: https://lists.gnu.org/archive/html/emacs-devel/2018-02/msg00626.html
     https://lists.gnu.org/archive/html/emacs-devel/2018-03/msg00301.html
---
 lisp/emacs-lisp/package.el | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index 6c307cc37c..1edc06d024 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -1444,10 +1444,21 @@ package-initialize
 If called as part of loading `user-init-file', set
 `package-enable-at-startup' to nil, to prevent accidentally
 loading packages twice.
+
 It is not necessary to adjust `load-path' or `require' the
 individual packages after calling `package-initialize' -- this is
-taken care of by `package-initialize'."
+taken care of by `package-initialize'.
+
+If `package-initialize' is called twice during Emacs startup,
+signal a warning, since this is a bad idea except in highly
+advanced use cases.  To suppress the warning, remove the
+superfluous call to `package-initialize' from your init-file.  If
+you have code which must run before `package-initialize', put
+that code in the early init-file."
   (interactive)
+  (when (and package--initialized (not after-init-time))
+    (lwarn '(package reinitialization) :warning
+           "Unnecessary call to `package-initialize' in init file"))
   (setq package-alist nil)
   (setq package-enable-at-startup nil)
   (package-load-all-descriptors)
-- 
2.16.2


  reply	other threads:[~2018-03-09  6:07 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-03  5:31 [PATCH] Various fixes for early init file changes Radon Rosborough
2018-03-03 17:26 ` Clément Pit-Claudel
2018-03-03 18:02   ` Radon Rosborough
2018-03-09  1:30 ` Noam Postavsky
2018-03-09  6:07   ` Radon Rosborough [this message]
2018-03-09 13:16     ` Noam Postavsky
2018-03-19  8:46     ` Eli Zaretskii
2018-03-19 10:06     ` Robert Pluim
2018-03-19 16:20       ` Radon Rosborough
2018-03-19 16:29         ` Stefan Monnier
2018-03-19 16:34           ` Radon Rosborough
2018-03-19 16:38             ` Stefan Monnier
2018-03-19 20:14               ` Radon Rosborough
2018-03-19 17:02         ` Drew Adams
2018-03-19 20:16           ` Radon Rosborough
2018-03-19 22:14             ` Clément Pit-Claudel
2018-03-20  5:44               ` Radon Rosborough
2018-03-20  5:53                 ` Clément Pit-Claudel
2018-03-20 16:08                 ` Andy Moreton
2018-03-20 16:36                   ` Radon Rosborough
2018-03-20 16:42                     ` Robert Pluim
2018-03-20 19:44                       ` Radon Rosborough
2018-03-21  9:00                         ` Robert Pluim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CADB4rJFVWH615DMzBnPaqrQUf5yWfbygHeN3q2Oa0UTo9BgC_g@mail.gmail.com \
    --to=radon.neon@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=npostavs@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).