emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 2db5757: Various follow-ups for early init file cha


From: Eli Zaretskii
Subject: [Emacs-diffs] master 2db5757: Various follow-ups for early init file changes
Date: Mon, 19 Mar 2018 04:46:00 -0400 (EDT)

branch: master
commit 2db57579b08ac99c464b6d3698648b3167fc5d55
Author: Radon Rosborough <address@hidden>
Commit: Eli Zaretskii <address@hidden>

    Various follow-ups 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
    https://lists.nongnu.org/archive/html/bug-gnu-emacs/2018-02/msg00827.html
    
    * 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
    https://lists.gnu.org/archive/html/emacs-devel/2018-02/msg00632.html
    (package-load-list): Refer to "making available" rather than "loading"
    for packages.  See
    https://lists.gnu.org/archive/html/emacs-devel/2018-02/msg00298.html
    
    * 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
    https://lists.gnu.org/archive/html/emacs-devel/2018-02/msg00545.html
    
    * lisp/emacs-lisp/package.el (package-initialize): Issue a warning
    if called twice.
    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
---
 doc/emacs/custom.texi      | 10 +++++++---
 lisp/emacs-lisp/package.el | 40 ++++++++++++++++++++++++++++------------
 lisp/startup.el            | 18 +++++++++---------
 3 files changed, 44 insertions(+), 24 deletions(-)

diff --git a/doc/emacs/custom.texi b/doc/emacs/custom.texi
index be73d7a..a69888c 100644
--- a/doc/emacs/custom.texi
+++ b/doc/emacs/custom.texi
@@ -2607,9 +2607,13 @@ desirable to have customizations that take effect during 
Emacs startup
 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}.
address@hidden Installation}.
+you can customize variables that affect the package initialization
+process, such as @code{package-enable-at-startup},
address@hidden, 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 999e0d0..1edc06d 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -161,29 +161,34 @@
 ;;; 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")
@@ -1439,10 +1444,21 @@ If optional arg NO-ACTIVATE is non-nil, don't activate 
packages.
 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)
diff --git a/lisp/startup.el b/lisp/startup.el
index 4105c1d..2669342 100644
--- a/lisp/startup.el
+++ b/lisp/startup.el
@@ -1115,6 +1115,15 @@ please check its value")
     (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 @@ please check its value")
     (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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]