Function: gnus-summary-find-matching

gnus-summary-find-matching is a byte-compiled function defined in gnus-sum.el.gz.

Signature

(gnus-summary-find-matching HEADER REGEXP &optional BACKWARD UNREAD NOT-CASE-FOLD NOT-MATCHING)

Documentation

Return a list of all articles that match REGEXP on HEADER.

The search stars on the current article and goes forwards unless BACKWARD is non-nil. If BACKWARD is all, do all articles. If UNREAD is non-nil, only unread articles will be taken into consideration. If NOT-CASE-FOLD, case won't be folded in the comparisons. If NOT-MATCHING, return a list of all articles that not match REGEXP on HEADER.

Source Code

;; Defined in /usr/src/emacs/lisp/gnus/gnus-sum.el.gz
(defun gnus-summary-find-matching (header regexp &optional backward unread
					  not-case-fold not-matching)
  "Return a list of all articles that match REGEXP on HEADER.
The search stars on the current article and goes forwards unless
BACKWARD is non-nil.  If BACKWARD is `all', do all articles.
If UNREAD is non-nil, only unread articles will
be taken into consideration.  If NOT-CASE-FOLD, case won't be folded
in the comparisons.  If NOT-MATCHING, return a list of all articles
that not match REGEXP on HEADER."
  (let ((case-fold-search (not not-case-fold))
	articles func)
    (if (consp header)
	(if (eq (car header) 'extra)
	    (setq func
                  (let ((x (cdr header)))
		    (lambda (h)
		      (or (cdr (assq x (mail-header-extra h)))
			  ""))))
	  (error "%s is an invalid header" header))
      (unless (fboundp (intern (concat "mail-header-" header)))
	(error "%s is not a valid header" header))
      (setq func (intern (concat "mail-header-" header))))
    (dolist (d (if (eq backward 'all)
		   gnus-newsgroup-data
		 (gnus-data-find-list
		  (gnus-summary-article-number)
		  (gnus-data-list backward))))
      (when (and (or (not unread)	; We want all articles...
		     (gnus-data-unread-p d)) ; Or just unreads.
		 (mail-header-p (gnus-data-header d)) ; It's not a pseudo.
		 (if not-matching
		     (not (string-match
			   regexp
			   (funcall func (gnus-data-header d))))
		   (string-match regexp
				 (funcall func (gnus-data-header d)))))
	(push (gnus-data-number d) articles))) ; Success!
    (nreverse articles)))