unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#59108: 28.2; rmail-get-new-mail sets unmodified if no new mail even if buffer modified before
@ 2022-11-07 16:20 Ken Olum
  2022-11-10 10:33 ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: Ken Olum @ 2022-11-07 16:20 UTC (permalink / raw)
  To: 59108

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))





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#59108: 28.2; rmail-get-new-mail sets unmodified if no new mail even if buffer modified before
  2022-11-07 16:20 bug#59108: 28.2; rmail-get-new-mail sets unmodified if no new mail even if buffer modified before Ken Olum
@ 2022-11-10 10:33 ` Eli Zaretskii
  2022-11-10 16:23   ` Ken Olum
  0 siblings, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2022-11-10 10:33 UTC (permalink / raw)
  To: Ken Olum; +Cc: 59108

> 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.





^ permalink raw reply related	[flat|nested] 5+ messages in thread

* bug#59108: 28.2; rmail-get-new-mail sets unmodified if no new mail even if buffer modified before
  2022-11-10 10:33 ` Eli Zaretskii
@ 2022-11-10 16:23   ` Ken Olum
  2022-11-10 17:18     ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: Ken Olum @ 2022-11-10 16:23 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 59108

Yes, it works.  Thanks, Eli.

                                        Ken





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#59108: 28.2; rmail-get-new-mail sets unmodified if no new mail even if buffer modified before
  2022-11-10 16:23   ` Ken Olum
@ 2022-11-10 17:18     ` Eli Zaretskii
  2022-11-10 17:24       ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2022-11-10 17:18 UTC (permalink / raw)
  To: Ken Olum; +Cc: 59108

> From: Ken Olum <kdo@cosmos.phy.tufts.edu>
> Cc: 59108@debbugs.gnu.org
> Date: Thu, 10 Nov 2022 11:23:41 -0500
> 
> Yes, it works.  Thanks, Eli.

Thanks, installed for the upcoming Emacs 29.





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#59108: 28.2; rmail-get-new-mail sets unmodified if no new mail even if buffer modified before
  2022-11-10 17:18     ` Eli Zaretskii
@ 2022-11-10 17:24       ` Eli Zaretskii
  0 siblings, 0 replies; 5+ messages in thread
From: Eli Zaretskii @ 2022-11-10 17:24 UTC (permalink / raw)
  To: 59108-done

> Cc: 59108@debbugs.gnu.org
> Date: Thu, 10 Nov 2022 19:18:03 +0200
> From: Eli Zaretskii <eliz@gnu.org>
> 
> > From: Ken Olum <kdo@cosmos.phy.tufts.edu>
> > Cc: 59108@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.





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-11-10 17:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-07 16:20 bug#59108: 28.2; rmail-get-new-mail sets unmodified if no new mail even if buffer modified before Ken Olum
2022-11-10 10:33 ` Eli Zaretskii
2022-11-10 16:23   ` Ken Olum
2022-11-10 17:18     ` Eli Zaretskii
2022-11-10 17:24       ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).