diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index 438af781393..3800d8fa56d 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el @@ -2095,7 +2095,7 @@ package-archive-base "Return the package described by DESC." (cdr (assoc (package-desc-archive desc) package-archives))) -(defun package-install-from-archive (pkg-desc) +(defun package-install-from-archive-1 (pkg-desc) "Download and install a package defined by PKG-DESC." ;; This won't happen, unless the archive is doing something wrong. (when (eq (package-desc-kind pkg-desc) 'dir) @@ -2141,6 +2141,15 @@ package-install-from-archive package-alist)))) (setf (package-desc-signed (car pkg-descs)) t)))))))))) +(defun package-install-from-archive (pkg-desc) + "Download and install PKG-DESC, refreshing the archive if necessary." + (condition-case msg + (package-install-from-archive-1 pkg-desc) + (error + (when (string-match-p "\\`Error retrieving: " (cadr msg)) + (package-refresh-contents) + (package-install-from-archive-1 pkg-desc))))) + ;;;###autoload (defun package-installed-p (package &optional min-version) "Return non-nil if PACKAGE, of MIN-VERSION or newer, is installed.