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

14 years ago
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 (extension package mode)
  56. `(add-to-list 'auto-mode-alist
  57. `(,extension . (lambda ()
  58. (package-install ',package)
  59. (,mode)))))
  60. (defvar prelude-auto-install-alist
  61. '(("\\.clj\\'" prelude-clojure clojure-mode)
  62. ("\\.coffee\\'" prelude-coffee coffee-mode)
  63. ("\\.css\\'" prelude-css css-mode)
  64. ("\\.el\\'" prelude-emacs-lisp emacs-lisp-mode)
  65. ("\\.erl\\'" erlang erlang-mode)
  66. ("\\.feature\\'" feature-mode feature-mode)
  67. ("\\.groovy\\'" groovy-mode groovy-mode)
  68. ("\\.haml\\'" haml-mode haml-mode)
  69. ("\\.hs\\'" prelude-haskell haskell-mode)
  70. ("\\.js\\'" prelude-js js-mode)
  71. ("\\.latex\\'" prelude-latex LaTeX-mode)
  72. ("\\.less\\'" less-css-mode less-css-mode)
  73. ("\\.lisp\\'" prelude-common-lisp lisp-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. ("\\.pl\\'" prelude-perl cperl-mode)
  79. ("\\.py\\'" python python-mode)
  80. ("\\.rb\\'" prelude-ruby ruby-mode)
  81. ("\\.sass\\'" sass-mode sass-mode)
  82. ("\\.scm\\'" prelude-scheme scheme-mode)
  83. ("\\.scss\\'" prelude-scss scss-mode)
  84. ("\\.xml\\'" prelude-xml nxml-mode)
  85. ("\\.yml\\'" yaml-mode yaml-mode)))
  86. ;; markdown-mode doesn't have autoloads for the auto-mode-alist
  87. ;; so we add them manually if it's already installed
  88. (when (package-installed-p 'markdown-mode)
  89. (add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-mode))
  90. (add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode)))
  91. (dolist (entry prelude-auto-install-alist)
  92. (let ((extension (first entry))
  93. (package (second entry))
  94. (mode (third entry)))
  95. (unless (package-installed-p package)
  96. (prelude-auto-install extension package mode))))
  97. (provide 'prelude-packages)
  98. ;;; prelude-packages.el ends here