Skip to content

Instantly share code, notes, and snippets.

@toumorokoshi
Created April 25, 2013 20:24
Show Gist options
  • Save toumorokoshi/5462827 to your computer and use it in GitHub Desktop.
Save toumorokoshi/5462827 to your computer and use it in GitHub Desktop.
An example of automated package installation with emacs and package.el
(require 'package)
(add-to-list 'package-archives
'("melpa" . "http://melpa.milkbox.net/packages/") t)
(add-to-list 'package-archives
'("marmalade" . "http://marmalade-repo.org/packages/") t)
(package-initialize)
(defvar toumorokoshi-packages
'(
ace-jump-mode
anything-git-goto
auto-complete
color-theme
flymake
flymake-cursor
flymake-go
go-autocomplete
go-mode
golden-ratio
hackernews
helm
highlight-indentation
jedi
js2-mode
linum-relative
magit
multiple-cursors
p4
powerline
scala-mode2
rainbow-mode
visual-regexp
yaml-mode
yasnippet
) "A list of packages to ensure are installed at launch.")
(provide 'toumorokoshi-packages)
;; http://stackoverflow.com/questions/10092322/how-to-automatically-install-emacs-packages-by-specifying-a-list-of-package-name
(setq url-http-attempt-keepalives nil)
(defun packages-installed-p ()
(loop for p in toumorokoshi-packages
when (not (package-installed-p p)) do (return nil)
finally (return t)))
(unless (packages-installed-p)
;; check for new packages (package versions)
(message "%s" "Emacs is now refreshing its package database...")
(package-refresh-contents)
(message "%s" " done.")
;; install the missing packages
(dolist (p toumorokoshi-packages)
(when (not (package-installed-p p))
(package-install p))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment