Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add @purcell's require-package

  • Loading branch information...
commit 08ed1237384fc11943b16ee15d1d8eb64e4c222c 1 parent 51963a2
@magnars magnars authored
Showing with 14 additions and 0 deletions.
  1. +14 −0 setup-package.el
View
14 setup-package.el
@@ -15,4 +15,18 @@
(package-install it)))
(delete-other-windows))
+;;; 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)
Please sign in to comment.
Something went wrong with that request. Please try again.