public
Created

An example of automated package installation with emacs and package.el

  • Download Gist
install.el
Emacs Lisp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
(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))))

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.