GNU bug report logs - #45941
28.0.50; rmail doesn't set modified flag when changing 'unseen' flag

Previous Next

Package: emacs;

Reported by: "Andrea G. Monaco" <andrea.monaco <at> autistici.org>

Date: Sun, 17 Jan 2021 17:57:02 UTC

Severity: normal

Found in version 28.0.50

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 45941 in the body.
You can then email your comments to 45941 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#45941; Package emacs. (Sun, 17 Jan 2021 17:57:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to "Andrea G. Monaco" <andrea.monaco <at> autistici.org>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 17 Jan 2021 17:57:02 GMT) Full text and rfc822 format available.

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

From: "Andrea G. Monaco" <andrea.monaco <at> autistici.org>
To: bug-gnu-emacs <at> gnu.org
Subject: 28.0.50; rmail doesn't set modified flag when changing 'unseen' flag
Date: Sun, 17 Jan 2021 18:55:59 +0100
Hello,


when I read a message for the first time in rmail, the unseen flag gets
cleared, but this does not set the modified flag of the buffer:
therefore the buffer can't be saved, nor Emacs offers to save it when I
close the program, and information about read messages gets usually
lost.

These are the relevant lines in rmail.el, inside rmail-show-message-1:

  ;; Mark the message as seen, but preserve buffer modified flag.
  (let ((modiff (buffer-modified-p)))
    (rmail-set-attribute rmail-unseen-attr-index nil)
    (unless modiff
      (restore-buffer-modified-p modiff)))


I'd prefer no special treatment of 'unseen' flag modification, so that
it set the modified flag.

I think that some users might prefer the current behavior, so we could
add a variable, maybe named rmail-unseen-change-set-modified, to
customize this.


Warmly,
Andrea Monaco



In GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.5, cairo version 1.16.0)
 of 2020-12-01 built on agm
Repository revision: 90a543e630012cc58c175d5bf3ffd42bb156c6b6
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12004000
System Description: Debian GNU/Linux 10 (buster)

Configured features:
XPM JPEG TIFF GIF PNG RSVG CAIRO SOUND DBUS GSETTINGS GLIB NOTIFY
INOTIFY LIBSELINUX GNUTLS LIBXML2 FREETYPE HARFBUZZ ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM MODULES THREADS LIBSYSTEMD JSON
PDUMPER LCMS2

Important settings:
  value of $LC_MONETARY: it_IT.UTF-8
  value of $LC_NUMERIC: it_IT.UTF-8
  value of $LC_TIME: it_IT.UTF-8
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: RMAIL Summary

Minor modes in effect:
  display-time-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-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
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug sendmail shr-color color eieio-opt
cl-extra speedbar ezimage dframe find-func shortdoc help-fns radix-tree
help-mode misearch multi-isearch rmailsum 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 qp rmailmm
message rmc puny dired dired-loaddefs rfc822 mml easymenu mml-sec epa
derived epg 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 time tooltip eldoc electric uniquify
ediff-hook vc-hooks lisp-float-type 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 elisp-mode lisp-mode
prog-mode register page tab-bar menu-bar rfn-eshadow isearch timer
select scroll-bar mouse jit-lock font-lock syntax facemenu 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 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 dbusbind inotify lcms2
dynamic-setting system-font-setting font-render-setting cairo
move-toolbar gtk x-toolkit x multi-tty make-network-process emacs)

Memory information:
((conses 16 191396 51037)
 (symbols 48 8932 2)
 (strings 32 128911 15394)
 (string-bytes 1 12255982)
 (vectors 16 118062)
 (vector-slots 8 1212654 84005)
 (floats 8 190 282)
 (intervals 56 5799 1278)
 (buffers 984 16))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#45941; Package emacs. (Wed, 27 Jan 2021 15:42:01 GMT) Full text and rfc822 format available.

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

From: "Andrea G. Monaco" <andrea.monaco <at> autistici.org>
To: bug-gnu-emacs <at> gnu.org
Subject: bug#45941: [PATCH] add option to mark buffer as modified after
 reading new message
Date: Wed, 27 Jan 2021 16:40:46 +0100
Hello,


this patch from current rmail.el adds an option for marking buffer as
modified when a message is read for the first time. The variable defaults
to nil, so it should not change current behavior.


diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el
index 29460cc20f..d800dce671 100644
--- a/lisp/mail/rmail.el
+++ b/lisp/mail/rmail.el
@@ -686,6 +686,10 @@ rmail-show-mime-function
 This function is called when `rmail-enable-mime' is non-nil.
 The package providing MIME support should set this.")
 
+(defvar rmail-read-new-message-trigger-modified nil
+  "If true, reading a message for the first time and thus clearing
+its unseen attribute triggers the modified flag for the RMAIL buffer.")
+
 ;;;###autoload
 (defvar rmail-insert-mime-forwarded-message-function nil
   "Function to insert a message in MIME format so it can be forwarded.
@@ -2747,10 +2751,11 @@ rmail-show-message-1
            (t (setq rmail-current-message msg)))
       (with-current-buffer rmail-buffer
        (setq header-style rmail-header-style)
-       ;; Mark the message as seen, but preserve buffer modified flag.
-       (let ((modiff (buffer-modified-p)))
+        ;; Mark the message as seen, but preserve buffer modified flag,
+       ;; unless rmail-read-new-message-trigger-modified is t
+        (let ((modiff (buffer-modified-p)))
          (rmail-set-attribute rmail-unseen-attr-index nil)
-         (unless modiff
+         (unless rmail-read-new-message-trigger-modified
            (restore-buffer-modified-p modiff)))
        ;; bracket the message in the mail
        ;; buffer and determine the coding system the transfer encoding.



-- 
Andrea G. Monaco
Hacker, mathematician, lgbt+ activist
"Hope will never be silent!", H. Milk




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#45941; Package emacs. (Wed, 27 Jan 2021 15:54:02 GMT) Full text and rfc822 format available.

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

From: Andreas Schwab <schwab <at> linux-m68k.org>
To: "Andrea G. Monaco" <andrea.monaco <at> autistici.org>
Cc: 45941 <at> debbugs.gnu.org
Subject: Re: bug#45941: [PATCH] add option to mark buffer as modified after
 reading new message
Date: Wed, 27 Jan 2021 16:53:06 +0100
On Jan 27 2021, Andrea G. Monaco wrote:

> diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el
> index 29460cc20f..d800dce671 100644
> --- a/lisp/mail/rmail.el
> +++ b/lisp/mail/rmail.el
> @@ -686,6 +686,10 @@ rmail-show-mime-function
>  This function is called when `rmail-enable-mime' is non-nil.
>  The package providing MIME support should set this.")
>  
> +(defvar rmail-read-new-message-trigger-modified nil
> +  "If true, reading a message for the first time and thus clearing

The first line of the docstring should be a complete sentence.

Andreas.

-- 
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#45941; Package emacs. (Wed, 27 Jan 2021 17:48:02 GMT) Full text and rfc822 format available.

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

From: "Andrea G. Monaco" <andrea.monaco <at> autistici.org>
To: bug-gnu-emacs <at> gnu.org
Subject: bug#45941: [PATCH] add option to mark buffer as modified after
 reading new message
Date: Wed, 27 Jan 2021 18:47:06 +0100
  > The first line of the docstring should be a complete sentence.
  > Andreas.

Thanks, I didn't know that. I fixed it and also chose a more fitting
name for the variable.


diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el
index 29460cc20f..749cdd5891 100644
--- a/lisp/mail/rmail.el
+++ b/lisp/mail/rmail.el
@@ -686,6 +686,9 @@ rmail-show-mime-function
 This function is called when `rmail-enable-mime' is non-nil.
 The package providing MIME support should set this.")
 
+(defvar rmail-showing-new-message-sets-modified nil
+  "If non-nil, showing a new message sets the modified flag for the RMAIL buffer.")
+
 ;;;###autoload
 (defvar rmail-insert-mime-forwarded-message-function nil
   "Function to insert a message in MIME format so it can be forwarded.
@@ -2747,10 +2750,11 @@ rmail-show-message-1
            (t (setq rmail-current-message msg)))
       (with-current-buffer rmail-buffer
        (setq header-style rmail-header-style)
-       ;; Mark the message as seen, but preserve buffer modified flag.
-       (let ((modiff (buffer-modified-p)))
+        ;; Mark the message as seen, but preserve buffer modified flag,
+       ;; unless rmail-showing-new-message-sets-modified is non-nil
+        (let ((modiff (buffer-modified-p)))
          (rmail-set-attribute rmail-unseen-attr-index nil)
-         (unless modiff
+         (unless rmail-showing-new-message-sets-modified
            (restore-buffer-modified-p modiff)))
        ;; bracket the message in the mail
        ;; buffer and determine the coding system the transfer encoding.


-- 
Andrea G. Monaco
Hacker, mathematician, lgbt+ activist
"Hope will never be silent!", H. Milk




Reply sent to Eli Zaretskii <eliz <at> gnu.org>:
You have taken responsibility. (Sat, 30 Jan 2021 09:29:01 GMT) Full text and rfc822 format available.

Notification sent to "Andrea G. Monaco" <andrea.monaco <at> autistici.org>:
bug acknowledged by developer. (Sat, 30 Jan 2021 09:29:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: "Andrea G. Monaco" <andrea.monaco <at> autistici.org>
Cc: 45941-done <at> debbugs.gnu.org
Subject: Re: bug#45941: [PATCH] add option to mark buffer as modified after
 reading new message
Date: Sat, 30 Jan 2021 11:28:34 +0200
> From: "Andrea G. Monaco" <andrea.monaco <at> autistici.org>
> Date: Wed, 27 Jan 2021 18:47:06 +0100
> 
> 
>   > The first line of the docstring should be a complete sentence.
>   > Andreas.
> 
> Thanks, I didn't know that. I fixed it and also chose a more fitting
> name for the variable.

Thanks, I installed this with some changes: the variable is now a user
option customizable via Custom, and I also added a NE|W|S entry about
it.

With that, I close the bug report.  Thank you for your contribution to
Emacs.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 27 Feb 2021 12:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 30 days ago.

Previous Next


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