aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarl Heuer1997-01-25 06:47:28 +0000
committerKarl Heuer1997-01-25 06:47:28 +0000
commit9a10bd0dc2f53ee16541cb3fc179c9c9e24dcf77 (patch)
tree0b0c7b525893df4ace369d2656600df1471f3195
parentfd2d7b3dd4ed12bca817d9f13e387e65a2bd4db0 (diff)
downloademacs-9a10bd0dc2f53ee16541cb3fc179c9c9e24dcf77.tar.gz
emacs-9a10bd0dc2f53ee16541cb3fc179c9c9e24dcf77.zip
(rmail-get-new-mail): Fix return value to match doc.
-rw-r--r--lisp/mail/rmail.el187
1 files changed, 94 insertions, 93 deletions
diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el
index ba2b8ae6ad7..79123bb0591 100644
--- a/lisp/mail/rmail.el
+++ b/lisp/mail/rmail.el
@@ -916,100 +916,101 @@ It returns t if it got any new messages."
916 (let ((all-files (if file-name (list file-name) 916 (let ((all-files (if file-name (list file-name)
917 rmail-inbox-list))) 917 rmail-inbox-list)))
918 (unwind-protect 918 (unwind-protect
919 (while all-files 919 (let (found)
920 (let ((opoint (point)) 920 (while all-files
921 (new-messages 0) 921 (let ((opoint (point))
922 (delete-files ()) 922 (new-messages 0)
923 ;; If buffer has not changed yet, and has not been saved yet, 923 (delete-files ())
924 ;; don't replace the old backup file now. 924 ;; If buffer has not changed yet, and has not been saved yet,
925 (make-backup-files (and make-backup-files (buffer-modified-p))) 925 ;; don't replace the old backup file now.
926 (buffer-read-only nil) 926 (make-backup-files (and make-backup-files (buffer-modified-p)))
927 ;; Don't make undo records for what we do in getting mail. 927 (buffer-read-only nil)
928 (buffer-undo-list t) 928 ;; Don't make undo records for what we do in getting mail.
929 success 929 (buffer-undo-list t)
930 ;; Files to insert this time around. 930 success
931 files 931 ;; Files to insert this time around.
932 ;; Last names of those files. 932 files
933 file-last-names) 933 ;; Last names of those files.
934 ;; Pull files off all-files onto files 934 file-last-names)
935 ;; as long as there is no name conflict. 935 ;; Pull files off all-files onto files
936 ;; A conflict happens when two inbox file names 936 ;; as long as there is no name conflict.
937 ;; have the same last component. 937 ;; A conflict happens when two inbox file names
938 (while (and all-files 938 ;; have the same last component.
939 (not (member (file-name-nondirectory (car all-files)) 939 (while (and all-files
940 file-last-names))) 940 (not (member (file-name-nondirectory (car all-files))
941 (setq files (cons (car all-files) files) 941 file-last-names)))
942 file-last-names 942 (setq files (cons (car all-files) files)
943 (cons (file-name-nondirectory (car all-files)) files)) 943 file-last-names
944 (setq all-files (cdr all-files))) 944 (cons (file-name-nondirectory (car all-files)) files))
945 ;; Put them back in their original order. 945 (setq all-files (cdr all-files)))
946 (setq files (nreverse files)) 946 ;; Put them back in their original order.
947 (setq files (nreverse files))
947 948
948 (goto-char (point-max)) 949 (goto-char (point-max))
949 (skip-chars-backward " \t\n") ; just in case of brain damage 950 (skip-chars-backward " \t\n") ; just in case of brain damage
950 (delete-region (point) (point-max)) ; caused by require-final-newline 951 (delete-region (point) (point-max)) ; caused by require-final-newline
951 (save-excursion 952 (save-excursion
952 (save-restriction 953 (save-restriction
953 (narrow-to-region (point) (point)) 954 (narrow-to-region (point) (point))
954 ;; Read in the contents of the inbox files, 955 ;; Read in the contents of the inbox files,
955 ;; renaming them as necessary, 956 ;; renaming them as necessary,
956 ;; and adding to the list of files to delete eventually. 957 ;; and adding to the list of files to delete eventually.
957 (if file-name 958 (if file-name
958 (rmail-insert-inbox-text files nil) 959 (rmail-insert-inbox-text files nil)
959 (setq delete-files (rmail-insert-inbox-text files t))) 960 (setq delete-files (rmail-insert-inbox-text files t)))
960 ;; Scan the new text and convert each message to babyl format. 961 ;; Scan the new text and convert each message to babyl format.
961 (goto-char (point-min)) 962 (goto-char (point-min))
962 (unwind-protect 963 (unwind-protect
963 (save-excursion 964 (save-excursion
964 (setq new-messages (rmail-convert-to-babyl-format) 965 (setq new-messages (rmail-convert-to-babyl-format)
965 success t)) 966 success t))
966 ;; If we could not convert the file's inboxes, 967 ;; If we could not convert the file's inboxes,
967 ;; rename the files we tried to read 968 ;; rename the files we tried to read
968 ;; so we won't over and over again. 969 ;; so we won't over and over again.
969 (if (and (not file-name) (not success)) 970 (if (and (not file-name) (not success))
970 (let ((delfiles delete-files) 971 (let ((delfiles delete-files)
971 (count 0)) 972 (count 0))
972 (while delfiles 973 (while delfiles
973 (while (file-exists-p (format "RMAILOSE.%d" count)) 974 (while (file-exists-p (format "RMAILOSE.%d" count))
974 (setq count (1+ count))) 975 (setq count (1+ count)))
975 (rename-file (car delfiles) 976 (rename-file (car delfiles)
976 (format "RMAILOSE.%d" count)) 977 (format "RMAILOSE.%d" count))
977 (setq delfiles (cdr delfiles)))))) 978 (setq delfiles (cdr delfiles))))))
978 (or (zerop new-messages) 979 (or (zerop new-messages)
979 (let (success) 980 (let (success)
980 (widen) 981 (widen)
981 (search-backward "\n\^_" nil t) 982 (search-backward "\n\^_" nil t)
982 (narrow-to-region (point) (point-max)) 983 (narrow-to-region (point) (point-max))
983 (goto-char (1+ (point-min))) 984 (goto-char (1+ (point-min)))
984 (rmail-count-new-messages) 985 (rmail-count-new-messages)
985 (run-hooks 'rmail-get-new-mail-hook) 986 (run-hooks 'rmail-get-new-mail-hook)
986 (save-buffer))) 987 (save-buffer)))
987 ;; Delete the old files, now that babyl file is saved. 988 ;; Delete the old files, now that babyl file is saved.
988 (while delete-files 989 (while delete-files
989 (condition-case () 990 (condition-case ()
990 ;; First, try deleting. 991 ;; First, try deleting.
991 (condition-case () 992 (condition-case ()
992 (delete-file (car delete-files)) 993 (delete-file (car delete-files))
993 (file-error 994 (file-error
994 ;; If we can't delete it, truncate it. 995 ;; If we can't delete it, truncate it.
995 (write-region (point) (point) (car delete-files)))) 996 (write-region (point) (point) (car delete-files))))
996 (file-error nil)) 997 (file-error nil))
997 (setq delete-files (cdr delete-files))))) 998 (setq delete-files (cdr delete-files)))))
998 (if (= new-messages 0) 999 (if (= new-messages 0)
999 (progn (goto-char opoint) 1000 (progn (goto-char opoint)
1000 (if (or file-name rmail-inbox-list) 1001 (if (or file-name rmail-inbox-list)
1001 (message "(No new mail has arrived)")) 1002 (message "(No new mail has arrived)")))
1002 nil) 1003 (if (rmail-summary-exists)
1003 (if (rmail-summary-exists) 1004 (rmail-select-summary
1004 (rmail-select-summary 1005 (rmail-update-summary)))
1005 (rmail-update-summary))) 1006 (message "%d new message%s read"
1006 (message "%d new message%s read" 1007 new-messages (if (= 1 new-messages) "" "s"))
1007 new-messages (if (= 1 new-messages) "" "s")) 1008 ;; Move to the first new message
1008 ;; Move to the first new message 1009 ;; unless we have other unseen messages before it.
1009 ;; unless we have other unseen messages before it. 1010 (rmail-show-message (rmail-first-unseen-message))
1010 (rmail-show-message (rmail-first-unseen-message)) 1011 (run-hooks 'rmail-after-get-new-mail-hook)
1011 (run-hooks 'rmail-after-get-new-mail-hook) 1012 (setq found t))))
1012 t))) 1013 found)
1013 ;; Don't leave the buffer screwed up if we get a disk-full error. 1014 ;; Don't leave the buffer screwed up if we get a disk-full error.
1014 (rmail-show-message)))) 1015 (rmail-show-message))))
1015 1016