Function: mail-dont-reply-to

mail-dont-reply-to is a byte-compiled function defined in mail-utils.el.gz.

Signature

(mail-dont-reply-to DESTINATIONS)

Documentation

Prune addresses from DESTINATIONS, a list of recipient addresses.

Remove all addresses matching mail-dont-reply-to-names from the comma-separated list, and return the pruned list.

Aliases

rmail-dont-reply-to (obsolete since 24.1)

Source Code

;; Defined in /usr/src/emacs/lisp/mail/mail-utils.el.gz
(defun mail-dont-reply-to (destinations)
  "Prune addresses from DESTINATIONS, a list of recipient addresses.
Remove all addresses matching `mail-dont-reply-to-names' from the
comma-separated list, and return the pruned list."
  ;; FIXME this (setting a user option the first time a command is used)
  ;; is somewhat strange.  Normally one would never set the option,
  ;; but instead fall back to the default so long as it was nil.
  ;; Or just set the default directly in the defcustom.
  (if (null mail-dont-reply-to-names)
      (setq mail-dont-reply-to-names
	     ;; `rmail-default-dont-reply-to-names' is obsolete.
	    (let ((a (bound-and-true-p rmail-default-dont-reply-to-names))
		  (b (if (> (length user-mail-address) 0)
			 (concat "\\`" (regexp-quote user-mail-address) "\\'"))))
	      (cond ((and a b) (concat a "\\|" b))
		    ((or a b))))))
  ;; Split up DESTINATIONS and match each element separately.
  (let ((start-pos 0) (cur-pos 0)
	(case-fold-search t))
    (while start-pos
      (setq cur-pos (string-match "[,\"]" destinations cur-pos))
      (if (and cur-pos (equal (match-string 0 destinations) "\""))
	  ;; Search for matching quote.
	  (let ((next-pos (string-search "\"" destinations (1+ cur-pos))))
	    (if next-pos
		(setq cur-pos (1+ next-pos))
	      ;; If the open-quote has no close-quote,
	      ;; delete the open-quote to get something well-defined.
	      ;; This case is not valid, but it can happen if things
	      ;; are weird elsewhere.
	      (setq destinations (concat (substring destinations 0 cur-pos)
				    (substring destinations (1+ cur-pos))))
	      (setq cur-pos start-pos)))
	(let* ((address (substring destinations start-pos cur-pos))
	       (naked-address (mail-strip-quoted-names address)))
	  (if (and mail-dont-reply-to-names
		   (string-match mail-dont-reply-to-names naked-address))
	      (setq destinations (concat (substring destinations 0 start-pos)
				    (and cur-pos (substring destinations
							    (1+ cur-pos))))
		    cur-pos start-pos)
	    (setq cur-pos (and cur-pos (1+ cur-pos))
		  start-pos cur-pos))))))
  ;; get rid of any trailing commas
  (let ((pos (string-match "[ ,\t\n]*\\'" destinations)))
    (if pos
        (setq destinations (substring destinations 0 pos))))
  ;; remove leading spaces. they bother me.
  (if (string-match "\\(\\s \\|,\\)*" destinations)
      (substring destinations (match-end 0))
    destinations))