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.

112 lines
4.1 KiB

14 years ago
14 years ago
13 years ago
  1. ;;; prelude-packages.el --- Emacs Prelude: default package selection.
  2. ;;
  3. ;; Copyright (c) 2011-2012 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 gist guru-mode helm helm-projectile magit magithub melpa
  39. rainbow-mode volatile-highlights yasnippet solarized-theme zenburn-theme)
  40. "A list of packages to ensure are installed at launch.")
  41. (defun prelude-packages-installed-p ()
  42. (-all? #'package-installed-p prelude-packages))
  43. (defun prelude-install-packages ()
  44. (unless (prelude-packages-installed-p)
  45. ;; check for new packages (package versions)
  46. (message "%s" "Emacs Prelude is now refreshing its package database...")
  47. (package-refresh-contents)
  48. (message "%s" " done.")
  49. ;; install the missing packages
  50. (-each
  51. (-reject #'package-installed-p prelude-packages)
  52. #'package-install)))
  53. (prelude-install-packages)
  54. (defmacro prelude-auto-install (extension package mode)
  55. `(add-to-list 'auto-mode-alist
  56. `(,extension . (lambda ()
  57. (unless (package-installed-p ',package)
  58. (package-install ',package))
  59. (,mode)))))
  60. (defvar prelude-auto-install-alist
  61. '(("\\.clj\\'" clojure-mode clojure-mode)
  62. ("\\.coffee\\'" coffee-mode coffee-mode)
  63. ("\\.css\\'" css-mode css-mode)
  64. ("\\.erl\\'" erlang erlang-mode)
  65. ("\\.feature\\'" feature-mode feature-mode)
  66. ("\\.groovy\\'" groovy-mode groovy-mode)
  67. ("\\.haml\\'" haml-mode haml-mode)
  68. ("\\.hs\\'" haskell-mode haskell-mode)
  69. ("\\.latex\\'" auctex LaTeX-mode)
  70. ("\\.less\\'" less-css-mode less-css-mode)
  71. ("\\.lua\\'" lua-mode lua-mode)
  72. ("\\.markdown\\'" markdown-mode markdown-mode)
  73. ("\\.md\\'" markdown-mode markdown-mode)
  74. ("\\.php\\'" php-mode php-mode)
  75. ("\\.py\\'" python python-mode)
  76. ("\\.sass\\'" sass-mode sass-mode)
  77. ("\\.scala\\'" scala-mode2 scala-mode)
  78. ("\\.scss\\'" scss-mode scss-mode)
  79. ("\\.yml\\'" yaml-mode yaml-mode)))
  80. ;; markdown-mode doesn't have autoloads for the auto-mode-alist
  81. ;; so we add them manually if it's already installed
  82. (when (package-installed-p 'markdown-mode)
  83. (add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-mode))
  84. (add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode)))
  85. (-each prelude-auto-install-alist
  86. (lambda (entry)
  87. (let ((extension (car entry))
  88. (package (cadr entry))
  89. (mode (cadr (cdr entry))))
  90. (unless (package-installed-p package)
  91. (prelude-auto-install extension package mode)))))
  92. (defun prelude-ensure-module-deps (packages)
  93. (-each (-remove #'package-installed-p packages) #'package-install))
  94. (provide 'prelude-packages)
  95. ;;; prelude-packages.el ends here