Jump to: navigation, search


209 bytes removed, 11:30, 12 April 2012
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 [ Emacs Prelude] I use the following code to install a list of required packages automatically on Emacs startup (if necessary):
<pre classsource lang="cllisp">;; Comment out if you've already loaded this package...
(require 'cl)
(defvar preludemy-packages
'(ack-and-a-half auctex clojure-mode coffee-mode deft expand-region
gist groovy-mode haml-mode haskell-mode inf-ruby
&quot;A list of packages to ensure are installed at launch.&quot;)
(defun preludemy-packages-installed-p ()
(loop for p in prelude-packages
when (not (package-installed-p p)) do (return nil)
finally (return t)))
(unless (preludemy-packages-installed-p)
;; check for new packages (package versions)
(message &quot;%s&quot; &quot;Emacs Prelude is now refreshing its package database...&quot;)
(message &quot;%s&quot; &quot; done.&quot;)
;; install the missing packages
(dolist (p prelude-packages)
(when (not (package-installed-p p))
(package-install p))))
(provide 'prelude-packages)
;;; prelude-packages.el ends here</pre>
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.

Navigation menu