;; Read in the contents of the inbox files, renaming them as
;; necessary, and adding to the list of files to delete
;; eventually.
- (if file-name
- (rmail-insert-inbox-text files nil)
- (setq delete-files (rmail-insert-inbox-text files t)))
+ (unwind-protect
+ (progn
+ ;; Set modified now to lock the file, so that we don't
+ ;; encounter locking problems later in the middle of
+ ;; reading the mail.
+ (set-buffer-modified-p t)
+ (if file-name
+ (rmail-insert-inbox-text files nil)
+ (setq delete-files (rmail-insert-inbox-text files t))))
+ ;; If there was no new mail, or we aborted before actually
+ ;; trying to get any, mark buffer unmodified. Otherwise the
+ ;; buffer is correctly marked modified and the file locked
+ ;; until we save out the new mail.
+ (if (= (point-min) (point-max))
+ (set-buffer-modified-p nil)))
;; Scan the new text and convert each message to
;; Rmail/mbox format.
(goto-char (point-min))
size))
(defun rmail-insert-inbox-text (files renamep)
- ;; Detect a locked file now, so that we avoid moving mail
- ;; out of the real inbox file. (That could scare people.)
- (or (memq (file-locked-p buffer-file-name) '(nil t))
- (error "RMAIL file %s is locked"
- (file-name-nondirectory buffer-file-name)))
(let (file tofile delete-files popmail got-password password)
(while files
;; Handle remote mailbox names specially; don't expand as filenames