unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] Various fixes for early init file changes
@ 2018-03-03  5:31 Radon Rosborough
  2018-03-03 17:26 ` Clément Pit-Claudel
  2018-03-09  1:30 ` Noam Postavsky
  0 siblings, 2 replies; 23+ messages in thread
From: Radon Rosborough @ 2018-03-03  5:31 UTC (permalink / raw)
  To: emacs-devel

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

Hello all,

Attached are three patches:

1. Fix `Info-default-directory-list' error during init. This moves the
running of `custom-reevaluate-setting' on predefined variables to
earlier during startup, so that `package-initialize' can access
`Info-default-directory-list'. Without this patch, warnings are
emitted during startup if packages with Info manuals are installed.
2. Documentation fixes for early init file changes. This clarifies in
the Emacs manual what variables need to be customized in the early
init file, and fixes a couple of docstrings in package.el that still
referred to "loading" packages rather than "making them available".
3. Warn if `package-initialize' is called twice. This causes Emacs to
emit a warning, by default, if `package-initialize' is called twice
during init. I expect this to cause people a lot of warnings, but I
think this is a good thing, since the alternative (currently) is a
pretty bad performance regression if people leave a now-superfluous
extra call to `package-initialize' in their init files. Plus, the fix
is trivial: just delete the extra call. For people who really do want
to call `package-initialize' twice for some reason, there is a new
variable `package-warn-on-reinitialization' which can be customized to
disable the warning.

I believe this addresses all the problems people have noticed with the
changes related to `package-initialize' and the early init file.
Please let me know if I missed anything. Thanks for all the feedback
and support!

Best regards,
Radon Rosborough

[-- Attachment #2: 0001-Fix-Info-default-directory-list-error-during-init.patch --]
[-- Type: application/octet-stream, Size: 2197 bytes --]

From b61d09e08302c7441e1f2301287b5fcff4303ecd Mon Sep 17 00:00:00 2001
From: Radon Rosborough <radon.neon@gmail.com>
Date: Fri, 2 Mar 2018 20:55:48 -0800
Subject: [PATCH] Fix Info-default-directory-list error during init

* lisp/startup.el (command-line): Call `custom-reevaluate-setting' on
predefined variables before loading the early init file and before
`package-initialize' is called.  This prevents
`Info-default-directory-list' from being unbound when
`package-initialize' tries to access it during startup.  See [1].

[1]: https://lists.gnu.org/archive/html/emacs-devel/2018-02/msg00545.html
---
 lisp/startup.el | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/lisp/startup.el b/lisp/startup.el
index 4105c1db2d..2669342eda 100644
--- a/lisp/startup.el
+++ b/lisp/startup.el
@@ -1115,6 +1115,15 @@ command-line
     (and command-line-args
          (setcdr command-line-args args)))
 
+  ;; Re-evaluate predefined variables whose initial value depends on
+  ;; the runtime context.
+  (let (current-load-list) ; c-r-s may call defvar, and hence LOADHIST_ATTACH
+    (mapc 'custom-reevaluate-setting
+          ;; Initialize them in the same order they were loaded, in case there
+          ;; are dependencies between them.
+          (prog1 (nreverse custom-delayed-init-variables)
+            (setq custom-delayed-init-variables nil))))
+
   ;; Warn for invalid user name.
   (when init-file-user
     (if (string-match "[~/:\n]" init-file-user)
@@ -1245,15 +1254,6 @@ command-line
     (startup--setup-quote-display)
     (setq internal--text-quoting-flag t))
 
-  ;; Re-evaluate predefined variables whose initial value depends on
-  ;; the runtime context.
-  (let (current-load-list) ; c-r-s may call defvar, and hence LOADHIST_ATTACH
-    (mapc 'custom-reevaluate-setting
-          ;; Initialize them in the same order they were loaded, in case there
-          ;; are dependencies between them.
-          (prog1 (nreverse custom-delayed-init-variables)
-            (setq custom-delayed-init-variables nil))))
-
   (normal-erase-is-backspace-setup-frame)
 
   ;; Register default TTY colors for the case the terminal hasn't a
-- 
2.16.2


[-- Attachment #3: 0001-Documentation-fixes-for-early-init-file-changes.patch --]
[-- Type: application/octet-stream, Size: 4648 bytes --]

From e3b57bedf521b814d32c4fe3698b5ffc726d8e22 Mon Sep 17 00:00:00 2001
From: Radon Rosborough <radon.neon@gmail.com>
Date: Fri, 2 Mar 2018 20:33:34 -0800
Subject: [PATCH] Documentation fixes for early init file changes

* doc/emacs/custom.texi (Early Init File): Add more details about
which variables must be set in the early init file rather than the
regular init file.  See [1].

* lisp/emacs-lisp/package.el (package-enable-at-startup): Update
docstring to note that packages are now made available before loading
the init file, rather than afterwards.  See [2].
(package-load-list): Refer to "making available" rather than "loading"
for packages.  See [3].

[1]: https://lists.nongnu.org/archive/html/bug-gnu-emacs/2018-02/msg00827.html
[2]: https://lists.gnu.org/archive/html/emacs-devel/2018-02/msg00632.html
[3]: https://lists.gnu.org/archive/html/emacs-devel/2018-02/msg00298.html
---
 doc/emacs/custom.texi      | 11 ++++++++---
 lisp/emacs-lisp/package.el | 27 ++++++++++++++++-----------
 2 files changed, 24 insertions(+), 14 deletions(-)

diff --git a/doc/emacs/custom.texi b/doc/emacs/custom.texi
index 0905ae7bb1..ca842bd1e1 100644
--- a/doc/emacs/custom.texi
+++ b/doc/emacs/custom.texi
@@ -2606,9 +2606,14 @@ Early Init File
 earlier than the normal init file is processed.  Such customizations
 can be put in the early init file, @file{~/.emacs.d/early-init.el}.
 This file is loaded before the package system is initialized, so in it
-you can customize variables that affect the initialization process,
-such as @code{package-enable-at-startup} and @code{package-load-list}.
-@xref{Package Installation}.
+you can customize variables that affect the initialization process
+(i.e. @code{package-initialize}), such as
+@code{package-enable-at-startup}, @code{package-load-list}, and
+@code{package-user-dir}.  Note that variables like
+@code{package-archives} which only affect the installation of new
+packages, and not the process of making already-installed packages
+available, may be customized in the regular init file.  @xref{Package
+Installation}.
 
   For more information on the early init file, @pxref{Init File,,,
 elisp, The Emacs Lisp Reference Manual}.
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index 999e0d0752..6c307cc37c 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -161,29 +161,34 @@ package
 ;;; Customization options
 ;;;###autoload
 (defcustom package-enable-at-startup t
-  "Whether to activate installed packages when Emacs starts.
-If non-nil, packages are activated after reading the init file
-and before `after-init-hook'.  Activation is not done if
-`user-init-file' is nil (e.g. Emacs was started with \"-q\").
+  "Whether to make installed packages available when Emacs starts.
+If non-nil, packages are made available before reading the init
+file (but after reading the early init file).  This means that if
+you wish to set this variable, you must do so in the early init
+file.  Regardless of the value of this variable, packages are not
+made available if `user-init-file' is nil (e.g. Emacs was started
+with \"-q\").
 
 Even if the value is nil, you can type \\[package-initialize] to
-activate the package system at any time."
+make installed packages available at any time, or you can
+call (package-initialize) in your init-file."
   :type 'boolean
   :version "24.1")
 
 (defcustom package-load-list '(all)
-  "List of packages for `package-initialize' to load.
+  "List of packages for `package-initialize' to make available.
 Each element in this list should be a list (NAME VERSION), or the
-symbol `all'.  The symbol `all' says to load the latest installed
-versions of all packages not specified by other elements.
+symbol `all'.  The symbol `all' says to make available the latest
+installed versions of all packages not specified by other
+elements.
 
 For an element (NAME VERSION), NAME is a package name (a symbol).
 VERSION should be t, a string, or nil.
-If VERSION is t, the most recent version is activated.
-If VERSION is a string, only that version is ever loaded.
+If VERSION is t, the most recent version is made available.
+If VERSION is a string, only that version is ever made available.
  Any other version, even if newer, is silently ignored.
  Hence, the package is \"held\" at that version.
-If VERSION is nil, the package is not loaded (it is \"disabled\")."
+If VERSION is nil, the package is not made available (it is \"disabled\")."
   :type '(repeat (choice (const all)
                          (list :tag "Specific package"
                                (symbol :tag "Package name")
-- 
2.16.2


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

From 678354ea2159aa0fdf39a5219d112eaebcad4f6e 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-warn-on-reinitialization): New
variable.
(package-initialize): Conditionally signal a warning.

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

diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index 6c307cc37c..7bc369c95d 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -175,6 +175,13 @@ package-enable-at-startup
   :type 'boolean
   :version "24.1")
 
+(defcustom package-warn-on-reinitialization t
+  "Whether to warn when `package-initialize' is called twice.
+If non-nil, and `package-initialize' is called more than once
+before Emacs startup has completed, signal a warning."
+  :type 'boolean
+  :version "27.1")
+
 (defcustom package-load-list '(all)
   "List of packages for `package-initialize' to make available.
 Each element in this list should be a list (NAME VERSION), or the
@@ -1448,6 +1455,10 @@ package-initialize
 individual packages after calling `package-initialize' -- this is
 taken care of by `package-initialize'."
   (interactive)
+  (when (and package--initialized
+             (not after-init-time)
+             package-warn-on-reinitialization)
+    (warn "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


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

end of thread, other threads:[~2018-03-21  9:00 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

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