diff options
author | John Wiegley <johnw@newartisans.com> | 2015-11-12 17:39:45 -0500 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2015-11-12 17:39:45 -0500 |
commit | 189c8b5422a7fc986efd5a4fc2a2699b9b08b94d (patch) | |
tree | c07fc2fba3e1cd5ba056e2678b8673fd45fa83a2 /lisp/use-package/use-package.el | |
parent | b1f442c15bc6f8ac54c81e8c9b80c263b99d4ccc (diff) | |
parent | d9f37b4f0c1abff2e3e9122403b6a578acbaba99 (diff) | |
download | emacs-189c8b5422a7fc986efd5a4fc2a2699b9b08b94d.tar.gz emacs-189c8b5422a7fc986efd5a4fc2a2699b9b08b94d.tar.bz2 emacs-189c8b5422a7fc986efd5a4fc2a2699b9b08b94d.zip |
Merge pull request from kovrik/byte-compile-ensure-fix
Install packages when byte-compiling (fix by @npostavs)
GitHub-reference: https://github.com/jwiegley/use-package/issues/285
Diffstat (limited to 'lisp/use-package/use-package.el')
-rw-r--r-- | lisp/use-package/use-package.el | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/lisp/use-package/use-package.el b/lisp/use-package/use-package.el index 6027c9f3aee..b88749d357b 100644 --- a/lisp/use-package/use-package.el +++ b/lisp/use-package/use-package.el @@ -463,12 +463,19 @@ manually updated package." (use-package-ensure-elpa package t))))) (defun use-package-handler/:ensure (name keyword ensure rest state) - (let ((body (use-package-process-keywords name rest state))) - `((let ((package-name (or (and (eq ',ensure t) (use-package-as-symbol ',name)) ',ensure))) - (when package-name - (require 'package) - (use-package-ensure-elpa package-name))) - ,@body))) + (let* ((body (use-package-process-keywords name rest state)) + (package-name (or (and (eq ensure t) (use-package-as-symbol name)) ensure)) + (ensure-form (if package-name + `(progn (require 'package) + (use-package-ensure-elpa ',package-name))))) + ;; We want to avoid installing packages when the `use-package' + ;; macro is being macro-expanded by elisp completion (see + ;; `lisp--local-variables'), but still do install packages when + ;; byte-compiling to avoid requiring `package' at runtime. + (if (bound-and-true-p byte-compile-current-file) + (eval ensure-form) ; Eval when byte-compiling, + (push ensure-form body)) ; or else wait until runtime. + body)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; |