summaryrefslogtreecommitdiffstats
path: root/lisp/init-package.el
diff options
context:
space:
mode:
authorMartin Polden <martin.polden@gmail.com>2016-02-26 09:42:44 +0100
committerMartin Polden <martin.polden@gmail.com>2016-02-26 09:44:36 +0100
commitb067cd9259140b7c74c44dfd0e9389fe6a8cafd4 (patch)
tree785fb238397d566f4b2c664e7fb7ee37d0b104f4 /lisp/init-package.el
parentd209a4a6a00b6bd2a699f5ffb1bac0c6a42b331b (diff)
Re-add require-package
Diffstat (limited to 'lisp/init-package.el')
-rw-r--r--lisp/init-package.el25
1 files changed, 18 insertions, 7 deletions
diff --git a/lisp/init-package.el b/lisp/init-package.el
index 060b7d8..4740d92 100644
--- a/lisp/init-package.el
+++ b/lisp/init-package.el
@@ -4,16 +4,27 @@
'("melpa" . "http://melpa.org/packages/") t)
(package-initialize)
+(defun require-package (package &optional min-version no-refresh)
+ "Install given PACKAGE, optionally requiring MIN-VERSION.
+If NO-REFRESH is non-nil, the available package lists will not be
+re-downloaded in order to locate PACKAGE."
+ (if (package-installed-p package min-version)
+ t
+ (if (or (assoc package package-archive-contents) no-refresh)
+ (package-install package)
+ (progn
+ (package-refresh-contents)
+ (require-package package min-version t)))))
+
+(defun require-packages (packages)
+ "Install a list of PACKAGES."
+ (mapcar (lambda (package) (require-package package)) packages))
+
;; install missing packages automatically
(setq use-package-always-ensure t)
-;; install and load use-package
-(unless (package-installed-p 'use-package)
- (package-install 'use-package))
-
-;; install diminish
-(unless (package-installed-p 'diminish)
- (package-install 'diminish))
+;; install use-package and diminish
+(require-packages '(use-package diminish))
;; speed up loading of use-package and dependencies
(eval-when-compile