Function: nnheader-head-make-header
nnheader-head-make-header is a byte-compiled function defined in
nnheader.el.gz.
Signature
(nnheader-head-make-header NUMBER)
Documentation
Return a full mail header with article NUMBER.
Do this using data of type head in the current buffer.
Source Code
;; Defined in /usr/src/emacs/lisp/gnus/nnheader.el.gz
(defsubst nnheader-head-make-header (number)
"Return a full mail header with article NUMBER.
Do this using data of type `head' in the current buffer."
(let ((p (point-min))
(cur (current-buffer))
in-reply-to chars lines end ref)
;; This implementation of this function, with nine
;; search-forwards instead of the one re-search-forward and a
;; case (which basically was the old function) is actually
;; about twice as fast, even though it looks messier. You
;; can't have everything, I guess. Speed and elegance don't
;; always go hand in hand.
(make-full-mail-header
;; Number.
number
;; Subject.
(progn
(goto-char p)
(if (search-forward "\nsubject:" nil t)
(funcall gnus-decode-encoded-word-function
(nnheader-header-value))
"(none)"))
;; From.
(progn
(goto-char p)
(if (search-forward "\nfrom:" nil t)
(funcall gnus-decode-encoded-address-function
(nnheader-header-value))
"(nobody)"))
;; Date.
(progn
(goto-char p)
(if (search-forward "\ndate:" nil t)
(nnheader-header-value) ""))
;; Message-ID.
(progn
(goto-char p)
(if (re-search-forward
"^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
;; We do it this way to make sure the Message-ID
;; is (somewhat) syntactically valid.
(buffer-substring (match-beginning 1)
(match-end 1))
;; If there was no message-id, we just fake one to make
;; subsequent routines simpler.
(nnheader-generate-fake-message-id number)))
;; References.
(progn
(goto-char p)
(if (search-forward "\nreferences:" nil t)
(progn
(setq end (point))
(prog1
(nnheader-header-value)
(setq ref
(buffer-substring
(progn
(end-of-line)
(search-backward ">" end t)
(1+ (point)))
(progn
(search-backward "<" end t)
(point))))))
;; Get the references from the in-reply-to header if there
;; were no references and the in-reply-to header looks
;; promising.
(if (and (search-forward "\nin-reply-to:" nil t)
(setq in-reply-to (nnheader-header-value))
(string-match "<[^>]+>" in-reply-to))
(let (ref2)
(setq ref (substring in-reply-to (match-beginning 0)
(match-end 0)))
(while (string-match "<[^>]+>" in-reply-to (match-end 0))
(setq ref2 (substring in-reply-to (match-beginning 0)
(match-end 0)))
(when (> (length ref2) (length ref))
(setq ref ref2)))
ref)
nil)))
;; Chars.
(progn
(goto-char p)
(if (search-forward "\nchars: " nil t)
(if (numberp (setq chars (ignore-errors (read cur))))
chars -1)
-1))
;; Lines.
(progn
(goto-char p)
(if (search-forward "\nlines: " nil t)
(if (numberp (setq lines (ignore-errors (read cur))))
lines -1)
-1))
;; Xref.
(progn
(goto-char p)
(and (search-forward "\nxref:" nil t)
(nnheader-header-value)))
;; Extra.
(when nnmail-extra-headers
(let ((extra nnmail-extra-headers)
out)
(while extra
(goto-char p)
(when (search-forward
(concat "\n" (symbol-name (car extra)) ":") nil t)
(push (cons (car extra) (nnheader-header-value))
out))
(pop extra))
out)))))