From 066b26d6c47d1384d5ed3ce09c6379a9df350256 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Sun, 6 Sep 2015 13:52:54 +0100 Subject: * 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) * doc/emacs/package.texi (Package Installation): Document it * doc/lispref/package.texi (Packaging Basics): Document it * etc/NEWS: Document it --- lisp/emacs-lisp/package.el | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'lisp/emacs-lisp/package.el') diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index 4d3678a1034..23247d78019 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el @@ -1372,13 +1372,18 @@ If successful, set `package-archive-contents'." The variable `package-load-list' controls which packages to load. If optional arg NO-ACTIVATE is non-nil, don't activate packages. If `user-init-file' does not mention `(package-initialize)', add -it to the file." +it to the file. +If called as part of loading `user-init-file', set +`package-enable-at-startup' to nil, to prevent accidentally +loading packages twice." (interactive) (setq package-alist nil) (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) -- cgit v1.2.3