From 34c75359126e78367e4542a39b4b687c8955e1c6 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Sat, 14 Feb 2015 11:13:29 -0200 Subject: [PATCH] emacs-lisp/package.el: Move the compatibility-table building logic. --- lisp/ChangeLog | 8 ++++++++ lisp/emacs-lisp/package.el | 19 +++++++++++++------ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 24cf80a4093..42b386f3f22 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,11 @@ +2015-02-14 Artur Malabarba + + * emacs-lisp/package.el (package-read-all-archive-contents): Don't + build the compatibility table. + (package-refresh-contents, package-initialize): Do build the + compatibility table. + (package--build-compatibility-table): New function. + 2015-02-14 Stefan Monnier * emacs-lisp/cl-preloaded.el (cl-struct-define): Register as children diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index d8b4595b6e6..64a646a9896 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el @@ -1144,10 +1144,7 @@ Will throw an error if the archive version is too new." If successful, set `package-archive-contents'." (setq package-archive-contents nil) (dolist (archive package-archives) - (package-read-archive-contents (car archive))) - ;; Build compat table. - (setq package--compatibility-table (make-hash-table :test 'eq)) - (package--mapc #'package--add-to-compatibility-table)) + (package-read-archive-contents (car archive)))) (defun package-read-archive-contents (archive) "Re-read archive contents for ARCHIVE. @@ -1691,6 +1688,12 @@ similar to an entry in `package-alist'. Save the cached copy to (epg-import-keys-from-file context file) (message "Importing %s...done" (file-name-nondirectory file)))) +(defun package--build-compatibility-table () + "Build `package--compatibility-table' with `package--mapc'." + ;; Build compat table. + (setq package--compatibility-table (make-hash-table :test 'eq)) + (package--mapc #'package--add-to-compatibility-table)) + ;;;###autoload (defun package-refresh-contents () "Download the ELPA archive description if needed. @@ -1713,7 +1716,8 @@ makes them available for download." (package--download-one-archive archive "archive-contents") (error (message "Failed to download `%s' archive." (car archive))))) - (package-read-all-archive-contents)) + (package-read-all-archive-contents) + (package--build-compatibility-table)) (defun package--find-non-dependencies () "Return a list of installed packages which are not dependencies. @@ -1742,7 +1746,10 @@ If optional arg NO-ACTIVATE is non-nil, don't activate packages." (unless no-activate (dolist (elt package-alist) (package-activate (car elt)))) - (setq package--initialized t)) + (setq package--initialized t) + ;; This uses `package--mapc' so it must be called after + ;; `package--initialized' is t. + (package--build-compatibility-table)) (defun package--add-to-compatibility-table (pkg) "If PKG is compatible (without dependencies), add to the compatibility table. -- 2.11.4.GIT