al-quelpa.el 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. ;;; al-quelpa.el --- Additional functionality for Quelpa
  2. ;; Copyright © 2014-2016, 2018 Alex Kost
  3. ;; This program is free software; you can redistribute it and/or modify
  4. ;; it under the terms of the GNU General Public License as published by
  5. ;; the Free Software Foundation, either version 3 of the License, or
  6. ;; (at your option) any later version.
  7. ;; This program is distributed in the hope that it will be useful,
  8. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. ;; GNU General Public License for more details.
  11. ;; You should have received a copy of the GNU General Public License
  12. ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. ;;; Code:
  14. (defvar al/main-packages nil
  15. "List of main packages that should be installed in a common way.")
  16. (defvar al/extra-packages nil
  17. "List of packages used from rarely to never.")
  18. (defun al/all-packages ()
  19. "Return all package recipes I use."
  20. (append al/main-packages
  21. al/extra-packages))
  22. (defun al/package-name (name-or-recipe)
  23. "Return package name (symbol) by NAME-OR-RECIPE."
  24. (if (listp name-or-recipe)
  25. (car name-or-recipe)
  26. name-or-recipe))
  27. (defun al/package-recipe (name-or-recipe)
  28. "Return package recipe by NAME-OR-RECIPE."
  29. (if (listp name-or-recipe)
  30. name-or-recipe
  31. (cl-find-if (lambda (recipe)
  32. (eq name-or-recipe (al/package-name recipe)))
  33. (al/all-packages))))
  34. (defun al/read-package-name ()
  35. "Prompt for and return a package name (symbol)."
  36. (let ((names (mapcar (lambda (recipe)
  37. (symbol-name (al/package-name recipe)))
  38. (al/all-packages))))
  39. (intern (completing-read "Update/install: " names nil t))))
  40. (declare-function quelpa "quelpa" t)
  41. ;;;###autoload
  42. (defun al/quelpa (&rest recipes)
  43. "Install/update packages using RECIPES.
  44. Each recipe from RECIPES should be either a MELPA package
  45. name (symbol) or a full recipe (list).
  46. Interactively, prompt for a package to update/install.
  47. With \\[universal-argument], update all packages except `al/extra-packages'.
  48. With \\[universal-argument] \\[universal-argument], update all packages."
  49. (interactive
  50. (cond ((equal current-prefix-arg '(4))
  51. al/main-packages)
  52. ((equal current-prefix-arg '(16))
  53. (al/all-packages))
  54. (t (list (al/package-recipe (al/read-package-name))))))
  55. (unless (fboundp 'quelpa)
  56. (with-temp-buffer
  57. (url-insert-file-contents
  58. "https://framagit.org/steckerhalter/quelpa/raw/master/bootstrap.el")
  59. (eval-buffer)))
  60. (mapc #'quelpa recipes))
  61. (provide 'al-quelpa)
  62. ;;; al-quelpa.el ends here