→How to use it with a custom build
Using the <tt>package.el</tt> UI is ok if you’re a casual Emacs user, but what if you have a custom Emacs configuration, stored under version control, that you’d like to instantly deploy on any OS/machine (like Emacs Prelude). Here in play comes <tt>package.el</tt>’s programmer interface. In [https://github.com/bbatsov/emacs-prelude Emacs Prelude] I use the following code to install a list of required packages automatically on Emacs startup (if necessary):
pre class=" cl">;; Comment out if you've already loaded this package...
'(ack-and-a-half auctex clojure-mode coffee-mode deft expand-region
gist groovy-mode haml-mode haskell-mode inf-ruby
"A list of packages to ensure are installed at launch.")
(loop for p in prelude-packages
when (not (package-installed-p p)) do (return nil)
finally (return t)))
;; check for new packages (package versions)
;; install the missing packages
(dolist (p prelude-packages)
(when (not (package-installed-p p))
This code check if all of the packages in the list are installed and if any of them are not installed if refreshes the local package database (in the case a required package for recently added to the remote repo) and installs them.