Function: gnus-function-implies-unread-1

gnus-function-implies-unread-1 is a byte-compiled function defined in gnus-agent.el.gz.

Signature

(gnus-function-implies-unread-1 FUNCTION)

Documentation

Recursively evaluate a predicate function to determine whether it can select any read articles. Returns t if the function is known to never return read articles, nil when it is known to always return read articles, and t_nil when the function may return both read and unread articles.

Source Code

;; Defined in /usr/src/emacs/lisp/gnus/gnus-agent.el.gz
(defun gnus-function-implies-unread-1 (function)
  "Recursively evaluate a predicate function to determine whether it can select
any read articles.  Returns t if the function is known to never
return read articles, nil when it is known to always return read
articles, and t_nil when the function may return both read and unread
articles."
  (let ((func (car function))
        (args (mapcar #'gnus-function-implies-unread-1 (cdr function))))
    (cond ((eq func 'and)
           (cond ((memq t args) ; if any argument returns only unread articles
                  ;; then that argument constrains the result to only unread articles.
                  t)
                 ((memq 't_nil args) ; if any argument is indeterminate
                  ;; then the result is indeterminate
                  't_nil)))
          ((eq func 'or)
           (cond ((memq nil args) ; if any argument returns read articles
                  ;; then that argument ensures that the results includes read articles.
                  nil)
                 ((memq 't_nil args) ; if any argument is indeterminate
                  ;; then that argument ensures that the results are indeterminate
                  't_nil)
                 (t ; if all arguments return only unread articles
                  ;; then the result returns only unread articles
                  t)))
          ((eq func 'not)
           (cond ((eq (car args) 't_nil) ; if the argument is indeterminate
                  ; then the result is indeterminate
                  (car args))
                 (t ; otherwise
                  ; toggle the result to be the opposite of the argument
                  (not (car args)))))
          ((eq func 'gnus-agent-read-p)
           nil) ; The read predicate NEVER returns unread articles
          ((eq func 'gnus-agent-false)
           t) ; The false predicate returns t as the empty set excludes all read articles
          ((eq func 'gnus-agent-true)
           nil) ; The true predicate ALWAYS returns read articles
          ((catch 'found-match
             (let ((alist gnus-category-predicate-alist))
               (while alist
                 (if (eq func (cdar alist))
                     (throw 'found-match t)
                   (setq alist (cdr alist))))))
           't_nil) ; All other predicates return read and unread articles
          (t
           (error "Unknown predicate function: %s" function)))))