Function: nnheader-insert-head

nnheader-insert-head is a byte-compiled function defined in nnheader.el.gz.

Signature

(nnheader-insert-head FILE)

Documentation

Insert the head of the article.

Source Code

;; Defined in /usr/src/emacs/lisp/gnus/nnheader.el.gz
(defun nnheader-insert-head (file)
  "Insert the head of the article."
  (when (file-exists-p file)
    (if (eq nnheader-max-head-length t)
	;; Just read the entire file.
	(nnheader-insert-file-contents file)
      ;; Read blocks of the size specified by `nnheader-head-chop-length'
      ;; until we find a separator.
      (let ((beg 0)
	    (start (point))
	    ;; Use `binary' to prevent the contents from being decoded,
	    ;; or it will change the number of characters that
	    ;; `insert-file-contents' returns.
	    (coding-system-for-read 'binary))
	(while (and (eq nnheader-head-chop-length
			(nth 1 (mm-insert-file-contents
				file nil beg
				(cl-incf beg nnheader-head-chop-length))))
		    ;; CRLF or CR might be used for the line-break code.
		    (prog1 (not (re-search-forward "\n\r?\n\\|\r\r" nil t))
		      (goto-char (point-max)))
		    (or (null nnheader-max-head-length)
			(< beg nnheader-max-head-length))))
	;; Finally decode the contents.
	(when (mm-coding-system-p nnheader-file-coding-system)
	  (decode-coding-region start (point-max)
				nnheader-file-coding-system))))
    t))