Function: rmail-count-new-messages

rmail-count-new-messages is a byte-compiled function defined in rmail.el.gz.

Signature

(rmail-count-new-messages &optional NOMSG)

Documentation

Count the number of new messages.

The buffer should be narrowed to include only the new messages. Output a helpful message unless NOMSG is non-nil.

Source Code

;; Defined in /usr/src/emacs/lisp/mail/rmail.el.gz
(defun rmail-count-new-messages (&optional nomsg)
  "Count the number of new messages.
The buffer should be narrowed to include only the new messages.
Output a helpful message unless NOMSG is non-nil."
  (let* ((case-fold-search nil)
	 (total-messages 0)
	 (messages-head nil)
	 (deleted-head nil))
    (or nomsg (message "Counting new messages..."))
    (goto-char (point-max))
    ;; Put at the end of messages-head
    ;; the entry for message N+1, which marks
    ;; the end of message N.  (N = number of messages).
    (setq messages-head (list (point-marker)))
    (rmail-set-message-counters-counter (point-min))
    (setq rmail-current-message (1+ rmail-total-messages))
    (setq rmail-total-messages
	  (+ rmail-total-messages total-messages))
    (setq rmail-message-vector
	  (vconcat rmail-message-vector (cdr messages-head)))
    (aset rmail-message-vector
	  rmail-current-message (car messages-head))
    (setq rmail-deleted-vector
	  (concat rmail-deleted-vector deleted-head))
    (setq rmail-summary-vector
	  (vconcat rmail-summary-vector (make-vector total-messages nil)))
    (setq rmail-msgref-vector
	  (vconcat rmail-msgref-vector (make-vector total-messages nil)))
    ;; Fill in the new elements of rmail-msgref-vector.
    (let ((i (1+ (- rmail-total-messages total-messages))))
      (while (<= i rmail-total-messages)
	(aset rmail-msgref-vector i (list i))
	(setq i (1+ i))))
    (goto-char (point-min))
    (or nomsg (message "Counting new messages...done (%d)" total-messages))))