Gnus development mailing list
 help / color / mirror / Atom feed
From: Pedro Silva <psilva@pedrosilva.pt>
To: ding@gnus.org
Subject: Re: Create a group from a list of message-ids
Date: Mon, 25 Nov 2013 10:28:18 +0100	[thread overview]
Message-ID: <i50zgamwksg79p.fsf@pedrosilva.pt> (raw)
In-Reply-To: <844n71b5nh.fsf@davestoy.home>

[-- Attachment #1: Type: text/plain, Size: 3872 bytes --]

david.goldberg6@verizon.net (Dave Goldberg) writes:

>> Hello,
>> I use a tool called mu [1] to index and search my mail, which is stored
>> in a Maildir folder. mu is able to give me the message ids of all the
>> mails that match a given query. I want to use these ids to create a new
>> group in gnus that shows the search result. So it basically boils down
>> to this:
>
>> Is there a function or facility in gnus that takes a list of message-ids
>> (or even a list of local path names) and creates a new group containing
>> the corresponding messages?
>
>> I am fine with writing some elisp to call out to mu and converting its
>> output to a list, I just need above mentioned functionality.
>
> nnir.el provides an interface to various search capabilities and although I
> can't speak to it as I don't use it, I see maildir mentioned for one of the
> backends.  Perhaps that is enough to get you started.

I while back I wanted exactly this. It's a work in progress; to be frank
I don't remeber if I ever for it working, as I switched away from
maildir and consequently mu. Worth a shot!

--8<---------------cut here---------------start------------->8---
(require 'nnir)

(defcustom nnir-mu-program "mu"
  "*Name of mu indexing program."
  :type '(string)
  :group 'nnir)

(defcustom nnir-mu-additional-switches '()
  "*A list of strings, to be given as additional arguments to mu.

Note that this should be a list.  Ie, do NOT use the following:
    (setq nnir-mu-additional-switches \"-s date -z\") ; wrong
Instead, use this:
    (setq nnir-mu-additional-switches '(\"-s\" \"date\" \"-z\"))"
  :type '(repeat (string))
  :group 'nnir)

(defun nnir-run-mu (query server &optional group)
  "Run QUERY against mu.
Returns a vector of (group name, file name) pairs (also vectors,
actually)."
  (save-excursion
    (let ((qstring (cdr (assq 'query query)))
          (groupspec (car group))
          artlist)

      (when (equal "" qstring)
        (error "mu: You didn't enter anything"))

      (set-buffer (get-buffer-create nnir-tmp-buffer))
      (erase-buffer)

      (if groupspec
          (message "Doing mu query %s on %s..." qstring groupspec)
        (message "Doing mu query %s..." qstring))

      (let* ((cp-list `( ,nnir-mu-program
                         nil            ; input from /dev/null
                         t              ; output
                         nil            ; don't redisplay
                         "find"
                         "--format=sexp"
                         ,@(nnir-read-server-parm 'nnir-mu-additional-switches server)
                         ,@(split-string qstring "\\s-+")       ; the query, in mu format
                         ))
             (exitstatus
              (progn
                (message "%s args: %s" nnir-mu-program
                         (mapconcat 'identity (cddddr cp-list) " ")) ;; ???
                (apply 'call-process cp-list))))
        (unless (or (null exitstatus)
                    (zerop exitstatus))
          (nnheader-report 'nnir "Couldn't run mu: %s" exitstatus)
          ;; mu 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:
      ;; plists
      (goto-char (point-min))
      (while (not (eobp))
        (ignore-errors
          (let* ((item (read (current-buffer)))
                 (group (concat server ":" (substring (plist-get item :maildir) 1)))
                 (artno (plist-get item :docid))
                 (score 1000))
            (push (vector group artno score) artlist))))

      (message "Massaging mu output...done")
      (print artlist)
      artlist)))

(add-to-list 'nnir-engines '(mu nnir-run-mu ()))
--8<---------------cut here---------------end--------------->8---
--
Pedro

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 800 bytes --]

  parent reply	other threads:[~2013-11-25  9:28 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-23 11:50 Alexander Baier
2013-11-25  2:02 ` Dave Goldberg
2013-11-25  8:52   ` Alexander Baier
2013-11-25  8:58     ` Frank Terbeck
2013-11-25  9:11       ` Alexander Baier
2013-11-25  9:01     ` Eric Abrahamsen
2013-11-25  9:13       ` Alexander Baier
2013-11-25 13:20         ` Eric Abrahamsen
2013-11-25 14:08           ` Alexander Baier
2013-11-25 15:26             ` Eric Abrahamsen
2013-11-25 15:44               ` Frank Terbeck
2013-11-26  4:06                 ` Eric Abrahamsen
2013-11-27  5:16                   ` Eric Abrahamsen
2013-11-27  7:34                     ` Alexander Baier
2013-11-27  8:10                       ` Eric Abrahamsen
2013-11-27  8:22                         ` Alexander Baier
2013-11-28 12:02                   ` Alexander Baier
2013-11-29  3:41                     ` Eric Abrahamsen
2013-11-30 18:56                       ` Alexander Baier
2013-11-25 16:11               ` Alexander Baier
2013-11-25  9:28   ` Pedro Silva [this message]
2013-11-25  9:44     ` Alexander Baier

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=i50zgamwksg79p.fsf@pedrosilva.pt \
    --to=psilva@pedrosilva.pt \
    --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).