|
11 | 11 | ;;; License: GPLv3
|
12 | 12 | (require 'core-spacemacs-buffer)
|
13 | 13 |
|
14 |
| -;; for some reason with-eval-after-load does not work here in 24.3 |
15 |
| -;; maybe the backport is incorrect! |
16 |
| -(eval-after-load 'package |
17 |
| - '(progn |
18 |
| - (defun package-refresh-contents () |
19 |
| - "Download the ELPA archive description if needed. |
| 14 | +;; Disclaimer: |
| 15 | +;; The code in this file is not meant to stay for ever, they are |
| 16 | +;; temporary fixes that we should remove as soon as a better |
| 17 | +;; solution is found. |
| 18 | + |
| 19 | +;; TODO remove this code as soon as we have a clean alternative. |
| 20 | +;; A good proposal is available here: |
| 21 | +;; https://github.com/syl20bnr/spacemacs/commit/4d87ea626dafc066d911c83538e260dd2bef762f#commitcomment-14708731 |
| 22 | +(when (and (version<= "24.3.1" emacs-version) |
| 23 | + (version<= emacs-version "24.5.1")) |
| 24 | + ;; for some reason with-eval-after-load does not work here in 24.3 |
| 25 | + ;; maybe the backport is incorrect! |
| 26 | + (eval-after-load 'package |
| 27 | + '(progn |
| 28 | + (defun package-refresh-contents () |
| 29 | + "Download the ELPA archive description if needed. |
20 | 30 | This informs Emacs about the latest versions of all packages, and
|
21 | 31 | makes them available for download.
|
22 | 32 |
|
23 | 33 | This redefinition adds a timeout of 5 seconds to contact each archive."
|
24 |
| - (interactive) |
25 |
| - ;; the first part is not available before Emacs 24.4 so we just ignore |
26 |
| - ;; it to be safe. |
27 |
| - (unless (version< emacs-version "24.4") |
28 |
| - ;; FIXME: Do it asynchronously. |
29 |
| - (unless (file-exists-p package-user-dir) |
30 |
| - (make-directory package-user-dir t)) |
31 |
| - (let ((default-keyring (expand-file-name "package-keyring.gpg" |
32 |
| - data-directory))) |
33 |
| - (when (and package-check-signature (file-exists-p default-keyring)) |
34 |
| - (condition-case-unless-debug error |
35 |
| - (progn |
36 |
| - (epg-check-configuration (epg-configuration)) |
37 |
| - (package-import-keyring default-keyring)) |
38 |
| - (error (message "Cannot import default keyring: %S" (cdr error))))))) |
39 |
| - (dolist (archive package-archives) |
40 |
| - (condition-case-unless-debug nil |
41 |
| - (with-timeout (5 (spacemacs-buffer/warning |
42 |
| - "Cannot contact archive %s (reason: timeout)" |
43 |
| - (cdr archive))) |
44 |
| - (package--download-one-archive archive "archive-contents")) |
45 |
| - (error (message "Failed to download `%s' archive." |
46 |
| - (car archive))))) |
47 |
| - (package-read-all-archive-contents)))) |
| 34 | + (interactive) |
| 35 | + ;; the first part is not available before Emacs 24.4 so we just ignore |
| 36 | + ;; it to be safe. |
| 37 | + (unless (version< emacs-version "24.4") |
| 38 | + ;; FIXME: Do it asynchronously. |
| 39 | + (unless (file-exists-p package-user-dir) |
| 40 | + (make-directory package-user-dir t)) |
| 41 | + (let ((default-keyring (expand-file-name "package-keyring.gpg" |
| 42 | + data-directory))) |
| 43 | + (when (and package-check-signature (file-exists-p default-keyring)) |
| 44 | + (condition-case-unless-debug error |
| 45 | + (progn |
| 46 | + (epg-check-configuration (epg-configuration)) |
| 47 | + (package-import-keyring default-keyring)) |
| 48 | + (error (message "Cannot import default keyring: %S" (cdr error))))))) |
| 49 | + (dolist (archive package-archives) |
| 50 | + (condition-case-unless-debug nil |
| 51 | + ;; add timeout here |
| 52 | + (with-timeout (5 (spacemacs-buffer/warning |
| 53 | + "Cannot contact archive %s (reason: timeout)" |
| 54 | + (cdr archive))) |
| 55 | + (package--download-one-archive archive "archive-contents")) |
| 56 | + (error (message "Failed to download `%s' archive." |
| 57 | + (car archive))))) |
| 58 | + (package-read-all-archive-contents))))) |
48 | 59 |
|
49 | 60 | (provide 'core-emacs-ext)
|
0 commit comments