Function: rmail-add-mbox-headers

rmail-add-mbox-headers is a byte-compiled function defined in rmail.el.gz.

Signature

(rmail-add-mbox-headers)

Documentation

Validate the RFC 822 (or later) format for the new messages.

Point should be at the first new message. An error is signaled if the new messages are not RFC 822 (or later) compliant. Unless an Rmail attribute header already exists, add it to the new messages. Return the number of new messages.

Source Code

;; Defined in /usr/src/emacs/lisp/mail/rmail.el.gz
(defun rmail-add-mbox-headers ()
  "Validate the RFC 822 (or later) format for the new messages.
Point should be at the first new message.
An error is signaled if the new messages are not RFC 822 (or later)
compliant.
Unless an Rmail attribute header already exists, add it to the
new messages.  Return the number of new messages."
  (save-excursion
    (save-restriction
      (let ((count 0)
	    (start (point))
	    (value "------U-")
	    (case-fold-search nil)
	    (delim (concat "\n\n" rmail-unix-mail-delimiter))
	    stop)
	;; Detect an empty inbox file.
	(unless (= start (point-max))
	  ;; Scan the new messages to establish a count and to ensure that
	  ;; an attribute header is present.
	  (if (looking-at rmail-unix-mail-delimiter)
	      (while (not stop)
		;; Determine if a new attribute header needs to be
		;; added to the message.
		(if (search-forward "\n\n" nil t)
		    (progn
		      (setq count (1+ count))
		      (narrow-to-region start (point))
		      (unless (mail-fetch-field rmail-attribute-header)
			(backward-char 1)
			(insert rmail-attribute-header ": " value "\n"))
		      (widen))
		  (rmail-error-bad-format))
		;; Move to the next message.
		(if (not (re-search-forward delim nil 'move))
		    (setq stop t)
		  (goto-char (match-beginning 0))
		  (forward-char 2))
		(setq start (point)))
	    (rmail-error-bad-format)))
	count))))