comparison lisp/mail/rmail.el @ 88268:6a755a3db87f

(rmail-process-new-messages): Don't decode messages here. (rmail-decode-messages): New function. (rmail): Use it. (rmail-get-new-mail): Likewise.
author Henrik Enberg <henrik.enberg@telia.com>
date Sat, 21 Jan 2006 21:09:42 +0000
parents defd9948075b
children 4775e8747134
comparison
equal deleted inserted replaced
88267:960c11d84a7d 88268:6a755a3db87f
839 (let ((inhibit-read-only t)) 839 (let ((inhibit-read-only t))
840 (erase-buffer) 840 (erase-buffer)
841 (insert-file-contents-literally new-file)) 841 (insert-file-contents-literally new-file))
842 (message "Replacing BABYL format with mbox format...done")) 842 (message "Replacing BABYL format with mbox format...done"))
843 (delete-file old-file) 843 (delete-file old-file)
844 (delete-file new-file)))) 844 (delete-file new-file)))
845 ;; Go through the converted file and decode each message
846 ;; according to its mime charset.
847 (rmail-decode-messages))
845 (goto-char (point-max)) 848 (goto-char (point-max))
846 (rmail-mode-2) 849 (rmail-mode-2)
847 ;; setup files coding system 850 ;; setup files coding system
848 (rmail-decode-mail-file) 851 (rmail-decode-mail-file)
849 ;; We use `run-mail-hook' to remember whether we should run 852 ;; We use `run-mail-hook' to remember whether we should run
1453 (unless (equal (point-min) (point-max)) 1456 (unless (equal (point-min) (point-max))
1454 (setq new-messages (rmail-process-new-messages) 1457 (setq new-messages (rmail-process-new-messages)
1455 rmail-current-message (1+ rmail-total-messages) 1458 rmail-current-message (1+ rmail-total-messages)
1456 rmail-total-messages (rmail-desc-get-count)) 1459 rmail-total-messages (rmail-desc-get-count))
1457 (run-hooks 'rmail-get-new-mail-hook) 1460 (run-hooks 'rmail-get-new-mail-hook)
1461 ;; Go through the RMAIL file and decode each message
1462 ;; according to its mime charset.
1463 (rmail-decode-messages)
1458 (save-buffer)) 1464 (save-buffer))
1459 ;; Delete the old files, now that the RMAIL file is 1465 ;; Delete the old files, now that the RMAIL file is
1460 ;; saved. 1466 ;; saved.
1461 (rmail-delete-inbox-files delete-files))) 1467 (rmail-delete-inbox-files delete-files)))
1462 (if (= new-messages 0) 1468 (if (= new-messages 0)
1711 (setq coding-system last-coding-system-used)) 1717 (setq coding-system last-coding-system-used))
1712 (set-buffer-modified-p modifiedp) 1718 (set-buffer-modified-p modifiedp)
1713 (setq buffer-file-coding-system nil) 1719 (setq buffer-file-coding-system nil)
1714 (setq save-buffer-coding-system (or coding-system 'undecided))))) 1720 (setq save-buffer-coding-system (or coding-system 'undecided)))))
1715 1721
1722 (defun rmail-decode-messages ()
1723 (let ((inhibit-read-only t)
1724 (case-fold-search nil)
1725 (start (point-max))
1726 end)
1727 ;; Process each message in turn starting from the back and
1728 ;; proceeding to the front of the region. This is especially a good
1729 ;; approach since the buffer will likely have new headers added.
1730 (widen)
1731 (goto-char start)
1732 (while (re-search-backward rmail-unix-mail-delimiter nil t)
1733 (setq end start)
1734 (setq start (point))
1735 (save-excursion
1736 (save-restriction
1737 (narrow-to-region start end)
1738 (goto-char (point-min))
1739
1740 (setq last-coding-system-used nil)
1741 (or rmail-enable-mime
1742 (not rmail-enable-multibyte)
1743 (let ((mime-charset
1744 (when (and rmail-decode-mime-charset
1745 (save-excursion
1746 (goto-char (rmail-header-get-limit))
1747 (let ((case-fold-search t))
1748 (re-search-backward
1749 rmail-mime-charset-pattern
1750 (point-min) t))))
1751 (intern (downcase (match-string 1))))))
1752 (rmail-decode-region start (point) mime-charset)))
1753
1754 ;; Add an the X-Coding-System header.
1755 (unless (rmail-header-get-header "X-Coding-System")
1756 (let ((val (symbol-name last-coding-system-used)))
1757 (rmail-header-add-header "X-Coding-System" val))))))))
1758
1716 1759
1717 ;;;; *** Rmail Message Formatting and Header Manipulation *** 1760 ;;;; *** Rmail Message Formatting and Header Manipulation ***
1718 1761
1719 (defun rmail-clear-headers (&optional ignored-headers) 1762 (defun rmail-clear-headers (&optional ignored-headers)
1720 "Delete all header fields that Rmail should not show. 1763 "Delete all header fields that Rmail should not show.
1931 (goto-char (point-max)) 1974 (goto-char (point-max))
1932 (while (search-backward "\r\n" (point-min) t) 1975 (while (search-backward "\r\n" (point-min) t)
1933 (delete-char 1))) 1976 (delete-char 1)))
1934 (setq end (marker-position end-marker)) 1977 (setq end (marker-position end-marker))
1935 (set-marker end-marker nil))) 1978 (set-marker end-marker nil)))
1936
1937 ;; Decode Message according to charset.
1938 (setq last-coding-system-used nil)
1939 (or rmail-enable-mime
1940 (not rmail-enable-multibyte)
1941 (let ((mime-charset
1942 (when (and rmail-decode-mime-charset
1943 (save-excursion
1944 (goto-char (rmail-header-get-limit))
1945 (let ((case-fold-search t))
1946 (re-search-backward
1947 rmail-mime-charset-pattern
1948 (point-min) t))))
1949 (intern (downcase (match-string 1))))))
1950 (rmail-decode-region start (point) mime-charset)))
1951
1952 ;; Add an X-Coding-System header if we don't have one.
1953 (unless (rmail-header-get-header "X-Coding-System")
1954 (rmail-header-add-header "X-Coding-System"
1955 (symbol-name last-coding-system-used)))
1956 1979
1957 ;; Make sure we have an Rmail BABYL attribute header field. 1980 ;; Make sure we have an Rmail BABYL attribute header field.
1958 ;; All we can assume is that the Rmail BABYL header field is 1981 ;; All we can assume is that the Rmail BABYL header field is
1959 ;; in the header section. It's placement can be modified by 1982 ;; in the header section. It's placement can be modified by
1960 ;; another mailer. 1983 ;; another mailer.