comparison lisp/mail/rmail.el @ 104197:b0dfefd17d86

(rmail-add-mbox-headers, rmail-set-message-counters-counter): Search for rmail-unix-mail-delimiter instead of just "From ". (Bug#4076)
author Eli Zaretskii <eliz@gnu.org>
date Sat, 08 Aug 2009 10:05:30 +0000
parents e59e70025fe8
children 0462fa7b12af
comparison
equal deleted inserted replaced
104196:779845050ee8 104197:b0dfefd17d86
2070 (save-restriction 2070 (save-restriction
2071 (let ((count 0) 2071 (let ((count 0)
2072 (start (point)) 2072 (start (point))
2073 (value "------U-") 2073 (value "------U-")
2074 (case-fold-search nil) 2074 (case-fold-search nil)
2075 limit) 2075 (delim (concat "\n\n" rmail-unix-mail-delimiter))
2076 limit stop)
2076 ;; Detect an empty inbox file. 2077 ;; Detect an empty inbox file.
2077 (unless (= start (point-max)) 2078 (unless (= start (point-max))
2078 ;; Scan the new messages to establish a count and to ensure that 2079 ;; Scan the new messages to establish a count and to ensure that
2079 ;; an attribute header is present. 2080 ;; an attribute header is present.
2080 (while (looking-at "From ") 2081 (if (looking-at rmail-unix-mail-delimiter)
2081 ;; Determine if a new attribute header needs to be added to 2082 (while (not stop)
2082 ;; the message. 2083 ;; Determine if a new attribute header needs to be
2083 (if (search-forward "\n\n" nil t) 2084 ;; added to the message.
2084 (progn 2085 (if (search-forward "\n\n" nil t)
2085 (setq count (1+ count)) 2086 (progn
2086 (narrow-to-region start (point)) 2087 (setq count (1+ count))
2087 (unless (mail-fetch-field rmail-attribute-header) 2088 (narrow-to-region start (point))
2088 (backward-char 1) 2089 (unless (mail-fetch-field rmail-attribute-header)
2089 (insert rmail-attribute-header ": " value "\n")) 2090 (backward-char 1)
2090 (widen)) 2091 (insert rmail-attribute-header ": " value "\n"))
2091 (rmail-error-bad-format)) 2092 (widen))
2092 ;; Move to the next message. 2093 (rmail-error-bad-format))
2093 (if (search-forward "\n\nFrom " nil 'move) 2094 ;; Move to the next message.
2094 (forward-char -5)) 2095 (if (not (re-search-forward delim nil 'move))
2095 (setq start (point)))) 2096 (setq stop t)
2097 (goto-char (match-beginning 0))
2098 (forward-char 2))
2099 (setq start (point)))))
2096 count)))) 2100 count))))
2097 2101
2098 (defun rmail-get-header-1 (name) 2102 (defun rmail-get-header-1 (name)
2099 "Subroutine of `rmail-get-header'. 2103 "Subroutine of `rmail-get-header'.
2100 Narrow to header, call `mail-fetch-field' to find header NAME." 2104 Narrow to header, call `mail-fetch-field' to find header NAME."
2478 (defun rmail-set-message-counters-counter (&optional stop) 2482 (defun rmail-set-message-counters-counter (&optional stop)
2479 ;; Collect the start position for each message into 'messages-head. 2483 ;; Collect the start position for each message into 'messages-head.
2480 (let ((start (point))) 2484 (let ((start (point)))
2481 (while (search-backward "\n\nFrom " stop t) 2485 (while (search-backward "\n\nFrom " stop t)
2482 (forward-char 2) 2486 (forward-char 2)
2483 (rmail-collect-deleted start) 2487 (when (looking-at rmail-unix-mail-delimiter)
2484 (setq messages-head (cons (point-marker) messages-head) 2488 (rmail-collect-deleted start)
2485 total-messages (1+ total-messages) 2489 (setq messages-head (cons (point-marker) messages-head)
2486 start (point)) 2490 total-messages (1+ total-messages)
2487 ;; Show progress after every 20 messages or so. 2491 start (point))
2488 (if (zerop (% total-messages 20)) 2492 ;; Show progress after every 20 messages or so.
2489 (message "Counting messages...%d" total-messages))) 2493 (if (zerop (% total-messages 20))
2494 (message "Counting messages...%d" total-messages))))
2490 ;; Handle the first message, maybe. 2495 ;; Handle the first message, maybe.
2491 (if stop 2496 (if stop
2492 (goto-char stop) 2497 (goto-char stop)
2493 (goto-char (point-min))) 2498 (goto-char (point-min)))
2494 (unless (not (looking-at "From ")) 2499 (unless (not (looking-at rmail-unix-mail-delimiter))
2495 (rmail-collect-deleted start) 2500 (rmail-collect-deleted start)
2496 (setq messages-head (cons (point-marker) messages-head) 2501 (setq messages-head (cons (point-marker) messages-head)
2497 total-messages (1+ total-messages))))) 2502 total-messages (1+ total-messages)))))
2498 2503
2499 ;; Display a message. 2504 ;; Display a message.