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.

71 lines
2.3 KiB

  1. ;;; prelude-auto-install.el --- Emacs Prelude: auto-install required packages
  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. ;; A simple mechanism to automatically install missing packages.
  12. ;;; License:
  13. ;; This program is free software; you can redistribute it and/or
  14. ;; modify it under the terms of the GNU General Public License
  15. ;; as published by the Free Software Foundation; either version 3
  16. ;; of the License, or (at your option) any later version.
  17. ;;
  18. ;; This program is distributed in the hope that it will be useful,
  19. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. ;; GNU General Public License for more details.
  22. ;;
  23. ;; You should have received a copy of the GNU General Public License
  24. ;; along with GNU Emacs; see the file COPYING. If not, write to the
  25. ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  26. ;; Boston, MA 02110-1301, USA.
  27. ;;; Code:
  28. (defmacro prelude-auto-install (ext mode)
  29. `(unless (fboundp ',mode)
  30. (add-to-list 'auto-mode-alist
  31. `(,ext . (lambda ()
  32. (package-install ',mode)
  33. (,mode))))))
  34. (defvar prelude-auto-install-alist
  35. '(("\\.markdown\\'" . markdown-mode)
  36. ("\\.md\\'" . markdown-mode)
  37. ("\\.haml\\'" . haml-mode)
  38. ("\\.scss\\'" . scss-mode)
  39. ("\\.sass\\'" . sass-mode)
  40. ("\\.groovy\\'" . groovy-mode)
  41. ("\\.yml\\'" . yaml-mode)
  42. ("\\.php\\'" . php-mode)
  43. ("\\.hs\\'" . haskell-mode)
  44. ("\\.less\\'" . less-css-mode)
  45. ("\\.lua\\'" . lua-mode)
  46. ("\\.coffee\\'" . coffee-mode)
  47. ("\\.erl\\'" . erlang-mode)
  48. ("\\.feature\\'" . feature-mode)))
  49. ;; markdown-mode doesn't have autoloads for the auto-mode-alist
  50. ;; so we add them manually if it's already installed
  51. (when (package-installed-p 'markdown-mode)
  52. (add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-mode))
  53. (add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode)))
  54. (dolist (entry prelude-auto-install-alist)
  55. (let ((ext (car entry))
  56. (mode (cdr entry)))
  57. (prelude-auto-install ext mode)))
  58. (provide 'prelude-auto-install)
  59. ;;; prelude-auto-install.el ends here