GNU bug report logs - #59108
28.2; rmail-get-new-mail sets unmodified if no new mail even if buffer modified before

Previous Next

Package: emacs;

Reported by: Ken Olum <kdo <at> cosmos.phy.tufts.edu>

Date: Mon, 7 Nov 2022 16:21:01 UTC

Severity: normal

Found in version 28.2

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 59108 in the body.
You can then email your comments to 59108 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#59108; Package emacs. (Mon, 07 Nov 2022 16:21:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Ken Olum <kdo <at> cosmos.phy.tufts.edu>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 07 Nov 2022 16:21:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Ken Olum <kdo <at> cosmos.phy.tufts.edu>
To: bug-gnu-emacs <at> gnu.org
Subject: 28.2; rmail-get-new-mail sets unmodified if no new mail even if buffer
 modified before
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.

To reproduce:

emacs -Q
M-x rmail
Delete a message or make some other change.  Buffer now marked modified.
Without having any new mail, press "g".
Get message "0 new messages read".  Buffer now marked unmodified.

                                        Ken

In GNU Emacs 28.2 (build 1, x86_64-pc-linux-gnu, X toolkit, Xaw scroll bars)
 of 2022-11-07 built on cosmos
Windowing system distributor 'The X.Org Foundation', version 11.0.11906000
System Description: Ubuntu 18.04.6 LTS

Configured features:
FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG LIBXML2 MODULES
NOTIFY INOTIFY PDUMPER PNG SECCOMP SOUND THREADS TIFF
TOOLKIT_SCROLL_BARS X11 XDBE XFT XIM XPM LUCID ZLIB

Important settings:
  value of $LC_ALL: C
  value of $LANG: en_US.UTF-8
  locale-coding-system: nil

Major mode: RMAIL

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  buffer-read-only: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug sendmail shr-color color shr kinsoku svg
xml dom browse-url url url-proxy url-privacy url-expand url-methods
url-history url-cookie url-domsuf url-util url-parse url-vars mailcap
rmailmm message rmc puny dired dired-loaddefs rfc822 mml mml-sec epa
derived epg rfc6068 epg-config gnus-util text-property-search time-date
mm-decode mm-bodies mm-encode mailabbrev gmm-utils mailheader mail-parse
rfc2231 rmail rmail-loaddefs auth-source cl-seq eieio eieio-core cl-macs
eieio-loaddefs cl-loaddefs cl-lib password-cache json subr-x map seq
byte-opt gv bytecomp byte-compile cconv rfc2047 rfc2045 ietf-drums
mm-util mail-prsvr mail-utils iso-transl tooltip eldoc paren electric
uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel
term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image
regexp-opt fringe tabulated-list replace newcomment text-mode lisp-mode
prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu
timer select scroll-bar mouse jit-lock font-lock syntax font-core
term/tty-colors frame minibuffer cl-generic cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms
cp51932 hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese composite emoji-zwj charscript charprop case-table
epa-hook jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice
button loaddefs faces cus-face macroexp files window text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote threads inotify dynamic-setting
system-font-setting font-render-setting x-toolkit x multi-tty
make-network-process emacs)

Memory information:
((conses 16 61191 13369)
 (symbols 48 7588 1)
 (strings 32 23283 2385)
 (string-bytes 1 722945)
 (vectors 16 14763)
 (vector-slots 8 204330 17922)
 (floats 8 135 324)
 (intervals 56 334 0)
 (buffers 992 12))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59108; Package emacs. (Thu, 10 Nov 2022 10:34:01 GMT) Full text and rfc822 format available.

Message #8 received at 59108 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Ken Olum <kdo <at> cosmos.phy.tufts.edu>
Cc: 59108 <at> debbugs.gnu.org
Subject: Re: 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 <at> 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.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59108; Package emacs. (Thu, 10 Nov 2022 16:24:02 GMT) Full text and rfc822 format available.

Message #11 received at 59108 <at> debbugs.gnu.org (full text, mbox):

From: Ken Olum <kdo <at> cosmos.phy.tufts.edu>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 59108 <at> debbugs.gnu.org
Subject: Re: bug#59108: 28.2;
 rmail-get-new-mail sets unmodified if no new mail even if buffer
 modified before
Date: Thu, 10 Nov 2022 11:23:41 -0500
Yes, it works.  Thanks, Eli.

                                        Ken




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59108; Package emacs. (Thu, 10 Nov 2022 17:19:01 GMT) Full text and rfc822 format available.

Message #14 received at 59108 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Ken Olum <kdo <at> cosmos.phy.tufts.edu>
Cc: 59108 <at> debbugs.gnu.org
Subject: Re: bug#59108: 28.2;
 rmail-get-new-mail sets unmodified if no new mail even if buffer
 modified before
Date: Thu, 10 Nov 2022 19:18:03 +0200
> From: Ken Olum <kdo <at> cosmos.phy.tufts.edu>
> Cc: 59108 <at> debbugs.gnu.org
> Date: Thu, 10 Nov 2022 11:23:41 -0500
> 
> Yes, it works.  Thanks, Eli.

Thanks, installed for the upcoming Emacs 29.




Reply sent to Eli Zaretskii <eliz <at> gnu.org>:
You have taken responsibility. (Thu, 10 Nov 2022 17:25:01 GMT) Full text and rfc822 format available.

Notification sent to Ken Olum <kdo <at> cosmos.phy.tufts.edu>:
bug acknowledged by developer. (Thu, 10 Nov 2022 17:25:01 GMT) Full text and rfc822 format available.

Message #19 received at 59108-done <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: 59108-done <at> debbugs.gnu.org
Subject: Re: bug#59108: 28.2;
 rmail-get-new-mail sets unmodified if no new mail even if buffer
 modified before
Date: Thu, 10 Nov 2022 19:24:26 +0200
> Cc: 59108 <at> debbugs.gnu.org
> Date: Thu, 10 Nov 2022 19:18:03 +0200
> From: Eli Zaretskii <eliz <at> gnu.org>
> 
> > From: Ken Olum <kdo <at> cosmos.phy.tufts.edu>
> > Cc: 59108 <at> debbugs.gnu.org
> > Date: Thu, 10 Nov 2022 11:23:41 -0500
> > 
> > Yes, it works.  Thanks, Eli.
> 
> Thanks, installed for the upcoming Emacs 29.

And closing.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 09 Dec 2022 12:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 255 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.