From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ken Olum Newsgroups: gmane.emacs.bugs Subject: bug#17706: 24.4.50; locked file error in rmail-insert-inbox-text Date: Thu, 26 Jun 2014 15:52:22 -0400 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1403812407 25041 80.91.229.3 (26 Jun 2014 19:53:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 26 Jun 2014 19:53:27 +0000 (UTC) Cc: 17706@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Jun 26 21:53:19 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1X0FjT-0002SU-5V for geb-bug-gnu-emacs@m.gmane.org; Thu, 26 Jun 2014 21:53:19 +0200 Original-Received: from localhost ([::1]:46621 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X0FjS-0001Gb-NY for geb-bug-gnu-emacs@m.gmane.org; Thu, 26 Jun 2014 15:53:18 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49971) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X0FjI-0001Bk-2B for bug-gnu-emacs@gnu.org; Thu, 26 Jun 2014 15:53:14 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X0FjC-0000E0-1h for bug-gnu-emacs@gnu.org; Thu, 26 Jun 2014 15:53:08 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:42900) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X0FjB-0000Dw-Uy for bug-gnu-emacs@gnu.org; Thu, 26 Jun 2014 15:53:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1X0FjB-0000Cl-Jf for bug-gnu-emacs@gnu.org; Thu, 26 Jun 2014 15:53:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ken Olum Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 26 Jun 2014 19:53:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 17706 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 17706-submit@debbugs.gnu.org id=B17706.1403812353731 (code B ref 17706); Thu, 26 Jun 2014 19:53:01 +0000 Original-Received: (at 17706) by debbugs.gnu.org; 26 Jun 2014 19:52:33 +0000 Original-Received: from localhost ([127.0.0.1]:34050 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1X0Fie-0000BY-QF for submit@debbugs.gnu.org; Thu, 26 Jun 2014 15:52:33 -0400 Original-Received: from cosmos.phy.tufts.edu ([130.64.83.16]:57319) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1X0FiZ-0000BJ-AV for 17706@debbugs.gnu.org; Thu, 26 Jun 2014 15:52:27 -0400 Original-Received: from kdo by cosmos.phy.tufts.edu ([local]:local) with local id 1X0FiY-00060G-VF - Using Exim-4.80.1 (MandrivaLinux) MTA (return-path ); Thu, 26 Jun 2014 15:52:23 -0400 In-Reply-To: <831turws0g.fsf@gnu.org> (message from Eli Zaretskii on Sat, 14 Jun 2014 16:16:31 +0300) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:90862 Archived-At: --=-=-= Content-Type: text/plain 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 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=rmail-lock.patch === 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 + + * 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 * skeleton.el (skeleton-end-hook): Default to nil and move the --=-=-=--