From: Ivan Goncharov Date: Thu, 12 Nov 2015 22:08:02 +0000 (+1300) Subject: Install packages when byte-compiling (fix by @npostavs) X-Git-Tag: emacs-29.0.90~1306^2~15^2~327^2 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=d9f37b4f0c1abff2e3e9122403b6a578acbaba99;p=emacs.git Install packages when byte-compiling (fix by @npostavs) --- 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)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;