Clean up package installation code

This commit is contained in:
Bozhidar Batsov 2013-07-23 15:53:17 +03:00
parent cc29e0f2bb
commit 1ad14ccf91
2 changed files with 20 additions and 8 deletions

View file

@ -351,7 +351,13 @@ If you'd like to add some auto installation of packages in your
personal config use the following code:
```lisp
(prelude-ensure-module-deps '(some-package some-other-package))
(prelude-require-packages '(some-package some-other-package))
```
If you require just a single package you can also use:
```lisp
(prelude-require-package 'some-package)
```
#### Disabling whitespace-mode

View file

@ -54,6 +54,18 @@
"Check if all packages in `prelude-packages' are installed."
(every #'package-installed-p prelude-packages))
(defun prelude-require-package (package)
"Install PACKAGE unless already installed."
(unless (package-installed-p package)
(package-install package)))
(defun prelude-require-packages (packages)
"Ensure PACKAGES are installed.
Missing packages are installed automatically."
(mapc #'prelude-require-package packages))
(defalias 'prelude-ensure-module-deps 'prelude-require-packages)
(defun prelude-install-packages ()
"Install all packages listed in `prelude-packages'."
(unless (prelude-packages-installed-p)
@ -62,8 +74,7 @@
(package-refresh-contents)
(message "%s" " done.")
;; install the missing packages
(mapc #'package-install
(remove-if #'package-installed-p prelude-packages))))
(prelude-require-packages prelude-packages)))
(prelude-install-packages)
@ -123,11 +134,6 @@ PACKAGE is installed only if not already present. The file is opened in MODE."
(prelude-auto-install extension package mode))))
prelude-auto-install-alist)
(defun prelude-ensure-module-deps (packages)
"Ensure PACKAGES are installed.
Missing packages are installed automatically."
(mapc #'package-install (remove-if #'package-installed-p packages)))
(provide 'prelude-packages)
;; Local Variables:
;; byte-compile-warnings: (not cl-functions)