summaryrefslogtreecommitdiff
path: root/lisp/use-package
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/use-package')
-rw-r--r--lisp/use-package/use-package.el22
1 files changed, 19 insertions, 3 deletions
diff --git a/lisp/use-package/use-package.el b/lisp/use-package/use-package.el
index 83b5bd3f08d..950d0bf0ec2 100644
--- a/lisp/use-package/use-package.el
+++ b/lisp/use-package/use-package.el
@@ -142,9 +142,25 @@ Return nil when the queue is empty."
(defun use-package-pin-package (package archive)
"Pin PACKAGE to ARCHIVE."
(unless (boundp 'package-pinned-packages)
- (setq package-pinned-packages '()))
- (add-to-list 'package-pinned-packages (cons package archive))
- (package-initialize t))
+ (setq package-pinned-packages ()))
+ (let ((archive-symbol (if (symbolp archive) archive (intern archive)))
+ (archive-name (if (stringp archive) archive (symbol-name archive))))
+ (if (use-package--archive-exists-p archive-symbol)
+ (add-to-list 'package-pinned-packages (cons package archive-name))
+ (error (message "Archive '%s' requested for package '%s' is not available." archive-name package)))
+ (package-initialize t)))
+
+(defun use-package--archive-exists-p (archive)
+ "Check if a given ARCHIVE is enabled.
+
+ARCHIVE can be a string or a symbol or 'manual to indicate a manually updated package."
+ (if (member archive '(manual "manual"))
+ 't
+ (let ((valid nil))
+ (dolist (pa package-archives)
+ (when (member archive (list (car pa) (intern (car pa))))
+ (setq valid 't)))
+ valid)))
(defun use-package-ensure-elpa (package)
(when (not (package-installed-p package))