Function: package-matches-selector-p

package-matches-selector-p is a byte-compiled function defined in package.el.gz.

Signature

(package-matches-selector-p SELECTOR PKG-DESC)

Documentation

Return non-nil if SELECTOR matches PKG-DESC.

If SELECTOR is t the match always passes. If SELECTOR is a list to a list you can specify a list of conditions. An entry of the form (archive STRING) will match any packages from the archive STRING (see package-archives), and an entry of the form (package SYMBOL) will match any packages whose names match SYMBOL. If any singular condition matches, then the entire selector matches PKG-DESC. If you prefix the list with a symbol not, the rules are inverted.

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/package.el.gz
(defun package-matches-selector-p (selector pkg-desc)
  "Return non-nil if SELECTOR matches PKG-DESC.
If SELECTOR is t the match always passes.  If SELECTOR is a list to a
list you can specify a list of conditions.  An entry of the
form (archive STRING) will match any packages from the archive
STRING (see `package-archives'), and an entry of the form (package
SYMBOL) will match any packages whose names match SYMBOL.  If any
singular condition matches, then the entire selector matches PKG-DESC.
If you prefix the list with a symbol `not', the rules are inverted."
  (let ((archive (package-desc-archive pkg-desc))
        (name (package-desc-name pkg-desc)))
    (pcase-exhaustive selector
      ((and (pred listp) list)
       (xor (any (lambda (ent)
                   (pcase ent
                     ((or `(archive . ,(pred (equal archive)))
                          `(package . ,(pred (eq name))))
                      t)
                     (_ nil)))
                 (if (eq (car list) 'not) (cdr list) list))
            (eq (car list) 'not)))
      ('t t))))