Subjects for messages with multiple files

Subject: Subjects for messages with multiple files

Date: Sat, 06 Aug 2022 08:07:08 -0300

To: Gregor Zattler,


From: David Bremner

Gregor Zattler <> writes:

> In my particular case the notmuch-search buffer shows two
> lines for two matching threads one of which stands out
> because its date is 1970-01-01 because I was too lazy to
> provide Date: headers in the test case's messages.
> In my particular case the Subject: shown on this very line
> for the test case is "two".  But if I place the cursor on
> this line and hit RET, the "first" of the three messages is
> shown, which in my particular case happens to be the one
> with Subject: "one".  Correspondingly the very first line of
> this notmuch-show buffer reads "one".

The underlying issue here is a bit tricky. Each message-id has a subject
value [1] associated with it. This is used to decide what to display
from notmuch search (i.e. it's used to construct the subject threads)
and it is used by the regex search.  Currently (since 2017) we make some
effort to maintain that as the subject of the first file indexed. The
numbering of duplicates on the other hand is by lexicographic order of
the filenames [2].  Probably we want to keep a list of subjects, but
then the question is how to make the order match. Ordering the files by
discovery order could be done (although not as trivially as you might
expect) or ordering the subjects by alphabetical order of filename could
be done. The latter probably requires less intrusive changes to the
database, but the question, for those who made it this far is we care
about keeping track of what the first indexed file is.  I had a quick
look back at the previous discussion [3] and I see some vague reference
to that being desirable as mitigation for some duplicate message-id
attacks, but I'm not sure how convincing that is.

[1]: actually a Xapian value slot, for those familiar with Xapian.

[2]: something like that anyway. The main point is that the database
     doesn't know anything about the order files are indexed

[3]: see e.g.
notmuch mailing list --
To unsubscribe send an email to