From 308e4e3f2cac8868b79ee181433c776fc029434a Mon Sep 17 00:00:00 2001 From: Ivan Goncharov Date: Wed, 6 Jan 2016 11:15:22 +1300 Subject: Move :pin out of macro expansion phase --- lisp/use-package/use-package.el | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'lisp/use-package/use-package.el') diff --git a/lisp/use-package/use-package.el b/lisp/use-package/use-package.el index b88749d357b..d5226e3a9d3 100644 --- a/lisp/use-package/use-package.el +++ b/lisp/use-package/use-package.el @@ -419,23 +419,23 @@ 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) t) (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 ',name ,archive-name)))) + ;; We want to avoid pinning packages when the `use-package' + ;; macro is being macro-expanded by elisp completion (see + ;; `lisp--local-variables'), but still do pin packages when + ;; byte-compiling to avoid requiring `package' at runtime. + (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)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; -- cgit v1.2.3 From d1c78a646cdf08cc0aa9c8664f69ce23e3e8cb83 Mon Sep 17 00:00:00 2001 From: Ivan Goncharov Date: Wed, 6 Jan 2016 12:56:54 +1300 Subject: Move :pin out of macro expansion phase fixes --- lisp/use-package/use-package.el | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'lisp/use-package/use-package.el') diff --git a/lisp/use-package/use-package.el b/lisp/use-package/use-package.el index d5226e3a9d3..a225d99810f 100644 --- a/lisp/use-package/use-package.el +++ b/lisp/use-package/use-package.el @@ -419,7 +419,7 @@ 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) - (add-to-list 'package-pinned-packages (cons package archive-name) t) + (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))) @@ -427,11 +427,10 @@ manually updated package." (defun use-package-handler/:pin (name keyword archive-name rest state) (let ((body (use-package-process-keywords name rest state)) (pin-form (if archive-name - `(use-package-pin-package ',name ,archive-name)))) - ;; We want to avoid pinning packages when the `use-package' - ;; macro is being macro-expanded by elisp completion (see - ;; `lisp--local-variables'), but still do pin packages when - ;; byte-compiling to avoid requiring `package' at runtime. + `(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. -- cgit v1.2.3