Emacs config utilizing prelude as a base
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

114 lines
4.1 KiB

13 years ago
14 years ago
13 years ago
  1. ;;; prelude-packages.el --- Emacs Prelude: default package selection.
  2. ;;
  3. ;; Copyright © 2011-2013 Bozhidar Batsov
  4. ;;
  5. ;; Author: Bozhidar Batsov <bozhidar@batsov.com>
  6. ;; URL: https://github.com/bbatsov/prelude
  7. ;; Version: 1.0.0
  8. ;; Keywords: convenience
  9. ;; This file is not part of GNU Emacs.
  10. ;;; Commentary:
  11. ;; Takes care of the automatic installation of all the packages required by
  12. ;; Emacs Prelude.
  13. ;;; License:
  14. ;; This program is free software; you can redistribute it and/or
  15. ;; modify it under the terms of the GNU General Public License
  16. ;; as published by the Free Software Foundation; either version 3
  17. ;; of the License, or (at your option) any later version.
  18. ;;
  19. ;; This program is distributed in the hope that it will be useful,
  20. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. ;; GNU General Public License for more details.
  23. ;;
  24. ;; You should have received a copy of the GNU General Public License
  25. ;; along with GNU Emacs; see the file COPYING. If not, write to the
  26. ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  27. ;; Boston, MA 02110-1301, USA.
  28. ;;; Code:
  29. (require 'package)
  30. (add-to-list 'package-archives
  31. '("melpa" . "http://melpa.milkbox.net/packages/") t)
  32. ;; set package-user-dir to be relative to Prelude install path
  33. (setq package-user-dir (expand-file-name "elpa" prelude-dir))
  34. (package-initialize)
  35. (defvar prelude-packages
  36. '(ace-jump-mode ack-and-a-half diminish elisp-slime-nav
  37. expand-region flycheck gist
  38. git-commit-mode gitconfig-mode gitignore-mode
  39. guru-mode helm helm-projectile
  40. key-chord magit melpa smex ido-ubiquitous
  41. rainbow-mode solarized-theme undo-tree
  42. volatile-highlights yasnippet zenburn-theme)
  43. "A list of packages to ensure are installed at launch.")
  44. (defun prelude-packages-installed-p ()
  45. (-all? #'package-installed-p prelude-packages))
  46. (defun prelude-install-packages ()
  47. (unless (prelude-packages-installed-p)
  48. ;; check for new packages (package versions)
  49. (message "%s" "Emacs Prelude is now refreshing its package database...")
  50. (package-refresh-contents)
  51. (message "%s" " done.")
  52. ;; install the missing packages
  53. (-each
  54. (-reject #'package-installed-p prelude-packages)
  55. #'package-install)))
  56. (prelude-install-packages)
  57. (defmacro prelude-auto-install (extension package mode)
  58. `(add-to-list 'auto-mode-alist
  59. `(,extension . (lambda ()
  60. (unless (package-installed-p ',package)
  61. (package-install ',package))
  62. (,mode)))))
  63. (defvar prelude-auto-install-alist
  64. '(("\\.clj\\'" clojure-mode clojure-mode)
  65. ("\\.coffee\\'" coffee-mode coffee-mode)
  66. ("\\.css\\'" css-mode css-mode)
  67. ("\\.erl\\'" erlang erlang-mode)
  68. ("\\.feature\\'" feature-mode feature-mode)
  69. ("\\.groovy\\'" groovy-mode groovy-mode)
  70. ("\\.haml\\'" haml-mode haml-mode)
  71. ("\\.hs\\'" haskell-mode haskell-mode)
  72. ("\\.latex\\'" auctex LaTeX-mode)
  73. ("\\.less\\'" less-css-mode less-css-mode)
  74. ("\\.lua\\'" lua-mode lua-mode)
  75. ("\\.markdown\\'" markdown-mode markdown-mode)
  76. ("\\.md\\'" markdown-mode markdown-mode)
  77. ("\\.php\\'" php-mode php-mode)
  78. ("\\.sass\\'" sass-mode sass-mode)
  79. ("\\.scala\\'" scala-mode2 scala-mode)
  80. ("\\.scss\\'" scss-mode scss-mode)
  81. ("\\.slim\\'" slim-mode slim-mode)
  82. ("\\.yml\\'" yaml-mode yaml-mode)))
  83. ;; markdown-mode doesn't have autoloads for the auto-mode-alist
  84. ;; so we add them manually if it's already installed
  85. (when (package-installed-p 'markdown-mode)
  86. (add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-mode))
  87. (add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode)))
  88. (-each prelude-auto-install-alist
  89. (lambda (entry)
  90. (let ((extension (car entry))
  91. (package (cadr entry))
  92. (mode (cadr (cdr entry))))
  93. (unless (package-installed-p package)
  94. (prelude-auto-install extension package mode)))))
  95. (defun prelude-ensure-module-deps (packages)
  96. (-each (-remove #'package-installed-p packages) #'package-install))
  97. (provide 'prelude-packages)
  98. ;;; prelude-packages.el ends here