core: add guards around package-refresh-contents redefinition
Authorize Spacemacs to redefine the function only for tested versions.
This commit is contained in:
parent
87b6d3fbe9
commit
7be61762ed
|
@ -11,39 +11,50 @@
|
||||||
;;; License: GPLv3
|
;;; License: GPLv3
|
||||||
(require 'core-spacemacs-buffer)
|
(require 'core-spacemacs-buffer)
|
||||||
|
|
||||||
;; for some reason with-eval-after-load does not work here in 24.3
|
;; Disclaimer:
|
||||||
;; maybe the backport is incorrect!
|
;; The code in this file is not meant to stay for ever, they are
|
||||||
(eval-after-load 'package
|
;; temporary fixes that we should remove as soon as a better
|
||||||
'(progn
|
;; solution is found.
|
||||||
(defun package-refresh-contents ()
|
|
||||||
"Download the ELPA archive description if needed.
|
;; TODO remove this code as soon as we have a clean alternative.
|
||||||
|
;; A good proposal is available here:
|
||||||
|
;; https://github.com/syl20bnr/spacemacs/commit/4d87ea626dafc066d911c83538e260dd2bef762f#commitcomment-14708731
|
||||||
|
(when (and (version<= "24.3.1" emacs-version)
|
||||||
|
(version<= emacs-version "24.5.1"))
|
||||||
|
;; for some reason with-eval-after-load does not work here in 24.3
|
||||||
|
;; maybe the backport is incorrect!
|
||||||
|
(eval-after-load 'package
|
||||||
|
'(progn
|
||||||
|
(defun package-refresh-contents ()
|
||||||
|
"Download the ELPA archive description if needed.
|
||||||
This informs Emacs about the latest versions of all packages, and
|
This informs Emacs about the latest versions of all packages, and
|
||||||
makes them available for download.
|
makes them available for download.
|
||||||
|
|
||||||
This redefinition adds a timeout of 5 seconds to contact each archive."
|
This redefinition adds a timeout of 5 seconds to contact each archive."
|
||||||
(interactive)
|
(interactive)
|
||||||
;; the first part is not available before Emacs 24.4 so we just ignore
|
;; the first part is not available before Emacs 24.4 so we just ignore
|
||||||
;; it to be safe.
|
;; it to be safe.
|
||||||
(unless (version< emacs-version "24.4")
|
(unless (version< emacs-version "24.4")
|
||||||
;; FIXME: Do it asynchronously.
|
;; FIXME: Do it asynchronously.
|
||||||
(unless (file-exists-p package-user-dir)
|
(unless (file-exists-p package-user-dir)
|
||||||
(make-directory package-user-dir t))
|
(make-directory package-user-dir t))
|
||||||
(let ((default-keyring (expand-file-name "package-keyring.gpg"
|
(let ((default-keyring (expand-file-name "package-keyring.gpg"
|
||||||
data-directory)))
|
data-directory)))
|
||||||
(when (and package-check-signature (file-exists-p default-keyring))
|
(when (and package-check-signature (file-exists-p default-keyring))
|
||||||
(condition-case-unless-debug error
|
(condition-case-unless-debug error
|
||||||
(progn
|
(progn
|
||||||
(epg-check-configuration (epg-configuration))
|
(epg-check-configuration (epg-configuration))
|
||||||
(package-import-keyring default-keyring))
|
(package-import-keyring default-keyring))
|
||||||
(error (message "Cannot import default keyring: %S" (cdr error)))))))
|
(error (message "Cannot import default keyring: %S" (cdr error)))))))
|
||||||
(dolist (archive package-archives)
|
(dolist (archive package-archives)
|
||||||
(condition-case-unless-debug nil
|
(condition-case-unless-debug nil
|
||||||
(with-timeout (5 (spacemacs-buffer/warning
|
;; add timeout here
|
||||||
"Cannot contact archive %s (reason: timeout)"
|
(with-timeout (5 (spacemacs-buffer/warning
|
||||||
(cdr archive)))
|
"Cannot contact archive %s (reason: timeout)"
|
||||||
(package--download-one-archive archive "archive-contents"))
|
(cdr archive)))
|
||||||
(error (message "Failed to download `%s' archive."
|
(package--download-one-archive archive "archive-contents"))
|
||||||
(car archive)))))
|
(error (message "Failed to download `%s' archive."
|
||||||
(package-read-all-archive-contents))))
|
(car archive)))))
|
||||||
|
(package-read-all-archive-contents)))))
|
||||||
|
|
||||||
(provide 'core-emacs-ext)
|
(provide 'core-emacs-ext)
|
||||||
|
|
Loading…
Reference in a new issue