Subject: bug#67954: 30.0.50; Gnus: notmuch results are not sorted properly

From: Eric Abrahamsen <[email-masked]>
Date: Mon, 01 Jan 2024 20:41:00 -0800

Eric Abrahamsen <[email-masked]> writes:

> Torsten Bronger <[email-masked]> writes:
>
>> If I search for mails using Gnus and notmuch.  My .gnus says:
>>
>> (setq gnus-secondary-select-methods
>>       '((nnml "" (gnus-search-engine gnus-search-notmuch)))
>>       gnus-search-notmuch-config-file "/etc/notmuch/.notmuch-config")
>>
>> Then I press ^ in group mode, move to the nnml: entry, and press G.
>> Then, I enter my query string, which starts the search.  Gnus asks how
>> many articles I want to have, and here the problem begins: If 1000 mails
>> have been found and I want to see 10, I expect to see the 10 most recent
>> ones.  However, they seem to be arbitrary.  At least, they are not the
>> 10 first/latest delivered by notmuch (which works in newest-first mode).
>>
>> If I retrieve all 1000 mails, they are also not sorted in the summary
>> buffer.  I can hit C-c C-s C-d without effect.  The sorting seems to be
>> random.
>
> Weird! Thanks for the report. I've piled up a few gnus-search bugs and
> will work on them in the next few days, if necessary I'll come back for
> more info then.

I haven't been able to reproduce this. I don't have an nnml
installation, but I've tried it with nnmaildir. I set
`gnus-thread-sort-functions' to the same value as yours, and remove all
other sorting customizations, then run the search at both the group
level and the server level. In all cases the results are sorted by date,
both when selecting a smaller number of results, or showing everything.

A few questions:

`gnus-search-notmuch-remove-prefix' defaults to "~/Mail", is that where
your mail is?

What do you mean C-s C-s C-d has no effect? It should reconstruct the
*Summary* buffer at least -- do you mean it reconstructs the buffer with
the same random sorting? That would be very strange to me, because at
this point the sorting commands are just working on the articles in the
summary buffer, and it doesn't have anything to do with search anymore.

If no further suspects present themselves, I can try to construct an
nnml mail store to work on.

Thanks,
Eric