Subject: 30.0.50; rmail-summary-output deleting wrong email
From: Martin Marshall <[email-masked]>
To: [email-masked]
Date: Thu, 09 Feb 2023 00:44:46 -0500
List-Id: <debbugs-submit.debbugs.gnu.org>

Greetings,

Bug description:

When both rmail-delete-after-output and rmail-output-reset-deleted-flag
are enabled, calling rmail-summary-output marks for deletion the email
*following* the selected email.

Expected behavior:

The *selected* email header should be marked for deletion after the same
email has been copied to the destination folder.

Steps to reproduce:

This is reproducible with "emacs -Q", but we need a dummy mbox file and
destination file.  So here's a (probably overly) detailed process for
setting that up and then reproducing the bug.

Create and enter a directory for the files:

$ mkdir ~/temp
$ cd ~/temp

Download sample mbox file from GitHub, and remove blank lines from the
top of the file:

(It's not my file, but it will work to reproduce the bug.)

$ wget -nd https://raw.githubusercontent.com/qsnake/git/master/t/t5100/sample.mbox
$ sed -i '/[^[:space:]]/,$!d' sample.mbox

Create an empty file to which we can output one of the messages from the
sample file, and start Emacs.

$ touch destination
$ emacs -Q

In the *scratch* buffer, paste the following:

(setq rmail-delete-after-output t
      rmail-output-reset-deleted-flag t)

Then evaluate it.

C-x C-e

Now open the sample mbox folder and bring up the summary window.

C-u M-x rmail RET sample.mbox RET h

Go to an email in the summary window and call rmail-summary-output to
copy it to destination and delete it from sample.mbox.  I'll jump to the
3rd email, which is from an address at kernel.org.

3 j o temp/destination RET

The selected email number 3 was copied to the destination folder.

However, it should have also been marked for deletion and wasn't.
Instead, email number 4 was marked for deletion.

Best regards.

In GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
3.24.30, cairo version 1.16.0)
Windowing system distributor 'The X.Org Foundation', version 11.0.12101004
System Description: Guix System

Configured using:
 'configure
 CONFIG_SHELL=/gnu/store/4y5m9lb8k3qkb1y9m02sw9w9a6hacd16-bash-minimal-5.1.8/bin/bash
 SHELL=/gnu/store/4y5m9lb8k3qkb1y9m02sw9w9a6hacd16-bash-minimal-5.1.8/bin/bash
 --prefix=/gnu/store/igny5mwgmpw4nw1a171sn372ci8qz7gf-emacs-next-29.0.60-0.ac7ec87
 --enable-fast-install --with-modules --with-cairo
 --with-native-compilation --disable-build-details'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES
NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3
THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER X11 XDBE XIM XINPUT2 XPM
GTK3 ZLIB

Important settings:
  value of $EMACSLOADPATH: /home/martin/.guix-profile/share/emacs/site-lisp:/gnu/store/igny5mwgmpw4nw1a171sn372ci8qz7gf-emacs-next-29.0.60-0.ac7ec87/share/emacs/30.0.50/lisp
  value of $EMACSNATIVELOADPATH: /home/martin/.guix-profile/lib/emacs/native-site-lisp
  value of $LC_MONETARY: en_US.UTF-8
  value of $LC_NUMERIC: en_US.UTF-8
  value of $LC_TIME: en_US.UTF-8
  value of $LANG: en_US.utf8
  locale-coding-system: utf-8-unix

Major mode: 📜

Minor modes in effect:
  flyspell-mode: t
  minibuffer-electric-default-mode: t
  marginalia-mode: t
  which-function-mode: t
  flymake-mode: t
  winner-mode: t
  save-place-mode: t
  savehist-mode: t
  repeat-mode: t
  recentf-mode: t
  pixel-scroll-precision-mode: t
  global-auto-revert-mode: t
  electric-pair-mode: t
  delete-selection-mode: t
  vertico-reverse-mode: t
  vertico-mouse-mode: t
  vertico-mode: t
  consult-notes-denote-mode: t
  global-corfu-mode: t
  corfu-mode: t
  auto-insert-mode: t
  mini-navblock-mode: t
  mini-formfeed-as-line-mode: t
  dynamic-completion-mode: t
  display-time-mode: t
  mini-tweak-themes-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tab-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  column-number-mode: t
  line-number-mode: t
  auto-fill-function: do-auto-fill
  indent-tabs-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  abbrev-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr shortdoc textsec uni-scripts idna-mapping
ucs-normalize uni-confusable textsec-check shr-color color qp rect cape
ffap windmove org-appear flyspell ispell flymake-proselint org-indent
oc-basic org-element org-persist org-id org-refile avl-tree ol-rmail
org-mouse ol-irc ol-info ol-eww eww url-queue shr pixel-fill kinsoku
url-file svg xml dom browse-url url url-proxy url-privacy url-expand
url-methods url-history url-cookie generate-lisp-file url-domsuf
url-util url-parse url-vars mm-url gnus nnheader range ol-doi
org-link-doi ol-docview doc-view image-mode exif ol-bibtex bibtex
iso8601 ol-bbdb ob-python python treesit ob-perl org ob ob-tangle ob-ref
ob-lob ob-table ob-exp org-macro org-src ob-comint org-pcomplete
pcomplete org-list org-footnote org-faces org-entities noutline outline
ob-emacs-lisp ob-core ob-eval org-cycle org-table ol org-fold
org-fold-core org-keys oc org-loaddefs cal-menu calendar cal-loaddefs
org-version org-compat org-macs emacsbug cl-print mwim rmail-spam-filter
rmailedit rmailkwd rmailmm message sendmail mailcap yank-media puny
rfc822 mml mml-sec epa derived epg rfc6068 epg-config gnus-util
mm-decode mm-bodies mm-encode mailabbrev gmm-utils mailheader mail-parse
rfc2231 rmailsort rmailsum undigest executable geiser-mode geiser-xref
geiser-compile geiser-guile info-look transient edmacro kmacro geiser
geiser-debug geiser-repl geiser-image geiser-capf geiser-doc geiser-menu
geiser-autodoc geiser-edit etags fileloop generator geiser-completion
geiser-eval geiser-connection tq geiser-syntax geiser-log geiser-popup
view geiser-impl geiser-custom geiser-base scheme tabify rmailout rmail
auth-source password-cache json map rfc2047 rfc2045 ietf-drums mm-util
mail-prsvr mail-utils help-fns radix-tree cus-edit cus-start magit-base
magit-section format-spec crm eieio eieio-core dash mule-util jka-compr
vc-git diff-mode vc-dispatcher minibuf-eldef marginalia face-remap info
ehelp add-log comp comp-cstr vc-svn disp-table which-func imenu hl-line
time-date checkdoc lisp-mnt flymake-proc flymake compile comint ansi-osc
ansi-color warnings thingatpt winner saveplace savehist repeat recentf
tree-widget wid-edit pixel-scroll cua-base subr-x autorevert filenotify
elec-pair delsel init my-settings vertico-reverse consult-vertico
vertico-mouse vertico consult-notes-denote denote xdg dired-x dired-aux
dired dired-loaddefs xref project byte-opt bytecomp byte-compile ring
consult-notes consult bookmark text-property-search pp compat compat-29
mini-packages pdf-loader corfu mini-expansions easy-expand skeleton
expand mini-bindings mini-builtins cl-macs autoinsert mini-mode-line
find-func mini-menus mini-core pcase cl-seq cl-extra help-mode icons
cl-loaddefs cl-lib modus-vivendi-tinted-theme completion time cus-load
my-pre-custom-settings gv easy-mmode modus-themes kbd-autoloads
link-hint-autoloads markdown-mode-autoloads minimap-autoloads
mwim-autoloads vundo-autoloads free-keys-autoloads denote-autoloads
org-appear-autoloads elfeed-autoloads olivetti-autoloads cape-autoloads
marginalia-autoloads esup-autoloads sr-speedbar-autoloads
corfu-autoloads vertico-autoloads magit-popup-autoloads
geiser-guile-autoloads geiser-autoloads edit-indirect-autoloads
bui-autoloads guix-autoloads rx modus-themes-autoloads showtip-autoloads
pos-tip-autoloads popup-autoloads sdcv-autoloads
flymake-proselint-autoloads async-autoloads with-editor-autoloads
dash-autoloads magit-autoloads everywhere-autoloads
expand-region-autoloads pretty-speedbar-autoloads compat-autoloads
consult-autoloads avy-autoloads embark-autoloads tablist-autoloads
pdf-tools-autoloads mu4e-autoloads auctex-autoloads tex-site
emms-autoloads guix-emacs early-init rmc iso-transl tooltip cconv 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 nadvice seq simple cl-generic
indonesian philippine 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 abbrev obarray oclosure cl-preloaded button loaddefs
theme-loaddefs faces cus-face macroexp files window text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget keymap
hashtable-print-readable backquote threads dbusbind inotify lcms2
dynamic-setting system-font-setting font-render-setting cairo
move-toolbar gtk x-toolkit xinput2 x multi-tty make-network-process
native-compile emacs)

Memory information:
((conses 16 936381 31637)
 (symbols 48 34023 6)
 (strings 32 152466 7215)
 (string-bytes 1 4620632)
 (vectors 16 86624)
 (vector-slots 8 2246791 81933)
 (floats 8 487 506)
 (intervals 56 53506 3437)
 (buffers 984 27))

-- 
Martin Marshall
[email-masked]