[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#59108: 28.2; rmail-get-new-mail sets unmodified if no new mail even
From: |
Eli Zaretskii |
Subject: |
bug#59108: 28.2; rmail-get-new-mail sets unmodified if no new mail even if buffer modified before |
Date: |
Thu, 10 Nov 2022 12:33:49 +0200 |
> From: Ken Olum <kdo@cosmos.phy.tufts.edu>
> Date: Mon, 07 Nov 2022 11:20:20 -0500
>
> rmail-get-new-mail-1 sets buffer-modified-p at the beginning to deal
> with locking issues right away. Then if there is no new mail it clears
> buffer-modified-p. Thus if the buffer was modified already it gets
> marked unmodified without being saved.
>
> I think it should restore buffer-modified-p to whatever it was to begin
> with when it doesn't find any new mail. I'll send a patch if you like.
Thanks. Does the patch below give good results?
diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el
index f095d5e..e3372a6 100644
--- a/lisp/mail/rmail.el
+++ b/lisp/mail/rmail.el
@@ -1751,6 +1751,7 @@ rmail-get-new-mail-1
(spam-filter-p (and (featurep 'rmail-spam-filter)
rmail-use-spam-filter))
(blurb "")
+ (mod-p (buffer-modified-p))
result success suffix)
(narrow-to-region (point) (point))
;; Read in the contents of the inbox files, renaming them as
@@ -1766,10 +1767,11 @@ rmail-get-new-mail-1
(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))
+ ;; trying to get any, mark buffer unmodified, unless it was
+ ;; modified originally. Otherwise the buffer is correctly
+ ;; marked modified and the file locked until we save out the
+ ;; new mail.
+ (if (and (null mod-p) (= (point-min) (point-max)))
(set-buffer-modified-p nil)))
;; Scan the new text and convert each message to
;; Rmail/mbox format.