Subject: bug#73581: 29.4; Gnus: Error doing a search on nnmaildir with gnus-search-find-grep

From: Visuwesh <[email-masked]>
Date: Sat, 12 Apr 2025 13:54:57 +0530

[சனி ஏப்ரல் 12, 2025] Daniel Cerqueira wrote:

> Visuwesh <[email-masked]> writes:
>
>> [வெள்ளி ஏப்ரல் 11, 2025] Daniel Cerqueira wrote:
>>
>>> A bit related:
>>>
>>> Can you give an overview how to make search queries with find-grep?
>>>
>>> For example, I am trying to make a query with "grep:"happy birthday"
>>> subject:friend" and it is not working.  Should I prepend a "grep:" after
>>> each space (on the search keywords)?
>>
>> AFAIU the code, you can't have space in the grep part.  See how
>> gnus-search parses these "meta keywords" in gnus-search-prepare-query.
>> Having two grep: selects the last one.  Give the patch below a try, I
>> don't think it is a good idea to reuse gnus-search-query-next-expr since
>> it does more than just go over "":
>>
>> diff --git a/lisp/gnus/gnus-search.el b/lisp/gnus/gnus-search.el
>> index 41915a0e3c0..7ca67e2134b 100644
>> --- a/lisp/gnus/gnus-search.el
>> +++ b/lisp/gnus/gnus-search.el
>> @@ -2110,20 +2140,28 @@ gnus-search-prepare-query
>
> [...]
>
> The patch did not work.  I haven't recorded the message error, but it
> was something to do with the something-generate-artlist having the wrong
> number of arguments.
>
> You don't need to fix it, if you don't want to, have too much work, or
> don't have time.

I can give a shot at debugging, when I have time, if you provide the
backtrace.  Getting the find-grep backend to work was a goal for me, you
gave me a good excuse to procrastinate from working on my thesis.  ;-)

>>> How to search in the subject or by date?
>>
>> You can't, the find-grep search backend simply runs grep.  If you don't
>> want to use mu or notmuch, you could try writing a backend for mblaze.
>
> Okay.  Regarding subject, I understand grep not doing it; but regarding
> time, something can be done with find (it is find-grep after all).  No
> need or no pressure in doing it, though.

I don't think we can exploit the various time statistics attached with a
file to achieve what you want.  A message from 2019 reports:

    % stat ~/mail/XXX/inbox/cur/1641645812.328064_1.astatine,U=1:2,S
      File: ~/mail/XXX/inbox/cur/1641645812.328064_1.astatine,U=1:2,S
      Size: 8420      	Blocks: 24         IO Block: 4096   regular file
    Device: 8,4	Inode: 5774494     Links: 1
    Access: (0600/-rw-------)  Uid: ( 1000/     viz)   Gid: ( 1000/     viz)
    Access: 2025-04-12 13:46:05.575388637 +0530
    Modify: 2022-01-08 18:13:32.297967005 +0530
    Change: 2022-06-05 07:44:16.919565297 +0530
     Birth: 2022-01-08 18:13:32.297967005 +0530
   % grep ^Date: ~/mail/XXX/inbox/cur/1641645812.328064_1.astatine,U=1:2,S
   Date: Mon, 21 Jan 2019 02:14:48 -0800

My first impressions of mblaze tells me writing a gnus-search backend
for it is going to be a formidable task since there's no easy way to
compose multi-header queries (we can use mpick but I don't think it can
act on message body text).