]> git.eshelyaron.com Git - emacs.git/commitdiff
Avoid changing value of defcustom package-enable-at-startup
authorStefan Kangas <stefankangas@gmail.com>
Wed, 6 Nov 2019 00:19:23 +0000 (01:19 +0100)
committerStefan Kangas <stefankangas@gmail.com>
Wed, 6 Nov 2019 00:19:23 +0000 (01:19 +0100)
* lisp/emacs-lisp/package.el (package--activated): New variable to
avoid changing value of defcustom 'package-enable-at-startup'.
(package-initialize): Don't set 'package-enable-at-startup'.
(package-initialize, package-activate-all): Set 'package--activated'
instead of 'package-enable-at-startup'.
(package--initialized): Add doc string.

* lisp/startup.el (command-line): Check if 'package--activated' is
non-nil before activating packages.

* doc/lispref/package.texi (Packaging Basics): Update docs.

doc/lispref/package.texi
lisp/emacs-lisp/package.el
lisp/startup.el

index 57f4cbc5db31df7404c8ad3e0a9fa6a8bca0fa72..236855bdf861500f3a0e7e818209001a2ad860ef 100644 (file)
@@ -117,10 +117,7 @@ init file.
 This function makes the packages available to the current session.
 The user option @code{package-load-list} specifies which packages to
 make available; by default, all installed packages are made available.
-If called during startup, this function also sets
-@code{package-enable-at-startup} to @code{nil}, to avoid accidentally
-evaluating package autoloads more than once.  @xref{Package
-Installation,,, emacs, The GNU Emacs Manual}.
+@xref{Package Installation,,, emacs, The GNU Emacs Manual}.
 
 In most cases, you should not need to call @code{package-activate-all},
 as this is done automatically during startup.  Simply make sure to put
index 3c14b50f3ed3a75ca873948688ad01a5bf91c7e4..b7a528dac49b1ee8af8cba7b848e83b1d8fd295f 100644 (file)
@@ -1543,20 +1543,24 @@ If successful, set or update `package-archive-contents'."
   (dolist (archive package-archives)
     (package-read-archive-contents (car archive))))
 
+\f
 ;;;; Package Initialize
 ;; A bit of a milestone.  This brings together some of the above
 ;; sections and populates all relevant lists of packages from contents
 ;; available on disk.
-(defvar package--initialized nil)
+
+(defvar package--initialized nil
+  "Non-nil if `package-initialize' has been run.")
+
+;;;###autoload
+(defvar package--activated nil
+  "Non-nil if `package-activate-all' has been run.")
 
 ;;;###autoload
 (defun package-initialize (&optional no-activate)
   "Load Emacs Lisp packages, and activate them.
 The variable `package-load-list' controls which packages to load.
 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
@@ -1573,7 +1577,6 @@ that code in the early init-file."
     (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)
   (package-read-all-archive-contents)
   (setq package--initialized t)
@@ -1589,7 +1592,7 @@ that code in the early init-file."
 (defun package-activate-all ()
   "Activate all installed packages.
 The variable `package-load-list' controls which packages to load."
-  (setq package-enable-at-startup nil)
+  (setq package--activated t)
   (if (file-readable-p package-quickstart-file)
       ;; Skip load-source-file-function which would slow us down by a factor
       ;; 2 (this assumes we were careful to save this file so it doesn't need
index 30f1a253ee65371f3441b43729d02346983cbc91..651224fe6c46bf56f0f18ebb5aee54cab4093704 100644 (file)
@@ -1013,6 +1013,8 @@ the `--debug-init' option to view a complete error backtrace."
     (when debug-on-error-should-be-set
       (setq debug-on-error debug-on-error-from-init-file))))
 
+(defvar package--activated nil)
+
 (defun command-line ()
   "A subroutine of `normal-top-level'.
 Amongst another things, it parses the command-line arguments."
@@ -1233,6 +1235,7 @@ please check its value")
   ;; If any package directory exists, initialize the package system.
   (and user-init-file
        package-enable-at-startup
+       (not package--activated)
        (catch 'package-dir-found
         (let (dirs)
           (if (boundp 'package-directory-list)