Subject: bug#39076: 26.3; rmail-summary-mark-deleted error with no arguments (or nil)

From: Ed Sabol <[email-masked]>
Date: Fri, 10 Jan 2020 16:30:15 -0500 (EST)

rmail-summary-mark-deleted is defined like so:

(defun rmail-summary-mark-deleted (&optional n undel) ...)

As you can see, n and undel are supposed to be optional arguments. However,
if I call

rmail-summary-mark-deleted with no arguments (or a nil argument), I get the
following lisp error:

(wrong-type-argument number-or-marker-p nil)

as shown in this backtrace:

Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil)
  rmail-summary-mark-deleted(nil)
  rmail-summary-delete-forward(-1)
  rmail-summary-delete-backward(1)
  funcall-interactively(rmail-summary-delete-backward 1)
  call-interactively(rmail-summary-delete-backward nil nil)
  command-execute(rmail-summary-delete-backward)

The issue is that rmail-summary-mark-deleted evaluates (1- n) which causes
the error when n is nil.

However, this is really a symptom of another issue I'm seeing. Immediately
after I hit "g" to get new mail in some rmail-summary buffer,
rmail-current-message is sometimes nil until I move to another message, but I
haven't tracked down yet why that's happening and I haven't been able to
reproduce it with `emacs -Q'....

That said, I *can* reproduce the error with (rmail-summary-mark-deleted) with
`emacs -Q'. It is easiest to do with an email whose "Subject:" header is
"(rmail-summary-mark-deleted)". Then, in the rmail-summary buffer, go to the
message with that subject, move point to just after the close paren in
"(rmail-summary-mark-deleted)", and hit C-x C-e to evaluate the expression in
the rmail-summary buffer.

In GNU Emacs 26.3 (build 2, x86_64-pc-linux-gnu, X toolkit)
 of 2019-11-19 built on heasarcdev
Windowing system distributor 'Scientific Linux', version 11.0.11704000
System Description:	Scientific Linux release 6.10 (Carbon)

Recent messages:
Quit
/software/usr/contrib/share/emacs/26.3/lisp/mail/rmail.el.gz and /usr/contrib/share/emacs/26.3/lisp/mail/rmail.el.gz are the same file
Mark saved where search started [2 times]
Making completion list...
completing-read-default: Command attempted to use minibuffer while in minibuffer
Quit [3 times]
next-line: End of buffer
Quit
next-line: End of buffer
Region copied to kill buffer.

Configured using:
 'configure --prefix=/software/usr/contrib
 --exec-prefix=/software/usr/contrib/linux-6.x --with-x-toolkit=lucid
 --with-xft=yes --with-toolkit-scroll-bars=no --with-gif=no --with-tiff=no
 --with-gnutls=no'

Configured features:
XAW3D XPM JPEG PNG SOUND GSETTINGS GLIB NOTIFY LIBSELINUX LIBXML2 FREETYPE
XFT ZLIB LUCID X11 XDBE XIM THREADS

Important settings:
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=none
  locale-coding-system: utf-8-unix

Major mode: Emacs-Lisp

Minor modes in effect:
  t: t
  show-paren-mode: t
  diff-auto-refine-mode: t
  display-time-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
/software/usr/contrib/share/emacs/26.x/site-lisp/dockerfile-mode hides /Home/lhea2/sabol/.emacs.d/elpa/dockerfile-mode-1.2/dockerfile-mode
/software/usr/contrib/share/emacs/26.x/site-lisp/perlcritic hides /software/usr/contrib/share/emacs/site-lisp/perlcritic
/Home/lhea2/sabol/.emacs.d/elpa/mmm-mode-0.5.7/mmm-region hides /software/usr/contrib/share/emacs/site-lisp/mmm-region
/software/usr/contrib/share/emacs/26.x/site-lisp/tidy hides /software/usr/contrib/share/emacs/site-lisp/tidy
/Home/lhea2/sabol/.emacs.d/elpa/mmm-mode-0.5.7/mmm-vars hides /software/usr/contrib/share/emacs/site-lisp/mmm-vars
/Home/lhea2/sabol/.emacs.d/elpa/mmm-mode-0.5.7/mmm-noweb hides /software/usr/contrib/share/emacs/site-lisp/mmm-noweb
/Home/lhea2/sabol/.emacs.d/elpa/mmm-mode-0.5.7/mmm-utils hides /software/usr/contrib/share/emacs/site-lisp/mmm-utils
/Home/lhea2/sabol/.emacs.d/elpa/mmm-mode-0.5.7/mmm-cweb hides /software/usr/contrib/share/emacs/site-lisp/mmm-cweb
/Home/lhea2/sabol/.emacs.d/elpa/mmm-mode-0.5.7/mmm-univ hides /software/usr/contrib/share/emacs/site-lisp/mmm-univ
/Home/lhea2/sabol/.emacs.d/elpa/mmm-mode-0.5.7/mmm-rpm hides /software/usr/contrib/share/emacs/site-lisp/mmm-rpm
/Home/lhea2/sabol/.emacs.d/elpa/mmm-mode-0.5.7/mmm-mason hides /software/usr/contrib/share/emacs/site-lisp/mmm-mason
/Home/lhea2/sabol/.emacs.d/elpa/mmm-mode-0.5.7/mmm-sample hides /software/usr/contrib/share/emacs/site-lisp/mmm-sample
/Home/lhea2/sabol/.emacs.d/elpa/mmm-mode-0.5.7/mmm-mode hides /software/usr/contrib/share/emacs/site-lisp/mmm-mode
/Home/lhea2/sabol/.emacs.d/elpa/mmm-mode-0.5.7/mmm-cmds hides /software/usr/contrib/share/emacs/site-lisp/mmm-cmds
/Home/lhea2/sabol/.emacs.d/elpa/mmm-mode-0.5.7/mmm-class hides /software/usr/contrib/share/emacs/site-lisp/mmm-class
/Home/lhea2/sabol/.emacs.d/elpa/mmm-mode-0.5.7/mmm-compat hides /software/usr/contrib/share/emacs/site-lisp/mmm-compat
/Home/lhea2/sabol/.emacs.d/elpa/mmm-mode-0.5.7/mmm-auto hides /software/usr/contrib/share/emacs/site-lisp/mmm-auto
/software/usr/contrib/share/emacs/26.x/site-lisp/mode-compile hides /software/usr/contrib/share/emacs/site-lisp/mode-compile
/software/usr/contrib/share/emacs/26.x/site-lisp/heasarc-info-mode hides /software/usr/contrib/share/emacs/site-lisp/heasarc-info-mode
/software/usr/contrib/share/emacs/26.x/site-lisp/simple-vc hides /software/usr/contrib/share/emacs/site-lisp/simple-vc
/software/usr/contrib/share/emacs/site-lisp/css-mode hides /software/usr/contrib/share/emacs/26.3/lisp/textmodes/css-mode
/software/usr/contrib/share/emacs/site-lisp/flymake hides /software/usr/contrib/share/emacs/26.3/lisp/progmodes/flymake

Features:
(shadow emacsbug find-func debug rect shr-color color xref project url-util
ispell rmailedit timezone supercite regi shr svg xml dom browse-url rmailout
cl-extra cl-print thingatpt help-fns radix-tree help-mode ediff-merg
ediff-wind ediff-diff ediff-mult ediff-help ediff-init ediff-util ediff
jka-compr mailalias mail-hist sendmail misearch multi-isearch pp qp rmailsum
rmailmm elec-pair paren psvn wid-edit cl log-edit message rmc puny
format-spec rfc822 mml mml-sec epa derived epg gnus-util rmail rmail-loaddefs
mm-decode mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045 ietf-drums
mailabbrev mail-utils gmm-utils mailheader ring add-log diff-mode executable
mmm-auto mmm-vars mmm-utils mmm-compat imenu mm-util mail-prsvr time advice
server restart-session dired dired-loaddefs pcvs vc-cvs pcvs-parse pcvs-info
pcvs-defs easy-mmode pcvs-util ewoc finder-inf package easymenu epg-config
url-handlers url-parse auth-source cl-seq eieio eieio-core cl-macs
eieio-loaddefs password-cache url-vars seq byte-opt gv bytecomp byte-compile
cconv cl-loaddefs cl-lib time-date mule-util 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 menu-bar
rfn-eshadow isearch timer select scroll-bar mouse jit-lock font-lock syntax
facemenu font-core term/tty-colors frame 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 minibuffer cl-preloaded nadvice loaddefs button faces
cus-face macroexp files text-properties overlay sha1 md5 base64 format env
code-pages mule custom widget hashtable-print-readable backquote threads
inotify dynamic-setting font-render-setting x-toolkit x multi-tty
make-network-process emacs)

Memory information:
((conses 16 501193 84028)
 (symbols 48 31333 1)
 (miscs 40 23052 4155)
 (strings 32 138700 11898)
 (string-bytes 1 5254271)
 (vectors 16 37509)
 (vector-slots 8 1831771 190318)
 (floats 8 356 385)
 (intervals 56 25000 1411)
 (buffers 992 56)
 (heap 1024 104355 6082))