comparison lisp/mail/rmail.el @ 101766:4c8d51496578

(rmail-convert-babyl-to-mbox): Disable undo while inserting the converted mailbox. (rmail-get-new-mail): Restore the loop over inboxes when two or more have the same basename. (Bug#2164) Set the return value according to whether any mail was found, not just in the last inbox. Only show a message and run the hook after checking all inboxes. (rmail-get-new-mail-1): Move message display and running the hook to rmail-get-new-mail.
author Glenn Morris <rgm@gnu.org>
date Tue, 03 Feb 2009 04:07:25 +0000
parents d69ff5f24dfd
children d9595deb9142
comparison
equal deleted inserted replaced
101765:119f13a715df 101766:4c8d51496578
917 (kill-all-local-variables) 917 (kill-all-local-variables)
918 (write-region (point-min) (point-max) old-file) 918 (write-region (point-min) (point-max) old-file)
919 (unrmail old-file new-file) 919 (unrmail old-file new-file)
920 (message "Replacing BABYL format with mbox format...") 920 (message "Replacing BABYL format with mbox format...")
921 (let ((inhibit-read-only t) 921 (let ((inhibit-read-only t)
922 (coding-system-for-read 'raw-text)) 922 (coding-system-for-read 'raw-text)
923 (buffer-undo-list t))
923 (erase-buffer) 924 (erase-buffer)
924 (insert-file-contents new-file) 925 (insert-file-contents new-file)
925 ;; Rmail buffers need to be saved with Unix EOLs, or else 926 ;; Rmail buffers need to be saved with Unix EOLs, or else
926 ;; the format will not be recognized. 927 ;; the format will not be recognized.
927 (set-buffer-file-coding-system 'raw-text-unix) 928 (set-buffer-file-coding-system 'raw-text-unix)
1573 (setq buffer-undo-list nil)) 1574 (setq buffer-undo-list nil))
1574 (let ((all-files (if file-name (list file-name) rmail-inbox-list)) 1575 (let ((all-files (if file-name (list file-name) rmail-inbox-list))
1575 (rmail-enable-multibyte (default-value 'enable-multibyte-characters)) 1576 (rmail-enable-multibyte (default-value 'enable-multibyte-characters))
1576 found) 1577 found)
1577 (unwind-protect 1578 (unwind-protect
1578 (when all-files 1579 (progn
1579 (let ((opoint (point)) 1580 ;; This loops if any members of the inbox list have the same
1580 ;; If buffer has not changed yet, and has not been 1581 ;; basename (see "name conflict" below).
1581 ;; saved yet, don't replace the old backup file now. 1582 (while all-files
1582 (make-backup-files (and make-backup-files (buffer-modified-p))) 1583 (let ((opoint (point))
1583 (buffer-read-only nil) 1584 ;; If buffer has not changed yet, and has not been
1584 ;; Don't make undo records while getting mail. 1585 ;; saved yet, don't replace the old backup file now.
1585 (buffer-undo-list t) 1586 (make-backup-files (and make-backup-files (buffer-modified-p)))
1586 delete-files success files file-last-names) 1587 (buffer-read-only nil)
1587 ;; Pull files off all-files onto files as long as there is 1588 ;; Don't make undo records while getting mail.
1588 ;; no name conflict. A conflict happens when two inbox 1589 (buffer-undo-list t)
1589 ;; file names have the same last component. 1590 delete-files success files file-last-names)
1590 (while (and all-files 1591 ;; Pull files off all-files onto files as long as there is
1591 (not (member (file-name-nondirectory (car all-files)) 1592 ;; no name conflict. A conflict happens when two inbox
1592 file-last-names))) 1593 ;; file names have the same last component.
1593 (setq files (cons (car all-files) files) 1594 ;; FIXME why does this "conflict" need kid gloves?
1594 file-last-names 1595 (while (and all-files
1595 (cons (file-name-nondirectory (car all-files)) files)) 1596 (not (member (file-name-nondirectory (car all-files))
1596 (setq all-files (cdr all-files))) 1597 file-last-names)))
1597 ;; Put them back in their original order. 1598 (setq files (cons (car all-files) files)
1598 (setq files (nreverse files)) 1599 file-last-names
1599 (goto-char (point-max)) 1600 (cons (file-name-nondirectory (car all-files)) files))
1600 (skip-chars-backward " \t\n") ; just in case of brain damage 1601 (setq all-files (cdr all-files)))
1601 (delete-region (point) (point-max)) ; caused by require-final-newline 1602 ;; Put them back in their original order.
1602 (setq found (rmail-get-new-mail-1 file-name files delete-files)))) 1603 (setq files (nreverse files))
1603 found) 1604 (goto-char (point-max))
1604 ;; Don't leave the buffer screwed up if we get a disk-full error. 1605 (skip-chars-backward " \t\n") ; just in case of brain damage
1605 (or found (rmail-show-message-maybe)))) 1606 (delete-region (point) (point-max)) ; caused by require-final-newline
1607 (setq found (or
1608 (rmail-get-new-mail-1 file-name files delete-files)
1609 found))))
1610 ;; Move to the first new message unless we have other unseen
1611 ;; messages before it.
1612 (if found (rmail-show-message-maybe (rmail-first-unseen-message)))
1613 (run-hooks 'rmail-after-get-new-mail-hook)
1614 found)
1615 ;; Don't leave the buffer screwed up if we get a disk-full error.
1616 (rmail-show-message-maybe))))
1606 1617
1607 (defun rmail-get-new-mail-1 (file-name files delete-files) 1618 (defun rmail-get-new-mail-1 (file-name files delete-files)
1608 "Return t if new messages are detected without error, nil otherwise." 1619 "Return t if new messages are detected without error, nil otherwise."
1609 (save-excursion 1620 (save-excursion
1610 (save-restriction 1621 (save-restriction
1671 (message "%d new message%s read%s" new-messages suffix blurb) 1682 (message "%d new message%s read%s" new-messages suffix blurb)
1672 (when spam-filter-p 1683 (when spam-filter-p
1673 (if rsf-beep (beep t)) 1684 (if rsf-beep (beep t))
1674 (sleep-for rsf-sleep-after-message)) 1685 (sleep-for rsf-sleep-after-message))
1675 1686
1676 ;; Establish the return value and move to the first new 1687 ;; Establish the return value.
1677 ;; message unless we have other unseen messages before it.
1678 (setq result (> new-messages 0)) 1688 (setq result (> new-messages 0))
1679 (when result
1680 (rmail-show-message-maybe (rmail-first-unseen-message)))
1681 (run-hooks 'rmail-after-get-new-mail-hook)
1682 result)))) 1689 result))))
1683 1690
1684 (defun rmail-get-new-mail-filter-spam (new-message-count) 1691 (defun rmail-get-new-mail-filter-spam (new-message-count)
1685 "Process new messages for spam." 1692 "Process new messages for spam."
1686 (let* ((old-messages (- rmail-total-messages new-message-count)) 1693 (let* ((old-messages (- rmail-total-messages new-message-count))