From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.user/3480 Path: news.gmane.org!not-for-mail From: Dmitry Astapov Newsgroups: gmane.emacs.gnus.user Subject: Mairix support for nnir.el Date: Fri, 06 Feb 2004 11:35:03 +0200 Organization: My Humble Opinions Ltd. -- views expressed are mine and only mine Message-ID: <87d68slfeg.fsf@dimail.umc.com.ua> Reply-To: Dmitry Astapov NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: sea.gmane.org 1138669584 19140 80.91.229.2 (31 Jan 2006 01:06:24 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 31 Jan 2006 01:06:24 +0000 (UTC) Original-X-From: nobody Tue Jan 17 17:32:17 2006 Original-Path: quimby.gnus.org!newsfeed1.e.nsc.no!nsc.no!nextra.com!news.tele.dk!news.tele.dk!small.news.tele.dk!news2.telebyte.nl!news1.spb.su!demos!news.cca.usart.ru!dimail.umc.com.ua!not-for-mail Original-Newsgroups: gnu.emacs.gnus Original-Sender: adept@80.255.64.73 Original-NNTP-Posting-Host: 80.255.64.73 Original-X-Trace: relay.cca.usart.ru 1076060354 84289 80.255.64.73 (6 Feb 2004 09:39:14 GMT) Original-X-Complaints-To: usenet@relay.cca.usart.ru Original-NNTP-Posting-Date: Fri, 6 Feb 2004 09:39:14 +0000 (UTC) User-Agent: Gnus/5.110002 (No Gnus v0.2) XEmacs/21.4 (Reasonable Discussion, linux) Cancel-Lock: sha1:EeGlWMZTQlgh8sYEYWWpUqgxt6I= Original-Xref: bridgekeeper.physik.uni-ulm.de gnus-emacs-gnus:3621 Original-Lines: 156 X-Gnus-Article-Number: 3621 Tue Jan 17 17:32:17 2006 Xref: news.gmane.org gmane.emacs.gnus.user:3480 Archived-At: --=-=-= Recently I came upon the ultimate (for me) solution for mail indexing and searching. Name's Mairix (http://www.rc0.org.uk/mairix/). So far it is the fastest and best MIME-gokking/non-latin1-friendly software among it's kind (and believe me - I looked very hard, tried glimpse, namazy, swish, ...). To make me completely happy, I sit and wrote nnir interface for Mairix, which I attach here (and BCC to Kai as well). Hope you may find it usefull. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=nnir-mairix-diff.patch --- /usr/share/emacs/site-lisp/gnus-bonus-el/nnir.el 2003-04-04 23:16:09.000000000 +0300 +++ /home/adept/.emacs-lisp/nnir.el 2004-02-06 00:11:27.000000000 +0200 @@ -318,6 +318,8 @@ (swish-e nnir-run-swish-e ((group . "Group spec: "))) (namazu nnir-run-namazu + ()) + (mairix nnir-run-mairix ())) "Alist of supported search engines. Each element in the alist is a three-element list (ENGINE FUNCTION ARGS). @@ -577,6 +567,39 @@ :type '(directory) :group 'nnir) +;; Mairix engine, see + +(defcustom nnir-mairix-program "mairix" + "*Name of Mairix search executable." + :type '(string) + :group 'nnir) + +(defcustom nnir-mairix-additional-switches '() + "*A list of strings, to be given as additional arguments to mairix. +The switche `-r' is always used, very few other switches (except `-t') +make any sense in this context. + +Note that this should be a list. Ie, do NOT use the following: + (setq nnir-mairix-additional-switches \"-t -t\") ; wrong +Instead, use this: + (setq nnir-mairix-additional-switches '(\"-t\" \"-t\"))" + :type '(repeat (string)) + :group 'nnir) + +(defcustom nnir-mairix-config-file (expand-file-name "~/.mairixrc") + "*Config file for Mairix." + :type '(file) + :group 'nnir) + +(defcustom nnir-mairix-remove-prefix (concat (getenv "HOME") "/Mail[^/]*/") + "*The prefix to remove from each file name returned by Mairix +in order to get a group name (albeit with / instead of .). + +This variable is very similar to `nnir-glimpse-remove-prefix', except +that it is for Mairix, not Glimpse." + :type '(directory) + :group 'nnir) + ;;; Internal Variables: (defvar nnir-current-query nil @@ -1271,6 +1293,78 @@ (> (nnir-artitem-rsv x) (nnir-artitem-rsv y))))))))) +;; Mairix interface +(defun nnir-run-mairix (query &optional group) + "Run given query against Mairix. Returns a vector of (group name, file name) +pairs (also vectors, actually). + +Tested with Mairix 0.11 on a Debian GNU/Linux system, unstable distribution." + (when group + (error "The Mairix backend cannot search specific groups")) + (save-excursion + (let ( + (artlist nil) + (qstring (cdr (assq 'query query))) + (group nil) + (article nil) + (process-environment (copy-sequence process-environment)) + ) + (setenv "LC_MESSAGES" "C") + (set-buffer (get-buffer-create nnir-tmp-buffer)) + (erase-buffer) + (let* ((cp-list + `( ,nnir-mairix-program + nil ; input from /dev/null + t ; output + nil ; don't redisplay + "-f" + ,nnir-mairix-config-file + "-r" ; produce raw output, do not link articles to + ; into result dir (see Mairix doc for info) + ,@nnir-mairix-additional-switches + ,@(split-string qstring) ; the query, in mairix format + )) + (exitstatus + (progn + (message "%s args: %s" nnir-mairix-program + (mapconcat 'identity (cddddr cp-list) " ")) + (apply 'call-process cp-list)))) + (unless (or (null exitstatus) + (zerop exitstatus)) + (nnheader-report 'nnir "Couldn't run mairix: %s" exitstatus) + ;; Mairix failure reason is in this buffer, show it if + ;; the user wants it. + (when (> gnus-verbose 6) + (display-buffer nnir-tmp-buffer)))) + + ;; Mairix output looks something like this: + ;; /home/henrik/Mail/mail/sent/1310 + ;; + ;; Matched 1 message + + (goto-char (point-min)) + (while (re-search-forward + "^\\/.+" + nil t) + (setq group (file-name-directory (match-string 0)) + article (file-name-nondirectory (match-string 0))) + + ;; make sure article and group is sane + (when (and (string-match "^[0-9]+$" article) + (not (null group))) + (when (string-match (concat "^" nnir-mairix-remove-prefix) group) + (setq group (replace-match "" t t group))) + + ;; remove trailing slash from groupname + (setq group (substring group 0 -1)) + + ;; stuff results into artlist vector + (push (vector (substitute ?. ?/ group) + (string-to-int article) + 1000) artlist))) + + (apply 'vector artlist)))) + ;;; Util Code: (defun nnir-read-parms (query) --=-=-= -- Dmitry Astapov //ADEpt GPG KeyID/fprint: F5D7639D/CA36 E6C4 815D 434D 0498 2B08 7867 4860 F5D7 639D --=-=-=--