changeset 88253:86d5137811c7

(rmail-delete-inbox-files): New function factored out of `rmail-get-new-mail'. (rmail-get-new-mail): Use it. (rmail-get-inbox-files): Renamed from `rmail-get-inbox-list'.
author Henrik Enberg <henrik.enberg@telia.com>
date Sat, 21 Jan 2006 03:39:40 +0000
parents aaab5dd1b031
children dd2fd4664465
files lisp/mail/rmail.el
diffstat 1 files changed, 17 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/mail/rmail.el	Sat Jan 21 03:22:55 2006 +0000
+++ b/lisp/mail/rmail.el	Sat Jan 21 03:39:40 2006 +0000
@@ -1350,7 +1350,7 @@
 
 ;;;; *** Rmail input ***
 
-(defun rmail-get-inbox-list ()
+(defun rmail-get-inbox-files ()
   "Return all files from `rmail-inbox-list' without name conflicts.
 A conflict happens when two inbox file names have the same name
 according to `file-name-nondirectory'."
@@ -1363,6 +1363,18 @@
 	(push (file-name-nondirectory file) last-names)))
     (nreverse files)))
 
+(defun rmail-delete-inbox-files (files)
+  "Delete all files given in FILES.
+If delete fails, truncate them to zero length."
+  (dolist (file files)
+    (condition-case nil
+	;; First, try deleting.
+	(condition-case nil
+	    (delete-file file)
+	  ;; If we can't delete it, truncate it.
+	  (file-error (write-region (point) (point) file)))
+      (file-error nil))))
+
 (defun rmail-get-new-mail (&optional file-name)
   "Move any new mail from this mail file's inbox files.
 The inbox files for the primary mail file are determined using
@@ -1406,7 +1418,7 @@
   ;; Get rid of all undo records for this buffer.
   (unless (eq buffer-undo-list t)
     (setq buffer-undo-list nil))
-  (let ((files (if file-name (list file-name) (rmail-get-inbox-list)))
+  (let ((files (if file-name (list file-name) (rmail-get-inbox-files)))
 	(rmail-enable-multibyte (default-value 'enable-multibyte-characters))
 	found current-message)
     (condition-case nil
@@ -1430,6 +1442,8 @@
 		(if file-name
 		    (rmail-insert-inbox-text files nil)
 		  (setq delete-files (rmail-insert-inbox-text files t)))
+		;; Process newly found messages and save them into the
+		;; RMAIL file.
 		(unless (equal (point-min) (point-max))
 		  (setq new-messages (rmail-process-new-messages)
 			rmail-current-message (1+ rmail-total-messages)
@@ -1438,14 +1452,7 @@
 		  (save-buffer))
 		;; Delete the old files, now that the RMAIL file is
 		;; saved.
-		(dolist (i delete-files)
-		  (condition-case nil
-		      ;; First, try deleting.
-		      (condition-case nil
-			  (delete-file i)
-			;; If we can't delete it, truncate it.
-			(file-error (write-region (point) (point) i)))
-		    (file-error nil)))))
+		(rmail-delete-inbox-files delete-files)))
 	    (if (= new-messages 0)
 		(progn (goto-char opoint)
 		       (when (or file-name rmail-inbox-list)