summaryrefslogtreecommitdiff
path: root/lisp/mail/rmail.el
diff options
context:
space:
mode:
authorKen Olum <kdo@cosmos.phy.tufts.edu>2016-05-28 13:46:22 +0300
committerEli Zaretskii <eliz@gnu.org>2016-05-28 13:46:22 +0300
commit549470fdf234acb4da7941e3bb9b28ed63a51876 (patch)
treedff95e89eaa065df2a072fdfc73285b1514d10a2 /lisp/mail/rmail.el
parent062757dca01cff127583438ae16237af55b6253c (diff)
downloademacs-549470fdf234acb4da7941e3bb9b28ed63a51876.tar.gz
emacs-549470fdf234acb4da7941e3bb9b28ed63a51876.tar.bz2
emacs-549470fdf234acb4da7941e3bb9b28ed63a51876.zip
Prevent locked-file errors in Rmail
* lisp/mail/rmail.el (rmail-get-new-mail-1): Lock file before calling 'rmail-insert-inbox-text'. Unlock if 'rmail-insert-inbox-text' doesn't modify buffer. (rmail-insert-inbox-text): Remove lock-checking code. (Bug#17706)
Diffstat (limited to 'lisp/mail/rmail.el')
-rw-r--r--lisp/mail/rmail.el23
1 files changed, 15 insertions, 8 deletions
diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el
index 734155e217d..e9882253c70 100644
--- a/lisp/mail/rmail.el
+++ b/lisp/mail/rmail.el
@@ -1818,9 +1818,21 @@ not be a new one). It returns non-nil if it got any new messages."
;; 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))
@@ -1969,11 +1981,6 @@ Value is the size of the newly read mail after conversion."
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