Function: message-carefully-insert-headers
message-carefully-insert-headers is a byte-compiled function defined
in message.el.gz.
Signature
(message-carefully-insert-headers HEADERS)
Documentation
Insert the HEADERS, an alist, into the message buffer.
Does not insert the headers when they are already present there
or in the synonym headers, defined by message-header-synonyms.
Source Code
;; Defined in /usr/src/emacs/lisp/gnus/message.el.gz
(defun message-carefully-insert-headers (headers)
"Insert the HEADERS, an alist, into the message buffer.
Does not insert the headers when they are already present there
or in the synonym headers, defined by `message-header-synonyms'."
;; FIXME: Should compare only the address and not the full name. Comparison
;; should be done case-folded (and with `string=' rather than
;; `string-match').
;; (mail-strip-quoted-names "Foo Bar <foo@bar>, bla@fasel (Bla Fasel)")
(dolist (header headers)
(let* ((header-name (symbol-name (car header)))
(new-header (cdr header))
(synonyms (cl-loop for synonym in message-header-synonyms
when (memq (car header) synonym) return synonym))
(old-header
(cl-loop for synonym in synonyms
for old-header = (mail-fetch-field (symbol-name synonym))
when (and old-header (string-match new-header old-header))
return synonym)))
(if old-header
(message "already have `%s' in `%s'" new-header old-header)
(when (and (message-position-on-field header-name)
(setq old-header (mail-fetch-field header-name))
(not (string-match "\\` *\\'" old-header)))
(insert ", "))
(insert new-header)))))