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.

118 lines
4.4 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. ;; set package-user-dir to be relative to Prelude install path
  34. (setq package-user-dir (expand-file-name "elpa" prelude-dir))
  35. (package-initialize)
  36. ;; required because of a package.el bug
  37. (setq url-http-attempt-keepalives nil)
  38. (defvar prelude-packages
  39. '(ack-and-a-half exec-path-from-shell expand-region gist guru-mode helm helm-projectile magit magithub melpa
  40. rainbow-mode volatile-highlights yasnippet solarized-theme zenburn-theme)
  41. "A list of packages to ensure are installed at launch.")
  42. (defun prelude-packages-installed-p ()
  43. (loop for p in prelude-packages
  44. when (not (package-installed-p p)) do (return nil)
  45. finally (return t)))
  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. (dolist (p prelude-packages)
  54. (unless (package-installed-p p)
  55. (package-install p)))))
  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\\'" prelude-clojure clojure-mode)
  65. ("\\.coffee\\'" prelude-coffee coffee-mode)
  66. ("\\.css\\'" prelude-css css-mode)
  67. ("\\.el\\'" prelude-emacs-lisp emacs-lisp-mode)
  68. ("\\.erl\\'" erlang erlang-mode)
  69. ("\\.feature\\'" feature-mode feature-mode)
  70. ("\\.groovy\\'" groovy-mode groovy-mode)
  71. ("\\.haml\\'" haml-mode haml-mode)
  72. ("\\.hs\\'" prelude-haskell haskell-mode)
  73. ("\\.js\\'" prelude-js js-mode)
  74. ("\\.latex\\'" prelude-latex LaTeX-mode)
  75. ("\\.less\\'" less-css-mode less-css-mode)
  76. ("\\.lisp\\'" prelude-common-lisp lisp-mode)
  77. ("\\.lua\\'" lua-mode lua-mode)
  78. ("\\.markdown\\'" markdown-mode markdown-mode)
  79. ("\\.md\\'" markdown-mode markdown-mode)
  80. ("\\.php\\'" php-mode php-mode)
  81. ("\\.pl\\'" prelude-perl cperl-mode)
  82. ("\\.py\\'" python python-mode)
  83. ("\\.rb\\'" prelude-ruby ruby-mode)
  84. ("\\.sass\\'" sass-mode sass-mode)
  85. ("\\.scala\\'" prelude-scala scala-mode)
  86. ("\\.scm\\'" prelude-scheme scheme-mode)
  87. ("\\.scss\\'" prelude-scss scss-mode)
  88. ("\\.xml\\'" prelude-xml nxml-mode)
  89. ("\\.yml\\'" yaml-mode yaml-mode)))
  90. ;; markdown-mode doesn't have autoloads for the auto-mode-alist
  91. ;; so we add them manually if it's already installed
  92. (when (package-installed-p 'markdown-mode)
  93. (add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-mode))
  94. (add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode)))
  95. (dolist (entry prelude-auto-install-alist)
  96. (let ((extension (first entry))
  97. (package (second entry))
  98. (mode (third entry)))
  99. (unless (package-installed-p package)
  100. (prelude-auto-install extension package mode))))
  101. (provide 'prelude-packages)
  102. ;;; prelude-packages.el ends here