Subject: 28.0.50; gnus-thread-sort-functions vs. loose threads

From: Kévin Le Gouguec <[email-masked]>
Date: Sun, 12 Jul 2020 15:05:56 +0200

Hello,

I try to configure gnus-thread-sort-functions so that threads are sorted
from least recently updated (at the top) to most recently updated (at
the bottom):

#+begin_src elisp
(setq gnus-thread-sort-functions '(gnus-thread-sort-by-number
                                   (not gnus-thread-sort-by-most-recent-date)))
#+end_src

The above works as intended most of the time, except when loose threads
are involved.  To reproduce:

- copy the attached emacs-devel.mbox to /tmp,
- copy the attached init.el somewhere,
- install gnus-mock from ELPA,
- evaluate the following, with init.el in default-directory:

#+begin_src elisp
(let ((gnus-mock-init-file (expand-file-name "init.el"))
      (gnus-mock-emacs-program (expand-file-name "src/emacs" source-directory)))
  (package-initialize)
  (gnus-mock-start))
#+end_src

This produces the following summary buffer:

20200708T163331 Philip K.               Re: Updating dired-guess-shell-alist-default
20200708T170847     Stefan Monnier          
20200708T163824 João Távora             Re: Byte-compilation warnings after merging eldoc changes

AFAICT, the first thread should be sorted last, since it has been
updated more recently than the second thread.  What leads me to believe
that this issue is linked to loose threads is that if we ask Gnus not to
gather those…

#+begin_src elisp
;; Evaluate:
(setq gnus-summary-make-false-root nil)
;; Then refresh with M-g.
#+end_src

… then the issue goes away:

20200708T163331 Philip K.               Re: Updating dired-guess-shell-alist-default
20200708T163824 João Távora             Re: Byte-compilation warnings after merging eldoc changes
20200708T170847 Stefan Monnier          Re: Updating dired-guess-shell-alist-default

Is this indeed a bug, or am I missing something?

Thank you for your time.

PS: when playing with this example, if you happen to set
gnus-summary-make-false-root to 'dummy, and notice that both the dummy
root *and* the first message display the subject line, note that I
already sent a report (and a patch) over at bug#40520.

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

Configured using:
 'configure --with-xwidgets --with-cairo'

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

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix