Subject: bug#44509: 28.0.50; Error querying with new gnus-search and notmuch

From: Eric Abrahamsen <[email-masked]>
Date: Wed, 11 Nov 2020 09:56:40 -0800

Eric Abrahamsen <[email-masked]> writes:

> "Jose A. Ortega Ruiz" <[email-masked]> writes:
>
>> Hi again, Eric.
>>
>> I was looking at the notmuch engine code and wondering why it wasn't
>> working for me in a leafnode directory, which puts its messages in a
>> nnmail-compatible format (as far as i can tell).  And i discovered what
>> looks like a possible bug in gnus-search-indexed (or a misunderstanding
>> on my side).  Concretely, on line 1363 of gnus-search, when implementing
>> gnus-search-indexed-parsed output, we're constructing a groups regexp
>> that looks like:
>>
>> 	(group-regexp (when groups
>> 			(regexp-opt
>> 			 (mapcar
>> 			  (lambda (x) (gnus-group-real-name x))
>> 			  groups))))
>>
>> and then matching the returned list of files on that regexp (line 1377):
>>
>>        (string-match-p group-regexp f-name)))
>>
>> But gnus-group-real-name is giving me back a dot-separated path for
>> nested folders (e.g. gmane.bugs.gnus), while the file paths in the
>> results are using slashes (gmane/bugs/gnus/234 etc.), so the match
>> test always fails and no results are returned.
>>
>> If i simply redefine group-regexp using:
>>
>>     (replace-regexp-in-string "\\." "/" (gnus-group-real-name x)))
>
> This code that comes straight from the old nnir.el, and has always
> looked a bit fragile to me. The problem is that it really just expects
> each message to be in a regular file, with groups as folders.
>
> So you're using notmuch as a search engine for a local leafnode nntp
> server, and indexing its message store directly?
>
> Is there any leafnode setting that could influence how it stores its
> messages? Can it be convinced to store them in hierarchical folders?
>
> I suppose I could change the group-regexp to munge periods, but that
> could cause breakage in other cases, and I would be hesitant to do that.
>
> Otherwise, all the indexed search engines have a
> `gnus-search-indexed-extract' method that's used to actually return the
> file name from the results buffer. Each one's got something slightly
> different. It would be very easy to create a new notmuch search engine
> subclass that only overrides this method. To wit:
>
> (defclass gnus-search-leafnode-notmuch (gnus-search-notmuch))

Sorry, this would need to be:

(defclass gnus-search-leafnode-notmuch (gnus-search-notmuch)
  nil)