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.

110 lines
3.1 KiB

14 years ago
  1. ;;; melpa.el --- special handling for the MELPA repository
  2. ;;
  3. ;; Copyright 2012 Donald Ephraim Curtis
  4. ;;
  5. ;; Author: Donald Ephraim Curtis <dcurtis@milkbox.net>
  6. ;; URL: https://github.com/milkypostman/melpa
  7. ;; Version: 0.3
  8. ;;
  9. ;;
  10. ;; Credits:
  11. ;; Steve Purcell
  12. ;;
  13. ;;
  14. ;; Installation:
  15. ;;
  16. ;; (progn
  17. ;; (switch-to-buffer
  18. ;; (url-retrieve-synchronously
  19. ;; "https://raw.github.com/milkypostman/melpa/master/melpa.el"))
  20. ;; (package-install-from-buffer (package-buffer-info) 'single))
  21. ;;
  22. ;;
  23. ;;
  24. ;; Code goes here
  25. ;;
  26. ;;;###autoload
  27. (defcustom package-archive-enable-alist nil
  28. "Optional Alist of enabled packages used by `package-filter'.
  29. The format is (ARCHIVE . PACKAGE ...), where ARCHIVE is a string
  30. matching an archive name in `package-archives', PACKAGE is a
  31. symbol of a package in ARCHIVE to enable.
  32. If no ARCHIVE exists in the alist, all packages are enabled."
  33. :group 'package
  34. :type '(alist :key-type string :value-type (repeat symbol)))
  35. ;;;###autoload
  36. (defcustom package-archive-exclude-alist nil
  37. "Alist of packages excluded by `package-filter'.
  38. The format is (ARCHIVE . PACKAGE ...), where ARCHIVE is a string
  39. matching an archive name in `package-archives', PACKAGE is a
  40. symbol of a package in that archive to exclude.
  41. Any specified package is excluded regardless of the value of
  42. `package-archive-enable-alist'"
  43. :group 'package
  44. :type '(alist :key-type string :value-type (repeat symbol)))
  45. ;;;###autoload
  46. (defcustom package-filter-function 'package-filter
  47. "Optional predicate function used to internally
  48. filter packages used by package.el.
  49. Return nil to filter a function from the list.
  50. The function is called with the arguments PACKAGE VERSION ARCHIVE, where
  51. PACKAGE is a symbol, VERSION is a vector as produced by `version-to-list', and
  52. ARCHIVE is the string name of the package archive."
  53. :group 'package
  54. :type 'function)
  55. ;;;###autoload
  56. (defadvice package-compute-transaction
  57. (before
  58. package-compute-transaction-reverse (package-list requirements)
  59. activate compile)
  60. "reverse the requirements"
  61. (setq requirements (reverse requirements))
  62. (print requirements))
  63. ;;;###autoload
  64. (defadvice package--add-to-archive-contents
  65. (around package-filter-add-to-archive-contents (package archive)
  66. activate compile)
  67. "Add filtering of available packages using `package-filter-function',
  68. if non-nil."
  69. (when (and package-filter-function
  70. (funcall package-filter-function
  71. (car package)
  72. (package-desc-vers (cdr package))
  73. archive))
  74. ad-do-it))
  75. ;;;###autoload
  76. (defun package-filter (package version archive)
  77. "Check package against enabled and excluded list for the `archive'.
  78. Filter packages not in the associated list for `archive' in
  79. `package-archive-enable-alist'.
  80. Filter packages in the associated list for `archive' in
  81. `package-archive-exclude-alist'."
  82. (let ((enable-rules (cdr (assoc archive package-archive-enable-alist)))
  83. (exclude-rules (cdr (assoc archive package-archive-exclude-alist))))
  84. (and (not (memq package exclude-rules))
  85. (or (not enable-rules)
  86. (memq package enable-rules)))))
  87. (provide 'melpa)
  88. ;;; melpa.el ends here