Commit 76e1e40b authored by Richard M. Stallman's avatar Richard M. Stallman
Browse files

* mail/rmail.el (rmail-set-message-counters):

Call rmail-set-message-counters-counter just once.
It returns # msgs after point.
(rmail-set-message-counters-counter):
Arg is now SPOT-TO-FIND.  Return # messages after that one.

* mail/rmail.el (rmail-forget-messages):
Ignore nil elt in rmail-message-vector.  Use dotimes.
parent 5c950923
......@@ -3,6 +3,9 @@
* mail/rmail.el (rmail-get-attr-names):
Accept an attribute header that is too short.
* mail/rmail.el (rmail-forget-messages):
Ignore nil elt in rmail-message-vector. Use dotimes.
* progmodes/compile.el (compilation-goto-locus):
Use next-error-move-function.
......
......@@ -2369,12 +2369,11 @@ change the invisible header text."
(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)))
......@@ -2440,20 +2439,25 @@ Output a helpful message unless NOMSG is non-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))
......@@ -2480,12 +2484,17 @@ the message. Point is at the beginning of the message."
?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)
......@@ -2494,13 +2503,15 @@ the message. Point is at the beginning of the message."
(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))
;; Display a message.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment