* Mairix support for nnir.el
@ 2004-02-06 9:35 Dmitry Astapov
[not found] ` <m3k6z97its.fsf@quimbies.gnus.org>
0 siblings, 1 reply; 3+ messages in thread
From: Dmitry Astapov @ 2004-02-06 9:35 UTC (permalink / raw)
[-- Attachment #1: Type: text/plain, Size: 449 bytes --]
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.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: nnir-mairix-diff.patch --]
[-- Type: text/x-patch, Size: 4763 bytes --]
--- /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 <URL:http://http://www.rc0.org.uk/mairix/>
+
+(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)
[-- Attachment #3: Type: text/plain, Size: 107 bytes --]
--
Dmitry Astapov //ADEpt
GPG KeyID/fprint: F5D7639D/CA36 E6C4 815D 434D 0498 2B08 7867 4860 F5D7 639D
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Mairix support for nnir.el
[not found] ` <m3k6z97its.fsf@quimbies.gnus.org>
@ 2004-05-19 19:46 ` Kai Grossjohann
2004-05-19 19:47 ` Lars Magne Ingebrigtsen
0 siblings, 1 reply; 3+ messages in thread
From: Kai Grossjohann @ 2004-05-19 19:46 UTC (permalink / raw)
Lars Magne Ingebrigtsen <larsi@gnus.org> writes:
> Dmitry Astapov <adept@ukr.net> writes:
>
>> 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.
>
> That looks interesting. Kai?
Is that me? ;-) I ticked the message, but didn't get a round tuit :-|
But it's not forgotten!
While you're at it: Want to install it?
Kai
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Mairix support for nnir.el
2004-05-19 19:46 ` Kai Grossjohann
@ 2004-05-19 19:47 ` Lars Magne Ingebrigtsen
0 siblings, 0 replies; 3+ messages in thread
From: Lars Magne Ingebrigtsen @ 2004-05-19 19:47 UTC (permalink / raw)
Kai Grossjohann <kai.grossjohann@gmx.net> writes:
> Is that me? ;-) I ticked the message, but didn't get a round tuit :-|
> But it's not forgotten!
:-)
> While you're at it: Want to install it?
If you think the code's OK, I can do that, but I'll probably have to
do the paperwork thing first?
--
(domestic pets only, the antidote for overdose, milk.)
larsi@gnus.org * Lars Magne Ingebrigtsen
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2004-05-19 19:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-02-06 9:35 Mairix support for nnir.el Dmitry Astapov
[not found] ` <m3k6z97its.fsf@quimbies.gnus.org>
2004-05-19 19:46 ` Kai Grossjohann
2004-05-19 19:47 ` Lars Magne Ingebrigtsen
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).