diff options
author | John Wiegley <johnw@newartisans.com> | 2016-02-25 17:24:59 -0800 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2016-02-25 17:24:59 -0800 |
commit | 6a90a9f16d0d31dd414139ea089dce3d80f1049b (patch) | |
tree | a01b97a464fda06cfc22760b18102c1e4d81011b | |
parent | ce51ea2055cc5c713f52342ceac79bc36631c8fe (diff) | |
download | emacs-6a90a9f16d0d31dd414139ea089dce3d80f1049b.tar.gz emacs-6a90a9f16d0d31dd414139ea089dce3d80f1049b.tar.bz2 emacs-6a90a9f16d0d31dd414139ea089dce3d80f1049b.zip |
Add configuration variable `use-package-check-before-init'
Fixes https://github.com/jwiegley/use-package/issues/306
-rw-r--r-- | lisp/use-package/use-package.el | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/lisp/use-package/use-package.el b/lisp/use-package/use-package.el index 619c6c3b3f3..617c523f8ff 100644 --- a/lisp/use-package/use-package.el +++ b/lisp/use-package/use-package.el @@ -66,9 +66,15 @@ then the expanded macros do their job silently." :type 'boolean :group 'use-package) +(defcustom use-package-check-before-init nil + "If non-nil, check that package exists before executing its `:init' block. +The check is performed by looking for the module using `locate-library'." + :type 'boolean + :group 'use-package) + (defcustom use-package-always-defer nil "If non-nil, assume `:defer t` unless `:demand t` is given." - :type 'sexp + :type 'boolean :group 'use-package) (defcustom use-package-always-ensure nil @@ -938,7 +944,13 @@ deferred until the prefix key sequence is pressed." (let ((body (use-package-process-keywords name rest state))) (use-package-concat ;; The user's initializations - (use-package-hook-injector (use-package-as-string name) :init arg) + (let ((init-body + (use-package-hook-injector (use-package-as-string name) + :init arg))) + (if use-package-check-before-init + `((if (locate-library ,(use-package-as-string name)) + ,(macroexp-progn init-body))) + init-body)) body))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |