(defun rmail-forget-messages ()
(unwind-protect
(if (vectorp rmail-message-vector)
- (let* ((i 0)
- (v rmail-message-vector)
+ (let* ((v rmail-message-vector)
(n (length v)))
- (while (< i n)
- (move-marker (aref v i) nil)
- (setq i (1+ i)))))
+ (dotimes (i n)
+ (if (aref v i)
+ (move-marker (aref v i) nil)))))
(setq rmail-message-vector nil)
(setq rmail-msgref-vector nil)
(setq rmail-deleted-vector nil)))
;; 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 (min (point) point-save))
- (setq messages-after-point total-messages)
+ (setq messages-after-point
+ (or (rmail-set-message-counters-counter (min (point) point-save))
+ 0))
- ;; Determine how many precede point.
- (rmail-set-message-counters-counter)
(setq rmail-total-messages total-messages)
(setq rmail-current-message
(min total-messages
(max 1 (- total-messages messages-after-point))))
- (setq rmail-message-vector
- (apply 'vector (cons (point-min-marker) messages-head))
- rmail-deleted-vector (concat "0" deleted-head)
- rmail-summary-vector (make-vector rmail-total-messages nil)
+
+ ;; Make an element 0 in rmail-message-vector and rmail-deleted-vector
+ ;; which will never be used.
+ (push nil messages-head)
+ (push ?0 deleted-head)
+ (setq rmail-message-vector (apply 'vector messages-head)
+ rmail-deleted-vector (concat deleted-head))
+
+ (setq rmail-summary-vector (make-vector rmail-total-messages nil)
rmail-msgref-vector (make-vector (1+ rmail-total-messages) nil))
+
(let ((i 0))
(while (<= i rmail-total-messages)
(aset rmail-msgref-vector i (list i))
?D
?\s) deleted-head))))
-(defun rmail-set-message-counters-counter (&optional stop)
- ;; Collect the start position for each message into 'messages-head.
- (let ((start (point)))
- (while (search-backward "\n\nFrom " stop t)
+(defun rmail-set-message-counters-counter (&optional spot-to-find)
+ "Collect the start positions of messages in list `messages-head'.
+Return the number of messages after the one containing SPOT-TO-FIND."
+ (let ((start (point))
+ messages-after-spot)
+ (while (search-backward "\n\nFrom " nil t)
(forward-char 2)
(when (looking-at rmail-unix-mail-delimiter)
+ (if (and (<= (point) spot-to-find)
+ (null messages-after-spot))
+ (setq messages-after-spot total-messages))
(rmail-collect-deleted start)
(setq messages-head (cons (point-marker) messages-head)
total-messages (1+ total-messages)
(if (zerop (% total-messages 20))
(message "Counting messages...%d" total-messages))))
;; Handle the first message, maybe.
- (if stop
- (goto-char stop)
- (goto-char (point-min)))
+ (goto-char (point-min))
(unless (not (looking-at rmail-unix-mail-delimiter))
+ (if (and (<= (point) spot-to-find)
+ (null messages-after-spot))
+ (setq messages-after-spot total-messages))
(rmail-collect-deleted start)
(setq messages-head (cons (point-marker) messages-head)
- total-messages (1+ total-messages)))))
+ total-messages (1+ total-messages)))
+ messages-after-spot))
\f
;; Display a message.