From: Eric Abrahamsen <eric@ericabrahamsen.net>
To: ding@gnus.org
Subject: Re: [Laura Conrad] Re: Notmuch as search engine
Date: Fri, 15 Apr 2022 09:14:58 -0700 [thread overview]
Message-ID: <8735iegw71.fsf@ericabrahamsen.net> (raw)
In-Reply-To: <87lew7t2jq.fsf@laymusic.org>
Laura Conrad <lconrad@laymusic.org> writes:
>>>>>> "Eric" == Eric Abrahamsen <eric@ericabrahamsen.net> writes:
>
> Eric> Laura Conrad <lconrad@laymusic.org> writes:
> >>>>>>> "Eric" == Eric S Fraga <e.fraga@ucl.ac.uk> writes:
> >>
> Eric> On Thursday, 14 Apr 2022 at 17:42, Laura Conrad wrote:
> >> >> (setq gnus-select-method '(nnml "private" (gnus-search-engine
> >> > notmuch)))
> >>
> Eric> But if you are using nnir, maybe try what I had, i.e.
> >>
> Eric> (setq gnus-select-method '(nnml "private"
> Eric> (nnir-search-engine notmuch)))
> >>
> Eric> as this was what I had and it worked?
> >>
> >> Well, that doesn't work for me either. I still get:
> >>
> >> gnus-select-newsgroup: Couldn’t request group nnir:nnir-87tuavth0w.fsf:
> >> Search produced empty results.
> >>
> >> Whereas from the command line:
> >>
> >> notmuch search --format=text --output=files scuttle
> >>
> >> produces lots of nice results like:
> >>
> >> /home/lconrad/Mail/laymusic/87119
> >> /home/lconrad/Mail/ding/31033
> >> /home/lconrad/Mail/sent/32975
> >> /home/lconrad/Mail/ding/31032
> >> /home/lconrad/Mail/sent/32974
> >> /home/lconrad/Mail/laymusic/87120
> >> /home/lconrad/Mail/laymusic/87119
>
> Eric> And `nnir-notmuch-remove-prefix' is set to "/home/lconrad/Mail"? It
> Eric> should be, that would be the default...
>
> Yes.
If notmuch is actually returning an error, which I suspect it isn't, you
can set `gnus-verbose' to something higher than 6, and it will show you
the buffer with the error message.
If (as I suspect) that doesn't do anything, try evaluating this version
of `nnir-run-notmuch'. It should pop up a buffer showing you the results
of the notmuch call, and put some messages in the *Messages* buffer
about the parsing of individual search results.
(defun nnir-run-notmuch (query server &optional groups)
"Run QUERY against notmuch.
Returns a vector of (group name, file name) pairs (also vectors,
actually). If GROUPS is a list of group names, use them to
construct path: search terms (see the variable
`nnir-notmuch-filter-group-names-function')."
(save-excursion
(let* ((qstring (cdr (assq 'query query)))
(prefix (nnir-read-server-parm 'nnir-notmuch-remove-prefix server))
artlist
(article-pattern (if (string-match "\\`nnmaildir:"
(gnus-group-server server))
":[0-9]+"
"^[0-9]+$"))
(groups (when nnir-notmuch-filter-group-names-function
(delq nil
(mapcar nnir-notmuch-filter-group-names-function
(mapcar #'gnus-group-short-name groups)))))
(pathquery (when groups
(concat " ("
(mapconcat (lambda (g)
(format "path:%s" g))
groups " or")
")")))
artno dirnam filenam)
(when (equal "" qstring)
(error "notmuch: You didn't enter anything"))
(set-buffer (get-buffer-create nnir-tmp-buffer))
(erase-buffer)
(if groups
(message "Doing notmuch query %s on %s..."
qstring (mapconcat #'identity groups " "))
(message "Doing notmuch query %s..." qstring))
(when groups
(setq qstring (concat qstring pathquery)))
(let* ((cp-list `( ,nnir-notmuch-program
nil ; input from /dev/null
t ; output
nil ; don't redisplay
"search"
"--format=text"
"--output=files"
,@(nnir-read-server-parm 'nnir-notmuch-additional-switches server)
,qstring ; the query, in notmuch format
))
(exitstatus
(progn
(message "%s args: %s" nnir-notmuch-program
(mapconcat #'identity (nthcdr 4 cp-list) " ")) ;; ???
(apply #'call-process cp-list))))
(unless (or (null exitstatus)
(zerop exitstatus))
(nnheader-report 'nnir "Couldn't run notmuch: %s" exitstatus)))
(display-buffer nnir-tmp-buffer)
;; The results are output in the format of:
;; absolute-path-name
(goto-char (point-min))
(while (not (eobp))
(setq filenam (buffer-substring-no-properties (line-beginning-position)
(line-end-position))
artno (file-name-nondirectory filenam)
dirnam (file-name-directory filenam))
(forward-line 1)
(message "Directory/group: %s; article number %s" dirnam artno)
;; don't match directories
(when (string-match article-pattern artno)
(when (not (null dirnam))
(message "Accepting result %s : %s" dirnam artno)
(nnir-add-result dirnam artno "" prefix server artlist))))
(message "Massaging notmuch output...done")
artlist)))
prev parent reply other threads:[~2022-04-15 16:15 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-12 19:27 Laura Conrad
2022-04-12 23:04 ` Eric Abrahamsen
2022-04-13 8:32 ` Eric S Fraga
2022-04-13 15:24 ` Eric Abrahamsen
2022-04-14 12:06 ` Eric S Fraga
2022-04-14 15:03 ` Eric Abrahamsen
2022-04-14 16:37 ` Laura Conrad
2022-04-14 18:06 ` Eric S Fraga
2022-04-14 21:42 ` Laura Conrad
2022-04-14 22:02 ` Eric S Fraga
2022-04-14 22:56 ` Laura Conrad
2022-04-15 0:04 ` Eric Abrahamsen
2022-04-15 4:04 ` Laura Conrad
2022-04-15 16:14 ` Eric Abrahamsen [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8735iegw71.fsf@ericabrahamsen.net \
--to=eric@ericabrahamsen.net \
--cc=ding@gnus.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).