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.

102 lines
3.4 KiB

14 years ago
14 years ago
14 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 'cl)
  30. (require 'package)
  31. (add-to-list 'package-archives
  32. '("melpa" . "http://melpa.milkbox.net/packages/") t)
  33. (package-initialize)
  34. ;; required because of a package.el bug
  35. (setq url-http-attempt-keepalives nil)
  36. (defvar prelude-packages
  37. '(ack-and-a-half expand-region gist helm helm-projectile magit magithub melpa
  38. rainbow-mode volatile-highlights yasnippet zenburn-theme)
  39. "A list of packages to ensure are installed at launch.")
  40. (defun prelude-packages-installed-p ()
  41. (loop for p in prelude-packages
  42. when (not (package-installed-p p)) do (return nil)
  43. finally (return t)))
  44. (defun prelude-install-packages ()
  45. (unless (prelude-packages-installed-p)
  46. ;; check for new packages (package versions)
  47. (message "%s" "Emacs Prelude is now refreshing its package database...")
  48. (package-refresh-contents)
  49. (message "%s" " done.")
  50. ;; install the missing packages
  51. (dolist (p prelude-packages)
  52. (unless (package-installed-p p)
  53. (package-install p)))))
  54. (prelude-install-packages)
  55. (defmacro prelude-auto-install (ext mode)
  56. `(add-to-list 'auto-mode-alist
  57. `(,ext . (lambda ()
  58. (package-install ',mode)
  59. (,mode)))))
  60. (defvar prelude-auto-install-alist
  61. '(("\\.markdown\\'" . markdown-mode)
  62. ("\\.md\\'" . markdown-mode)
  63. ("\\.haml\\'" . haml-mode)
  64. ("\\.scss\\'" . scss-mode)
  65. ("\\.sass\\'" . sass-mode)
  66. ("\\.groovy\\'" . groovy-mode)
  67. ("\\.yml\\'" . yaml-mode)
  68. ("\\.php\\'" . php-mode)
  69. ("\\.hs\\'" . haskell-mode)
  70. ("\\.less\\'" . less-css-mode)
  71. ("\\.lua\\'" . lua-mode)
  72. ("\\.coffee\\'" . coffee-mode)
  73. ("\\.erl\\'" . erlang)
  74. ("\\.feature\\'" . feature-mode)))
  75. ;; markdown-mode doesn't have autoloads for the auto-mode-alist
  76. ;; so we add them manually if it's already installed
  77. (when (package-installed-p 'markdown-mode)
  78. (add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-mode))
  79. (add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode)))
  80. (dolist (entry prelude-auto-install-alist)
  81. (let ((ext (car entry))
  82. (mode (cdr entry)))
  83. (unless (package-installed-p mode)
  84. (prelude-auto-install ext mode))))
  85. (provide 'prelude-packages)
  86. ;;; prelude-packages.el ends here