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