summaryrefslogtreecommitdiff
path: root/lisp/use-package
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2016-01-12 16:01:19 -0500
committerJohn Wiegley <johnw@newartisans.com>2016-01-12 16:01:19 -0500
commit38c170e17bf23fe0d5dc621c7a88c1093c2ee6ee (patch)
tree2c6a01db68cdd839582417f2c279d1112048131d /lisp/use-package
parent3ce3b3a98c65f365d5e95258c28b9c9f751f41b0 (diff)
parentd1c78a646cdf08cc0aa9c8664f69ce23e3e8cb83 (diff)
downloademacs-38c170e17bf23fe0d5dc621c7a88c1093c2ee6ee.tar.gz
emacs-38c170e17bf23fe0d5dc621c7a88c1093c2ee6ee.tar.bz2
emacs-38c170e17bf23fe0d5dc621c7a88c1093c2ee6ee.zip
Merge pull request from kovrik/issue-299
Move :pin out of macro expansion phase GitHub-reference: https://github.com/jwiegley/use-package/issues/302
Diffstat (limited to 'lisp/use-package')
-rw-r--r--lisp/use-package/use-package.el23
1 files changed, 11 insertions, 12 deletions
diff --git a/lisp/use-package/use-package.el b/lisp/use-package/use-package.el
index fecd37bc121..a359e946378 100644
--- a/lisp/use-package/use-package.el
+++ b/lisp/use-package/use-package.el
@@ -419,23 +419,22 @@ manually updated package."
(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)
- (push (cons package archive-name) package-pinned-packages)
+ (add-to-list 'package-pinned-packages (cons package archive-name))
(error "Archive '%s' requested for package '%s' is not available."
archive-name package))
(package-initialize t)))
(defun use-package-handler/:pin (name keyword archive-name rest state)
- (let ((body (use-package-process-keywords name rest state)))
- ;; This happens at macro expansion time, not when the expanded code is
- ;; compiled or evaluated.
- (if (null archive-name)
- body
- (use-package-pin-package name archive-name)
- (use-package-concat
- body
- `((push '(,(use-package-as-symbol name) . ,archive-name)
- package-pinned-packages)
- t)))))
+ (let ((body (use-package-process-keywords name rest state))
+ (pin-form (if archive-name
+ `(use-package-pin-package ',(use-package-as-symbol name)
+ ,archive-name))))
+ ;; Pinning should occur just before ensuring
+ ;; See `use-package-handler/:ensure'.
+ (if (bound-and-true-p byte-compile-current-file)
+ (eval pin-form) ; Eval when byte-compiling,
+ (push pin-form body)) ; or else wait until runtime.
+ body))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;