diff options
| author | Chong Yidong | 2008-12-20 04:07:07 +0000 |
|---|---|---|
| committer | Chong Yidong | 2008-12-20 04:07:07 +0000 |
| commit | 2b8e6500ca2300931b1eecce57838f02fb85edc6 (patch) | |
| tree | 0f0b086e9950a41005a212b47b1b062e269d206c | |
| parent | 8b176528f28ca47619885a4871f973020eeebebf (diff) | |
| download | emacs-2b8e6500ca2300931b1eecce57838f02fb85edc6.tar.gz emacs-2b8e6500ca2300931b1eecce57838f02fb85edc6.zip | |
(pmail-get-new-mail): Call pmail-swap-buffers-maybe.
(pmail-get-new-mail-1): Adjust restriction after calling
pmail-insert-inbox-text.
(pmail-add-mbox-headers): Use save-restriction.
| -rw-r--r-- | lisp/mail/pmail.el | 60 |
1 files changed, 33 insertions, 27 deletions
diff --git a/lisp/mail/pmail.el b/lisp/mail/pmail.el index 7f7665de8ad..ce48cf3ada1 100644 --- a/lisp/mail/pmail.el +++ b/lisp/mail/pmail.el | |||
| @@ -1581,6 +1581,7 @@ It returns t if it got any new messages." | |||
| 1581 | (or (verify-visited-file-modtime (current-buffer)) | 1581 | (or (verify-visited-file-modtime (current-buffer)) |
| 1582 | (find-file (buffer-file-name))) | 1582 | (find-file (buffer-file-name))) |
| 1583 | (set-buffer pmail-buffer) | 1583 | (set-buffer pmail-buffer) |
| 1584 | (pmail-swap-buffers-maybe) | ||
| 1584 | (pmail-maybe-set-message-counters) | 1585 | (pmail-maybe-set-message-counters) |
| 1585 | (widen) | 1586 | (widen) |
| 1586 | ;; Get rid of all undo records for this buffer. | 1587 | ;; Get rid of all undo records for this buffer. |
| @@ -1626,7 +1627,8 @@ It returns t if it got any new messages." | |||
| 1626 | (let ((new-messages 0) | 1627 | (let ((new-messages 0) |
| 1627 | (spam-filter-p (and (featurep 'rmail-spam-filter) | 1628 | (spam-filter-p (and (featurep 'rmail-spam-filter) |
| 1628 | pmail-use-spam-filter)) | 1629 | pmail-use-spam-filter)) |
| 1629 | blurb result success suffix) | 1630 | (blurb "") |
| 1631 | result success suffix) | ||
| 1630 | (narrow-to-region (point) (point)) | 1632 | (narrow-to-region (point) (point)) |
| 1631 | ;; Read in the contents of the inbox files, renaming them as | 1633 | ;; Read in the contents of the inbox files, renaming them as |
| 1632 | ;; necessary, and adding to the list of files to delete | 1634 | ;; necessary, and adding to the list of files to delete |
| @@ -1637,6 +1639,8 @@ It returns t if it got any new messages." | |||
| 1637 | ;; Scan the new text and convert each message to | 1639 | ;; Scan the new text and convert each message to |
| 1638 | ;; Pmail/mbox format. | 1640 | ;; Pmail/mbox format. |
| 1639 | (goto-char (point-min)) | 1641 | (goto-char (point-min)) |
| 1642 | (skip-chars-forward " \n") | ||
| 1643 | (narrow-to-region (point) (point-max)) | ||
| 1640 | (unwind-protect | 1644 | (unwind-protect |
| 1641 | (setq new-messages (pmail-add-mbox-headers) | 1645 | (setq new-messages (pmail-add-mbox-headers) |
| 1642 | success t) | 1646 | success t) |
| @@ -1953,30 +1957,31 @@ compliant. | |||
| 1953 | Unless an Rmail attribute header already exists, add it to the | 1957 | Unless an Rmail attribute header already exists, add it to the |
| 1954 | new messages. Return the number of new messages." | 1958 | new messages. Return the number of new messages." |
| 1955 | (save-excursion | 1959 | (save-excursion |
| 1956 | (let ((count 0) | 1960 | (save-restriction |
| 1957 | (start (point)) | 1961 | (let ((count 0) |
| 1958 | (value "------U") | 1962 | (start (point)) |
| 1959 | limit) | 1963 | (value "------U") |
| 1960 | ;; Detect an empty inbox file. | 1964 | limit) |
| 1961 | (unless (= start (point-max)) | 1965 | ;; Detect an empty inbox file. |
| 1962 | ;; Scan the new messages to establish a count and to insure that | 1966 | (unless (= start (point-max)) |
| 1963 | ;; an attribute header is present. | 1967 | ;; Scan the new messages to establish a count and to insure that |
| 1964 | (while (looking-at "From ") | 1968 | ;; an attribute header is present. |
| 1965 | ;; Determine if a new attribute header needs to be added to | 1969 | (while (looking-at "From ") |
| 1966 | ;; the message. | 1970 | ;; Determine if a new attribute header needs to be added to |
| 1967 | (if (search-forward "\n\n" nil t) | 1971 | ;; the message. |
| 1968 | (progn | 1972 | (if (search-forward "\n\n" nil t) |
| 1969 | (setq count (1+ count)) | 1973 | (progn |
| 1970 | (narrow-to-region start (point)) | 1974 | (setq count (1+ count)) |
| 1971 | (unless (mail-fetch-field pmail-attribute-header) | 1975 | (narrow-to-region start (point)) |
| 1972 | (pmail-add-header pmail-attribute-header value)) | 1976 | (unless (mail-fetch-field pmail-attribute-header) |
| 1973 | (widen)) | 1977 | (pmail-add-header pmail-attribute-header value)) |
| 1974 | (pmail-error-bad-format)) | 1978 | (widen)) |
| 1975 | ;; Move to the next message. | 1979 | (pmail-error-bad-format)) |
| 1976 | (if (search-forward "\n\nFrom " nil 'move) | 1980 | ;; Move to the next message. |
| 1977 | (forward-char -5)) | 1981 | (if (search-forward "\n\nFrom " nil 'move) |
| 1978 | (setq start (point)))) | 1982 | (forward-char -5)) |
| 1979 | count))) | 1983 | (setq start (point)))) |
| 1984 | count)))) | ||
| 1980 | 1985 | ||
| 1981 | ;;;; *** Pmail Message Formatting and Header Manipulation *** | 1986 | ;;;; *** Pmail Message Formatting and Header Manipulation *** |
| 1982 | 1987 | ||
| @@ -2282,7 +2287,8 @@ change the invisible header text." | |||
| 2282 | (pmail-set-message-counters))) | 2287 | (pmail-set-message-counters))) |
| 2283 | 2288 | ||
| 2284 | (defun pmail-count-new-messages (&optional nomsg) | 2289 | (defun pmail-count-new-messages (&optional nomsg) |
| 2285 | "Count the number of new messages in the region. | 2290 | "Count the number of new messages. |
| 2291 | The buffer should be narrowed to include only the new messages. | ||
| 2286 | Output a helpful message unless NOMSG is non-nil." | 2292 | Output a helpful message unless NOMSG is non-nil." |
| 2287 | (let* ((case-fold-search nil) | 2293 | (let* ((case-fold-search nil) |
| 2288 | (total-messages 0) | 2294 | (total-messages 0) |
| @@ -2376,10 +2382,10 @@ the message. Point is at the beginning of the message." | |||
| 2376 | (while (search-backward "\n\nFrom " stop t) | 2382 | (while (search-backward "\n\nFrom " stop t) |
| 2377 | (forward-char 2) | 2383 | (forward-char 2) |
| 2378 | (pmail-collect-deleted start) | 2384 | (pmail-collect-deleted start) |
| 2379 | ;; Show progress after every 20 messages or so. | ||
| 2380 | (setq messages-head (cons (point-marker) messages-head) | 2385 | (setq messages-head (cons (point-marker) messages-head) |
| 2381 | total-messages (1+ total-messages) | 2386 | total-messages (1+ total-messages) |
| 2382 | start (point)) | 2387 | start (point)) |
| 2388 | ;; Show progress after every 20 messages or so. | ||
| 2383 | (if (zerop (% total-messages 20)) | 2389 | (if (zerop (% total-messages 20)) |
| 2384 | (message "Counting messages...%d" total-messages))) | 2390 | (message "Counting messages...%d" total-messages))) |
| 2385 | ;; Handle the first message, maybe. | 2391 | ;; Handle the first message, maybe. |