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.

212 lines
6.9 KiB

12 years ago
9 years ago
9 years ago
10 years ago
12 years ago
11 years ago
  1. ;;; prelude-packages.el --- Emacs Prelude: default package selection.
  2. ;;
  3. ;; Copyright © 2011-2017 Bozhidar Batsov
  4. ;;
  5. ;; Author: Bozhidar Batsov <bozhidar@batsov.com>
  6. ;; URL: https://github.com/bbatsov/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. ;; accessing a package repo over https on Windows is a no go, so we
  32. ;; fallback to http there
  33. (if (eq system-type 'windows-nt)
  34. (add-to-list 'package-archives
  35. '("melpa" . "http://melpa.org/packages/") t)
  36. (add-to-list 'package-archives
  37. '("melpa" . "https://melpa.org/packages/") t))
  38. ;; set package-user-dir to be relative to Prelude install path
  39. (setq package-user-dir (expand-file-name "elpa" prelude-dir))
  40. (package-initialize)
  41. (defvar prelude-packages
  42. '(ace-window
  43. avy
  44. anzu
  45. beacon
  46. browse-kill-ring
  47. crux
  48. dash
  49. discover-my-major
  50. diff-hl
  51. diminish
  52. easy-kill
  53. editorconfig
  54. epl
  55. expand-region
  56. flycheck
  57. gist
  58. git-timemachine
  59. gitconfig-mode
  60. gitignore-mode
  61. god-mode
  62. grizzl
  63. guru-mode
  64. imenu-anywhere
  65. ov
  66. projectile
  67. magit
  68. move-text
  69. operate-on-number
  70. smart-mode-line
  71. smartparens
  72. smartrep
  73. undo-tree
  74. volatile-highlights
  75. which-key
  76. zenburn-theme
  77. zop-to-char)
  78. "A list of packages to ensure are installed at launch.")
  79. (defun prelude-packages-installed-p ()
  80. "Check if all packages in `prelude-packages' are installed."
  81. (every #'package-installed-p prelude-packages))
  82. (defun prelude-require-package (package)
  83. "Install PACKAGE unless already installed."
  84. (unless (memq package prelude-packages)
  85. (add-to-list 'prelude-packages package))
  86. (unless (package-installed-p package)
  87. (package-install package)))
  88. (defun prelude-require-packages (packages)
  89. "Ensure PACKAGES are installed.
  90. Missing packages are installed automatically."
  91. (mapc #'prelude-require-package packages))
  92. (define-obsolete-function-alias 'prelude-ensure-module-deps 'prelude-require-packages)
  93. (defun prelude-install-packages ()
  94. "Install all packages listed in `prelude-packages'."
  95. (unless (prelude-packages-installed-p)
  96. ;; check for new packages (package versions)
  97. (message "%s" "Emacs Prelude is now refreshing its package database...")
  98. (package-refresh-contents)
  99. (message "%s" " done.")
  100. ;; install the missing packages
  101. (prelude-require-packages prelude-packages)))
  102. ;; run package installation
  103. (prelude-install-packages)
  104. (defun prelude-list-foreign-packages ()
  105. "Browse third-party packages not bundled with Prelude.
  106. Behaves similarly to `package-list-packages', but shows only the packages that
  107. are installed and are not in `prelude-packages'. Useful for
  108. removing unwanted packages."
  109. (interactive)
  110. (package-show-package-list
  111. (set-difference package-activated-list prelude-packages)))
  112. (defmacro prelude-auto-install (extension package mode)
  113. "When file with EXTENSION is opened triggers auto-install of PACKAGE.
  114. PACKAGE is installed only if not already present. The file is opened in MODE."
  115. `(add-to-list 'auto-mode-alist
  116. `(,extension . (lambda ()
  117. (unless (package-installed-p ',package)
  118. (package-install ',package))
  119. (,mode)))))
  120. (defvar prelude-auto-install-alist
  121. '(("\\.clj\\'" clojure-mode clojure-mode)
  122. ("\\.cmake\\'" cmake-mode cmake-mode)
  123. ("CMakeLists\\.txt\\'" cmake-mode cmake-mode)
  124. ("\\.coffee\\'" coffee-mode coffee-mode)
  125. ("\\.css\\'" css-mode css-mode)
  126. ("\\.csv\\'" csv-mode csv-mode)
  127. ("Cask" cask-mode cask-mode)
  128. ("\\.d\\'" d-mode d-mode)
  129. ("\\.dart\\'" dart-mode dart-mode)
  130. ("\\.elm\\'" elm-mode elm-mode)
  131. ("\\.ex\\'" elixir-mode elixir-mode)
  132. ("\\.exs\\'" elixir-mode elixir-mode)
  133. ("\\.elixir\\'" elixir-mode elixir-mode)
  134. ("\\.erl\\'" erlang erlang-mode)
  135. ("\\.feature\\'" feature-mode feature-mode)
  136. ("\\.go\\'" go-mode go-mode)
  137. ("\\.groovy\\'" groovy-mode groovy-mode)
  138. ("\\.haml\\'" haml-mode haml-mode)
  139. ("\\.hs\\'" haskell-mode haskell-mode)
  140. ("\\.json\\'" json-mode json-mode)
  141. ("\\.kt\\'" kotlin-mode kotlin-mode)
  142. ("\\.kv\\'" kivy-mode kivy-mode)
  143. ("\\.latex\\'" auctex LaTeX-mode)
  144. ("\\.less\\'" less-css-mode less-css-mode)
  145. ("\\.lua\\'" lua-mode lua-mode)
  146. ("\\.markdown\\'" markdown-mode markdown-mode)
  147. ("\\.md\\'" markdown-mode markdown-mode)
  148. ("\\.ml\\'" tuareg tuareg-mode)
  149. ("\\.pp\\'" puppet-mode puppet-mode)
  150. ("\\.php\\'" php-mode php-mode)
  151. ("\\.proto\\'" protobuf-mode protobuf-mode)
  152. ("\\.pyd\\'" cython-mode cython-mode)
  153. ("\\.pyi\\'" cython-mode cython-mode)
  154. ("\\.pyx\\'" cython-mode cython-mode)
  155. ("PKGBUILD\\'" pkgbuild-mode pkgbuild-mode)
  156. ("\\.rs\\'" rust-mode rust-mode)
  157. ("\\.sass\\'" sass-mode sass-mode)
  158. ("\\.scala\\'" scala-mode scala-mode)
  159. ("\\.scss\\'" scss-mode scss-mode)
  160. ("\\.slim\\'" slim-mode slim-mode)
  161. ("\\.styl\\'" stylus-mode stylus-mode)
  162. ("\\.swift\\'" swift-mode swift-mode)
  163. ("\\.textile\\'" textile-mode textile-mode)
  164. ("\\.thrift\\'" thrift thrift-mode)
  165. ("\\.yml\\'" yaml-mode yaml-mode)
  166. ("\\.yaml\\'" yaml-mode yaml-mode)
  167. ("Dockerfile\\'" dockerfile-mode dockerfile-mode)))
  168. ;; markdown-mode doesn't have autoloads for the auto-mode-alist
  169. ;; so we add them manually if it's already installed
  170. (when (package-installed-p 'markdown-mode)
  171. (add-to-list 'auto-mode-alist '("\\.markdown\\'" . gfm-mode))
  172. (add-to-list 'auto-mode-alist '("\\.md\\'" . gfm-mode)))
  173. (when (package-installed-p 'pkgbuild-mode)
  174. (add-to-list 'auto-mode-alist '("PKGBUILD\\'" . pkgbuild-mode)))
  175. ;; build auto-install mappings
  176. (mapc
  177. (lambda (entry)
  178. (let ((extension (car entry))
  179. (package (cadr entry))
  180. (mode (cadr (cdr entry))))
  181. (unless (package-installed-p package)
  182. (prelude-auto-install extension package mode))))
  183. prelude-auto-install-alist)
  184. (provide 'prelude-packages)
  185. ;; Local Variables:
  186. ;; byte-compile-warnings: (not cl-functions)
  187. ;; End:
  188. ;;; prelude-packages.el ends here