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.

115 lines
4.2 KiB

13 years ago
14 years ago
14 years ago
13 years ago
13 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: http://batsov.com/emacs-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. ;; required because of a package.el bug
  36. (setq url-http-attempt-keepalives nil)
  37. (defvar prelude-packages
  38. '(ack-and-a-half elisp-slime-nav exec-path-from-shell expand-region
  39. flycheck gist
  40. guru-mode helm helm-projectile magit magithub melpa
  41. rainbow-mode solarized-theme volatile-highlights yasnippet
  42. 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. ("\\.py\\'" python python-mode)
  79. ("\\.sass\\'" sass-mode sass-mode)
  80. ("\\.scala\\'" scala-mode2 scala-mode)
  81. ("\\.scss\\'" scss-mode scss-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