This isn’t an original recipe, but this is how I kick off my .emacs
settings to ensure that
my-packages are auto-installed.
;;; Package magic. (require 'package) (package-initialize) (add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/")) (defvar my-packages '(evil key-chord helm elscreen ace-jump-mode surround recentf magit) "A list of packages to check for and install at launch.") (defun my-missing-packages () (let (missing-packages) (dolist (package my-packages missing-packages) (or (package-installed-p package) (push package missing-packages))))) (let ((missing (my-missing-packages))) (when missing ;; Check for new packages (package versions) (package-refresh-contents) ;; Install the missing packages (mapc (lambda (package) (when (not (package-installed-p package)) (package-install package))) missing)))