Subject: Re: bug#66885: 29.1; gnus search with mu always returns empty
From: Eric Abrahamsen <[email-masked]>
To: Britt Anderson <[email-masked]>
Cc: [email-masked]
Date: Tue, 09 Jan 2024 13:29:27 -0800
List-Id: <debbugs-submit.debbugs.gnu.org>

On 01/05/24 11:24 AM, Britt Anderson wrote:
>>Hi Britt, I'm finally getting around to testing this. I set up mu with a
>>local maildir, and so far I'm not able to reproduce the problem. I mark
>>two maildir groups and search for unread messages with "mark:unread".
>>
>>The search arguments constructed by gnus-search look like:
>>
>>("find" "--nocolor" "--muhome=/home/eric/.cache/mu" "" "" "flag:unread"
>>"and" "(" "maildir:/mails" "or" "maildir:/Welcome" ")" "--format=plain"
>>"--fields=l")
>
> Thanks for getting back to me. I can get results with a similar
> command on the command line, but the same search in gnus still
> returns empty. My mail (for three different addresses) lives in
> /home/britt/.local/mail with the unique part of the directory
> hierarchy following the above. I edited my gnus.el to remove that
> common part as the "remove prefix", but still returned empty.
>
>
>>I'm not sure what else to try! Even if mu is returning results from
>>other Gnus backends, that shouldn't cause a failure. Though mu has the
>>"path:" key we can use with remove-prefix...
>>
>>The last things to try would be: setting `gnus-verbose' to 10, trying
>>the search, and telling me what you find in *Message*, and...
>
> I tried this and only got:
>
> #+begin_verbatim
> Doing mu query on (nnmaildir+b3l-archives:y2023)...
> Group nnselect:nnselect-87zfxjahkq.fsf contains no messages

This is really weird, after the "Doing mu query on" message, you should
have either gotten a "Search engine returned N results" message, or an
error buffer pop-up. With `gnus-verbose' at 10 I don't know how you'd
get this particular message situation.

> Quit
> No other window to select
> Quit
> C-M-x is undefined
> 10 (#o12, #xa, ?\C-j)
> You can run the command ‘eval-expression’ with M-:
> 10 (#o12, #xa, ?\C-j)
> Mark set [2 times]
> #+end_verbatim
>
> That "10" at the end is me evaluating gnus-verbose to verify it was set
> to 10.  The details of the mu command are not displayed. 
>
>>
>>eval'ing this version of the mu command method, that includes the
>>"path:" key. Does this fix the problem?
>>
>>(cl-defmethod gnus-search-indexed-search-command ((engine gnus-search-mu)
>>						  (qstring string)
>>						  query &optional groups)
>>  (let ((limit (alist-get 'limit query))
>>	(thread (alist-get 'thread query)))
>>    (with-slots (switches config-directory remove-prefix) engine
>>      `("find" 			; command must come first
>>	"--nocolor"		; mu will always give colored output otherwise
>>	,(format "--muhome=%s" config-directory)
>>	,@switches
>>	,(if thread "-r" "")
>>	,(if limit (format "--maxnum=%d" limit) "")
>>	,qstring
>>	,@(if groups
>>	      `("and" "("
>>		,@(nbutlast (mapcan (lambda (x)
>>				      (list (concat "maildir:/" x) "or"))
>>				    groups))
>>		")")
>>	    "")
>>	,(format "path:%s" (file-name-as-directory
>>                    (expand-file-name remove-prefix "/")))
>>	"--format=plain"
>>	"--fields=l"))))
>
> I did try this with no change. 
>
> I think you have given it the hero's try. Since it works for you and
> not for me I assume it is a problem on my side, and given the limited
> number of users it is probably not worth more of your time at this
> point. Thanks for all your efforts. Gnus is great and I don't want you
> to have to spend too much time on this. 

Okay, I'm closing the bug report for now, but I really would like
gnus-search to be as robust as possible. If anything more jumps out at
you, or there are any other further developments, please let me know!

Yours,
Eric