Function: nnmail-fancy-expiry-target

nnmail-fancy-expiry-target is a byte-compiled function defined in nnmail.el.gz.

Signature

(nnmail-fancy-expiry-target GROUP)

Documentation

Return a target expiry group determined by nnmail-fancy-expiry-targets.

Source Code

;; Defined in /usr/src/emacs/lisp/gnus/nnmail.el.gz
(defun nnmail-fancy-expiry-target (_group)
  "Return a target expiry group determined by `nnmail-fancy-expiry-targets'."
  (let* (header
	 (case-fold-search nil)
	 (from (or (message-fetch-field "from") ""))
	 (to (or (message-fetch-field "to") ""))
	 (date (message-fetch-field "date"))
	 (target 'delete))
    (setq date (if date
		   (condition-case err
		       (date-to-time date)
		     (error
		      (message "%s" (error-message-string err))
		      (current-time)))
		 (current-time)))
    (dolist (regexp-target-pair (reverse nnmail-fancy-expiry-targets) target)
      (setq header (car regexp-target-pair))
      (cond
       ;; If the header is to-from then match against the
       ;; To or From header
       ((and (equal header 'to-from)
	     (or (string-match (cadr regexp-target-pair) from)
		 (and (string-match (cadr regexp-target-pair) to)
		      (let ((mail-dont-reply-to-names
			     (message-dont-reply-to-names)))
			(equal (if (fboundp 'rmail-dont-reply-to)
				   (rmail-dont-reply-to from)
				 (mail-dont-reply-to from)) "")))))
	(setq target (format-time-string (caddr regexp-target-pair) date)))
       ((and (not (equal header 'to-from))
	     (string-match (cadr regexp-target-pair)
			   (or
			    (message-fetch-field header)
			    "")))
	(setq target
	      (format-time-string (caddr regexp-target-pair) date)))))))