Function: feedmail-deduce-address-list

feedmail-deduce-address-list is a byte-compiled function defined in feedmail.el.gz.

Signature

(feedmail-deduce-address-list MESSAGE-BUFFER HEADER-START HEADER-END ADDR-REGEXP ADDRESS-LIST)

Documentation

Get address list with all comments and other excitement trimmed.

Addresses are collected only from headers whose names match the fourth argument. Returns a list of strings. Duplicate addresses will have been weeded out.

Source Code

;; Defined in /usr/src/emacs/lisp/mail/feedmail.el.gz
(defun feedmail-deduce-address-list (message-buffer header-start header-end addr-regexp address-list)
  "Get address list with all comments and other excitement trimmed.
Addresses are collected only from headers whose names match the fourth
argument.  Returns a list of strings.  Duplicate addresses will have
been weeded out."
  (feedmail-say-debug ">in-> feedmail-deduce-address-list %s %s" addr-regexp address-list)
  (let ((simple-address)
	(address-blob)
	(this-line)
	(this-line-end))

    (with-current-buffer (get-buffer-create " *FQM scratch*")
      (erase-buffer)
      (insert-buffer-substring message-buffer header-start header-end)
      (goto-char (point-min))
      (let ((case-fold-search t))
	(while (re-search-forward addr-regexp (point-max) t)
	  (replace-match "")
	  (setq this-line (match-beginning 0))
	  (forward-line 1)
	  ;; get any continuation lines
	  (while (and (looking-at "^[ \t]+") (< (point) (point-max)))
	    (forward-line 1))
	  (setq this-line-end (point-marker))
	  ;; only keep if we don't have it already
	  (setq address-blob
		(mail-strip-quoted-names (buffer-substring-no-properties this-line this-line-end)))
	  (while (string-match "\\([, \t\n\r]*\\)\\([^, \t\n\r]+\\)" address-blob)
	    (setq simple-address (substring address-blob (match-beginning 2) (match-end 2)))
	    (setq address-blob (replace-match "" t t address-blob))
	    (if (not (member simple-address address-list))
		(push simple-address address-list)))
	  ))
      (kill-buffer nil))
    (identity address-list)))