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

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