Function: nnir-run-notmuch
nnir-run-notmuch is a byte-compiled function defined in nnir.el.gz.
Signature
(nnir-run-notmuch QUERY SERVER &optional GROUPS)
Documentation
Run QUERY with GROUPS from SERVER 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).
Source Code
;; Defined in /usr/src/emacs/lisp/obsolete/nnir.el.gz
(defun nnir-run-notmuch (query server &optional groups)
"Run QUERY with GROUPS from SERVER 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 (gnus-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)
;; notmuch failure reason is in this buffer, show it if
;; the user wants it.
(when (> gnus-verbose 6)
(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)
;; don't match directories
(when (string-match article-pattern artno)
(when (not (null dirnam))
(nnir-add-result dirnam artno "" prefix server artlist))))
(message "Massaging notmuch output...done")
artlist)))