From: Ken Olum <kdo@cosmos.phy.tufts.edu>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 17706@debbugs.gnu.org
Subject: bug#17706: 24.4.50; locked file error in rmail-insert-inbox-text
Date: Thu, 26 Jun 2014 15:52:22 -0400 [thread overview]
Message-ID: <q524mz7mosp.fsf@cosmos.phy.tufts.edu> (raw)
In-Reply-To: <831turws0g.fsf@gnu.org> (message from Eli Zaretskii on Sat, 14 Jun 2014 16:16:31 +0300)
[-- Attachment #1: Type: text/plain, Size: 281 bytes --]
Here is a patch to mark the buffer modified (which locks the file) in
rmail-get-new-mail-1 before calling rmail-insert-inbox-text, and mark it
unmodified if rmail-insert-inbox-text returns (or is aborted) without
modifying the buffer.
Ken
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: rmail-lock.patch --]
[-- Type: text/x-diff, Size: 2182 bytes --]
=== modified file 'lisp/mail/rmail.el'
--- lisp/mail/rmail.el 2014-05-21 16:58:19 +0000
+++ lisp/mail/rmail.el 2014-06-26 19:18:00 +0000
@@ -1816,9 +1816,20 @@
;; 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))
@@ -1968,11 +1979,6 @@
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 movemail popmail got-password password)
(while files
;; Handle remote mailbox names specially; don't expand as filenames
=== modified file 'lisp/ChangeLog'
--- lisp/ChangeLog 2014-06-26 19:46:02 +0000
+++ lisp/ChangeLog 2014-06-26 19:46:30 +0000
@@ -1,3 +1,10 @@
+2014-06-26 Ken Olum <kdo@cosmos.phy.tufts.edu>
+
+ * 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
+
2014-06-26 Leo Liu <sdl.web@gmail.com>
* skeleton.el (skeleton-end-hook): Default to nil and move the
next prev parent reply other threads:[~2014-06-26 19:52 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-05 20:10 bug#17706: 24.4.50; locked file error in rmail-insert-inbox-text Ken Olum
2014-06-06 8:03 ` Eli Zaretskii
2014-06-06 15:09 ` Ken Olum
2014-06-06 15:39 ` Eli Zaretskii
2014-06-06 15:50 ` Eli Zaretskii
2014-06-06 16:29 ` Ken Olum
2014-06-07 8:34 ` Eli Zaretskii
2014-06-07 12:42 ` Ken Olum
2014-06-14 12:16 ` Ken Olum
2014-06-14 13:16 ` Eli Zaretskii
2014-06-26 19:52 ` Ken Olum [this message]
2014-06-27 9:34 ` Eli Zaretskii
2014-06-27 15:54 ` Glenn Morris
2014-06-27 19:39 ` Eli Zaretskii
2014-06-27 19:54 ` Glenn Morris
2014-06-27 20:03 ` Eli Zaretskii
2016-05-23 20:23 ` Mark Lillibridge
2016-05-28 10:48 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=q524mz7mosp.fsf@cosmos.phy.tufts.edu \
--to=kdo@cosmos.phy.tufts.edu \
--cc=17706@debbugs.gnu.org \
--cc=eliz@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.