Skip to content
Browse files

Add @purcell's require-package

  • Loading branch information...
1 parent 51963a2 commit 08ed1237384fc11943b16ee15d1d8eb64e4c222c @magnars magnars committed
Showing with 14 additions and 0 deletions.
  1. +14 −0 setup-package.el
14 setup-package.el
@@ -15,4 +15,18 @@
(package-install it)))
+;;; On-demand installation of packages
+(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)))))
(provide 'setup-package)

0 comments on commit 08ed123

Please sign in to comment.
Something went wrong with that request. Please try again.