summaryrefslogtreecommitdiff
path: root/lisp/use-package
diff options
context:
space:
mode:
authorRadon Rosborough <radon.neon@gmail.com>2017-01-15 09:03:05 -0700
committerRadon Rosborough <radon.neon@gmail.com>2017-01-15 09:03:05 -0700
commite853355714254d76691f97ec51c4980eff85c49a (patch)
treed1c1c9d24601c3f9a020ec18b0591f169944c5a5 /lisp/use-package
parentad8094c22d9a1bfbc1ad19bbbe3c164d1dae6850 (diff)
downloademacs-e853355714254d76691f97ec51c4980eff85c49a.tar.gz
emacs-e853355714254d76691f97ec51c4980eff85c49a.tar.bz2
emacs-e853355714254d76691f97ec51c4980eff85c49a.zip
Add use-package-ensure-function
This allows the user to customize the :ensure keyword by using a different package manager than package.el.
Diffstat (limited to 'lisp/use-package')
-rw-r--r--lisp/use-package/use-package.el16
1 files changed, 13 insertions, 3 deletions
diff --git a/lisp/use-package/use-package.el b/lisp/use-package/use-package.el
index cfff54579bc..469872b94db 100644
--- a/lisp/use-package/use-package.el
+++ b/lisp/use-package/use-package.el
@@ -182,6 +182,16 @@ Must be set before loading use-package."
:type 'boolean
:group 'use-package)
+(defcustom use-package-ensure-function 'use-package-ensure-elpa
+ "Function that ensures a package is installed.
+This function is called with one argument, the package name as a
+symbol, by the `:ensure' keyword.
+
+The default value uses package.el to install the package."
+ :type '(choice (const :tag "package.el" use-package-ensure-elpa)
+ (function :tag "Custom"))
+ :group 'use-package)
+
(when use-package-enable-imenu-support
;; Not defined in Emacs 24
(defvar lisp-mode-symbol-regexp
@@ -504,6 +514,7 @@ manually updated package."
"(an unquoted symbol name)")))))))
(defun use-package-ensure-elpa (package &optional no-refresh)
+ (require 'package)
(if (package-installed-p package)
t
(if (and (not no-refresh)
@@ -518,9 +529,8 @@ manually updated package."
(defun use-package-handler/:ensure (name keyword ensure rest state)
(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)))))
+ (ensure-form (when package-name
+ `(,use-package-ensure-function ',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