annotate lisp/gnus/nnir.el @ 95625:ca7011bae7f9

(mail-interactive): Add :version.
author Glenn Morris <rgm@gnu.org>
date Sat, 07 Jun 2008 02:40:47 +0000
parents 49755ce71b9e
children 4bbbc2594f0b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1 ;;; nnir.el --- search mail with various search engines -*- coding: iso-8859-1 -*-
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2
95616
49755ce71b9e Formatting fixes.
Glenn Morris <rgm@gnu.org>
parents: 95610
diff changeset
3 ;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
49755ce71b9e Formatting fixes.
Glenn Morris <rgm@gnu.org>
parents: 95610
diff changeset
4 ;; 2007, 2008 Free Software Foundation, Inc.
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
5
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
6 ;; Author: Kai Großjohann <grossjohann@ls6.cs.uni-dortmund.de>
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
7 ;; Swish-e and Swish++ backends by:
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
8 ;; Christoph Conrad <christoph.conrad@gmx.de>.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
9 ;; IMAP backend by: Simon Josefsson <jas@pdc.kth.se>.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
10 ;; IMAP search by: Torsten Hilbrich <torsten.hilbrich <at> gmx.net>
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
11 ;; IMAP search improved by Daniel Pittman <daniel@rimspace.net>.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
12 ;; nnmaildir support for Swish++ and Namazu backends by:
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
13 ;; Justus Piater <Justus <at> Piater.name>
95616
49755ce71b9e Formatting fixes.
Glenn Morris <rgm@gnu.org>
parents: 95610
diff changeset
14 ;; Keywords: news mail searching ir
49755ce71b9e Formatting fixes.
Glenn Morris <rgm@gnu.org>
parents: 95610
diff changeset
15
49755ce71b9e Formatting fixes.
Glenn Morris <rgm@gnu.org>
parents: 95610
diff changeset
16 ;; This file is part of GNU Emacs.
49755ce71b9e Formatting fixes.
Glenn Morris <rgm@gnu.org>
parents: 95610
diff changeset
17
49755ce71b9e Formatting fixes.
Glenn Morris <rgm@gnu.org>
parents: 95610
diff changeset
18 ;; GNU Emacs is free software: you can redistribute it and/or modify
49755ce71b9e Formatting fixes.
Glenn Morris <rgm@gnu.org>
parents: 95610
diff changeset
19 ;; it under the terms of the GNU General Public License as published by
49755ce71b9e Formatting fixes.
Glenn Morris <rgm@gnu.org>
parents: 95610
diff changeset
20 ;; the Free Software Foundation, either version 3 of the License, or
49755ce71b9e Formatting fixes.
Glenn Morris <rgm@gnu.org>
parents: 95610
diff changeset
21 ;; (at your option) any later version.
49755ce71b9e Formatting fixes.
Glenn Morris <rgm@gnu.org>
parents: 95610
diff changeset
22
49755ce71b9e Formatting fixes.
Glenn Morris <rgm@gnu.org>
parents: 95610
diff changeset
23 ;; GNU Emacs is distributed in the hope that it will be useful,
49755ce71b9e Formatting fixes.
Glenn Morris <rgm@gnu.org>
parents: 95610
diff changeset
24 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
49755ce71b9e Formatting fixes.
Glenn Morris <rgm@gnu.org>
parents: 95610
diff changeset
25 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
49755ce71b9e Formatting fixes.
Glenn Morris <rgm@gnu.org>
parents: 95610
diff changeset
26 ;; GNU General Public License for more details.
49755ce71b9e Formatting fixes.
Glenn Morris <rgm@gnu.org>
parents: 95610
diff changeset
27
49755ce71b9e Formatting fixes.
Glenn Morris <rgm@gnu.org>
parents: 95610
diff changeset
28 ;; You should have received a copy of the GNU General Public License
49755ce71b9e Formatting fixes.
Glenn Morris <rgm@gnu.org>
parents: 95610
diff changeset
29 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
49755ce71b9e Formatting fixes.
Glenn Morris <rgm@gnu.org>
parents: 95610
diff changeset
30
49755ce71b9e Formatting fixes.
Glenn Morris <rgm@gnu.org>
parents: 95610
diff changeset
31 ;;; Commentary:
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
32
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
33 ;; TODO: Documentation in the Gnus manual
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
34
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
35 ;; From: Reiner Steib
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
36 ;; Subject: Re: Including nnir.el
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
37 ;; Newsgroups: gmane.emacs.gnus.general
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
38 ;; Message-ID: <v9d5dnp6aq.fsf@marauder.physik.uni-ulm.de>
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
39 ;; Date: 2006-06-05 22:49:01 GMT
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
40 ;;
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
41 ;; On Sun, Jun 04 2006, Sascha Wilde wrote:
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
42 ;;
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
43 ;; > The one thing most hackers like to forget: Documentation. By now the
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
44 ;; > documentation is only in the comments at the head of the source, I
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
45 ;; > would use it as basis to cook up some minimal texinfo docs.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
46 ;; >
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
47 ;; > Where in the existing gnus manual would this fit best?
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
48
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
49 ;; Maybe (info "(gnus)Combined Groups") for a general description.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
50 ;; `gnus-group-make-nnir-group' might be described in (info
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
51 ;; "(gnus)Foreign Groups") as well.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
52
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
53
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
54 ;; The most recent version of this can always be fetched from the Gnus
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
55 ;; CVS repository. See http://www.gnus.org/ for more information.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
56
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
57 ;; This code is still in the development stage but I'd like other
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
58 ;; people to have a look at it. Please do not hesitate to contact me
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
59 ;; with your ideas.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
60
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
61 ;; What does it do? Well, it allows you to index your mail using some
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
62 ;; search engine (freeWAIS-sf, swish-e and others -- see later),
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
63 ;; then type `G G' in the Group buffer and issue a query to the search
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
64 ;; engine. You will then get a buffer which shows all articles
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
65 ;; matching the query, sorted by Retrieval Status Value (score).
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
66
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
67 ;; When looking at the retrieval result (in the Summary buffer) you
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
68 ;; can type `G T' (aka M-x gnus-summary-nnir-goto-thread RET) on an
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
69 ;; article. You will be teleported into the group this article came
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
70 ;; from, showing the thread this article is part of. (See below for
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
71 ;; restrictions.)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
72
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
73 ;; The Lisp installation is simple: just put this file on your
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
74 ;; load-path, byte-compile it, and load it from ~/.gnus or something.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
75 ;; This will install a new command `G G' in your Group buffer for
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
76 ;; searching your mail. Note that you also need to configure a number
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
77 ;; of variables, as described below.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
78
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
79 ;; Restrictions:
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
80 ;;
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
81 ;; * If you don't use HyREX as your search engine, this expects that
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
82 ;; you use nnml or another one-file-per-message backend, because the
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
83 ;; others doesn't support nnfolder.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
84 ;; * It can only search the mail backend's which are supported by one
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
85 ;; search engine, because of different query languages.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
86 ;; * There are restrictions to the Wais setup.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
87 ;; * There are restrictions to the imap setup.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
88 ;; * gnus-summary-nnir-goto-thread: Fetches whole group first, before
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
89 ;; limiting to the right articles. This is much too slow, of
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
90 ;; course. May issue a query for number of articles to fetch; you
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
91 ;; must accept the default of all articles at this point or things
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
92 ;; may break.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
93
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
94 ;; The Lisp setup involves setting a few variables and setting up the
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
95 ;; search engine. You can define the variables in the server definition
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
96 ;; like this :
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
97 ;; (setq gnus-secondary-select-methods '(
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
98 ;; (nnimap "" (nnimap-address "localhost")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
99 ;; (nnir-search-engine hyrex)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
100 ;; (nnir-hyrex-additional-switches ("-d" "ddl-nnimap.xml"))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
101 ;; )))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
102 ;; Or you can define the global ones. The variables set in the mailer-
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
103 ;; definition will be used first.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
104 ;; The variable to set is `nnir-search-engine'. Choose one of the engines
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
105 ;; listed in `nnir-engines'. (Actually `nnir-engines' is an alist,
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
106 ;; type `C-h v nnir-engines RET' for more information; this includes
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
107 ;; examples for setting `nnir-search-engine', too.)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
108 ;;
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
109 ;; The variable nnir-mail-backend isn't used anymore.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
110 ;;
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
111
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
112 ;; You must also set up a search engine. I'll tell you about the two
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
113 ;; search engines currently supported:
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
114
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
115 ;; 1. freeWAIS-sf
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
116 ;;
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
117 ;; As always with freeWAIS-sf, you need a so-called `format file'. I
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
118 ;; use the following file:
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
119 ;;
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
120 ;; ,-----
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
121 ;; | # Kai's format file for freeWAIS-sf for indexing mails.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
122 ;; | # Each mail is in a file, much like the MH format.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
123 ;; |
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
124 ;; | # Document separator should never match -- each file is a document.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
125 ;; | record-sep: /^@this regex should never match@$/
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
126 ;; |
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
127 ;; | # Searchable fields specification.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
128 ;; |
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
129 ;; | region: /^[sS]ubject:/ /^[sS]ubject: */
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
130 ;; | subject "Subject header" stemming TEXT BOTH
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
131 ;; | end: /^[^ \t]/
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
132 ;; |
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
133 ;; | region: /^([tT][oO]|[cC][cC]):/ /^([tT][oO]|[cC][cC]): */
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
134 ;; | to "To and Cc headers" SOUNDEX BOTH
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
135 ;; | end: /^[^ \t]/
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
136 ;; |
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
137 ;; | region: /^[fF][rR][oO][mM]:/ /^[fF][rR][oO][mM]: */
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
138 ;; | from "From header" SOUNDEX BOTH
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
139 ;; | end: /^[^ \t]/
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
140 ;; |
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
141 ;; | region: /^$/
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
142 ;; | stemming TEXT GLOBAL
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
143 ;; | end: /^@this regex should never match@$/
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
144 ;; `-----
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
145 ;;
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
146 ;; 1998-07-22: waisindex would dump core on me for large articles with
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
147 ;; the above settings. I used /^$/ as the end regex for the global
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
148 ;; field. That seemed to work okay.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
149
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
150 ;; There is a Perl module called `WAIS.pm' which is available from
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
151 ;; CPAN as well as ls6-ftp.cs.uni-dortmund.de:/pub/wais/Perl. This
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
152 ;; module comes with a nifty tool called `makedb', which I use for
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
153 ;; indexing. Here's my `makedb.conf':
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
154 ;;
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
155 ;; ,-----
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
156 ;; | # Config file for makedb
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
157 ;; |
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
158 ;; | # Global options
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
159 ;; | waisindex = /usr/local/bin/waisindex
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
160 ;; | wais_opt = -stem -t fields
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
161 ;; | # `-stem' option necessary when `stemming' is specified for the
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
162 ;; | # global field in the *.fmt file
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
163 ;; |
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
164 ;; | # Own variables
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
165 ;; | homedir = /home/kai
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
166 ;; |
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
167 ;; | # The mail database.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
168 ;; | database = mail
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
169 ;; | files = `find $homedir/Mail -name \*[0-9] -print`
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
170 ;; | dbdir = $homedir/.wais
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
171 ;; | limit = 100
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
172 ;; `-----
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
173 ;;
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
174 ;; The Lisp setup involves the `nnir-wais-*' variables. The most
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
175 ;; difficult to understand variable is probably
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
176 ;; `nnir-wais-remove-prefix'. Here's what it does: the output of
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
177 ;; `waissearch' basically contains the file name and the (full)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
178 ;; directory name. As Gnus works with group names rather than
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
179 ;; directory names, the directory name is transformed into a group
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
180 ;; name as follows: first, a prefix is removed from the (full)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
181 ;; directory name, then all `/' are replaced with `.'. The variable
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
182 ;; `nnir-wais-remove-prefix' should contain a regex matching exactly
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
183 ;; this prefix. It defaults to `$HOME/Mail/' (note the trailing
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
184 ;; slash).
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
185
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
186 ;; 2. Namazu
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
187 ;;
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
188 ;; The Namazu backend requires you to have one directory containing all
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
189 ;; index files, this is controlled by the `nnir-namazu-index-directory'
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
190 ;; variable. To function the `nnir-namazu-remove-prefix' variable must
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
191 ;; also be correct, see the documentation for `nnir-wais-remove-prefix'
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
192 ;; above.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
193 ;;
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
194 ;; It is particularly important not to pass any any switches to namazu
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
195 ;; that will change the output format. Good switches to use include
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
196 ;; `--sort', `--ascending', `--early' and `--late'. Refer to the Namazu
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
197 ;; documentation for further information on valid switches.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
198 ;;
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
199 ;; To index my mail with the `mknmz' program I use the following
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
200 ;; configuration file:
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
201 ;;
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
202 ;; ,----
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
203 ;; | package conf; # Don't remove this line!
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
204 ;; |
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
205 ;; | # Paths which will not be indexed. Don't use `^' or `$' anchors.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
206 ;; | $EXCLUDE_PATH = "spam|sent";
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
207 ;; |
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
208 ;; | # Header fields which should be searchable. case-insensitive
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
209 ;; | $REMAIN_HEADER = "from|date|message-id|subject";
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
210 ;; |
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
211 ;; | # Searchable fields. case-insensitive
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
212 ;; | $SEARCH_FIELD = "from|date|message-id|subject";
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
213 ;; |
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
214 ;; | # The max length of a word.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
215 ;; | $WORD_LENG_MAX = 128;
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
216 ;; |
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
217 ;; | # The max length of a field.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
218 ;; | $MAX_FIELD_LENGTH = 256;
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
219 ;; `----
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
220 ;;
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
221 ;; My mail is stored in the directories ~/Mail/mail/, ~/Mail/lists/ and
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
222 ;; ~/Mail/archive/, so to index them I go to the directory set in
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
223 ;; `nnir-namazu-index-directory' and issue the following command.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
224 ;;
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
225 ;; mknmz --mailnews ~/Mail/archive/ ~/Mail/mail/ ~/Mail/lists/
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
226 ;;
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
227 ;; For maximum searching efficiency I have a cron job set to run this
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
228 ;; command every four hours.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
229
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
230 ;; 3. HyREX
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
231 ;;
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
232 ;; The HyREX backend requires you to have one directory from where all
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
233 ;; your relative paths are to, if you use them. This directory must be
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
234 ;; set in the `nnir-hyrex-index-directory' variable, which defaults to
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
235 ;; your home directory. You must also pass the base, class and
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
236 ;; directory options or simply your dll to the `nnir-hyrex-programm' by
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
237 ;; setting the `nnir-hyrex-additional-switches' variable accordently.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
238 ;; To function the `nnir-hyrex-remove-prefix' variable must also be
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
239 ;; correct, see the documentation for `nnir-wais-remove-prefix' above.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
240
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
241 ;; 4. find-grep
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
242 ;;
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
243 ;; The find-grep engine simply runs find(1) to locate eligible
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
244 ;; articles and searches them with grep(1). This, of course, is much
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
245 ;; slower than using a proper search engine but OTOH doesn't require
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
246 ;; maintenance of an index and is still faster than using any built-in
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
247 ;; means for searching. The method specification of the server to
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
248 ;; search must include a directory for this engine to work (E.g.,
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
249 ;; `nnml-directory'). The tools must be POSIX compliant. GNU Find
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
250 ;; prior to version 4.2.12 (4.2.26 on Linux due to incorrect ARG_MAX
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
251 ;; handling) does not work.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
252 ;; ,----
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
253 ;; | ;; find-grep configuration for searching the Gnus Cache
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
254 ;; |
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
255 ;; | (nnml "cache"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
256 ;; | (nnml-get-new-mail nil)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
257 ;; | (nnir-search-engine find-grep)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
258 ;; | (nnml-directory "~/News/cache/")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
259 ;; | (nnml-active-file "~/News/cache/active"))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
260 ;; `----
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
261
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
262 ;; Developer information:
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
263
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
264 ;; I have tried to make the code expandable. Basically, it is divided
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
265 ;; into two layers. The upper layer is somewhat like the `nnvirtual'
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
266 ;; or `nnkiboze' backends: given a specification of what articles to
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
267 ;; show from another backend, it creates a group containing exactly
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
268 ;; those articles. The lower layer issues a query to a search engine
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
269 ;; and produces such a specification of what articles to show from the
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
270 ;; other backend.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
271
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
272 ;; The interface between the two layers consists of the single
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
273 ;; function `nnir-run-query', which just selects the appropriate
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
274 ;; function for the search engine one is using. The input to
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
275 ;; `nnir-run-query' is a string, representing the query as input by
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
276 ;; the user. The output of `nnir-run-query' is supposed to be a
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
277 ;; vector, each element of which should in turn be a three-element
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
278 ;; vector. The first element should be full group name of the article,
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
279 ;; the second element should be the article number, and the third
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
280 ;; element should be the Retrieval Status Value (RSV) as returned from
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
281 ;; the search engine. An RSV is the score assigned to the document by
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
282 ;; the search engine. For Boolean search engines, the
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
283 ;; RSV is always 1000 (or 1 or 100, or whatever you like).
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
284
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
285 ;; The sorting order of the articles in the summary buffer created by
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
286 ;; nnir is based on the order of the articles in the above mentioned
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
287 ;; vector, so that's where you can do the sorting you'd like. Maybe
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
288 ;; it would be nice to have a way of displaying the search result
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
289 ;; sorted differently?
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
290
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
291 ;; So what do you need to do when you want to add another search
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
292 ;; engine? You write a function that executes the query. Temporary
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
293 ;; data from the search engine can be put in `nnir-tmp-buffer'. This
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
294 ;; function should return the list of articles as a vector, as
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
295 ;; described above. Then, you need to register this backend in
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
296 ;; `nnir-engines'. Then, users can choose the backend by setting
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
297 ;; `nnir-search-engine'.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
298
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
299 ;; Todo, or future ideas:
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
300
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
301 ;; * It should be possible to restrict search to certain groups.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
302 ;;
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
303 ;; * There is currently no error checking.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
304 ;;
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
305 ;; * The summary buffer display is currently really ugly, with all the
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
306 ;; added information in the subjects. How could I make this
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
307 ;; prettier?
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
308 ;;
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
309 ;; * A function which can be called from an nnir summary buffer which
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
310 ;; teleports you into the group the current article came from and
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
311 ;; shows you the whole thread this article is part of.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
312 ;; Implementation suggestions?
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
313 ;; (1998-07-24: There is now a preliminary implementation, but
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
314 ;; it is much too slow and quite fragile.)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
315 ;;
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
316 ;; * Support other mail backends. In particular, probably quite a few
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
317 ;; people use nnfolder. How would one go about searching nnfolders
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
318 ;; and producing the right data needed? The group name and the RSV
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
319 ;; are simple, but what about the article number?
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
320 ;; - The article number is encoded in the `X-Gnus-Article-Number'
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
321 ;; header of each mail.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
322 ;; - The HyREX engine supports nnfolder.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
323 ;;
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
324 ;; * Support compressed mail files. Probably, just stripping off the
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
325 ;; `.gz' or `.Z' file name extension is sufficient.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
326 ;;
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
327 ;; * At least for imap, the query is performed twice.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
328 ;;
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
329
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
330 ;; Have you got other ideas?
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
331
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
332 ;;; Setup Code:
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
333
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
334 (require 'nnoo)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
335 (require 'gnus-group)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
336 (require 'gnus-sum)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
337 (require 'message)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
338 (require 'gnus-util)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
339 (eval-and-compile
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
340 (require 'cl))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
341
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
342 (nnoo-declare nnir)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
343 (nnoo-define-basics nnir)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
344
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
345 (gnus-declare-backend "nnir" 'mail)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
346
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
347 (defvar nnir-imap-search-field "TEXT"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
348 "The IMAP search item when doing an nnir search")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
349
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
350 (defvar nnir-imap-search-arguments
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
351 '(("Whole message" . "TEXT")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
352 ("Subject" . "SUBJECT")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
353 ("To" . "TO")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
354 ("From" . "FROM")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
355 (nil . "HEADER \"%s\""))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
356 "Mapping from user readable strings to IMAP search items for use in nnir")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
357
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
358 (defvar nnir-imap-search-argument-history ()
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
359 "The history for querying search options in nnir")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
360
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
361 ;;; Developer Extension Variable:
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
362
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
363 (defvar nnir-engines
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
364 `((wais nnir-run-waissearch
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
365 ())
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
366 (imap nnir-run-imap
95616
49755ce71b9e Formatting fixes.
Glenn Morris <rgm@gnu.org>
parents: 95610
diff changeset
367 ((criteria
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
368 "Search in: " ; Prompt
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
369 ,nnir-imap-search-arguments ; alist for completing
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
370 nil ; no filtering
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
371 nil ; allow any user input
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
372 nil ; initial value
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
373 nnir-imap-search-argument-history ; the history to use
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
374 ,nnir-imap-search-field ; default
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
375 )))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
376 (swish++ nnir-run-swish++
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
377 ((group . "Group spec: ")))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
378 (swish-e nnir-run-swish-e
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
379 ((group . "Group spec: ")))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
380 (namazu nnir-run-namazu
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
381 ())
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
382 (hyrex nnir-run-hyrex
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
383 ((group . "Group spec: ")))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
384 (find-grep nnir-run-find-grep
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
385 ((grep-options . "Grep options: "))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
386 "Alist of supported search engines.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
387 Each element in the alist is a three-element list (ENGINE FUNCTION ARGS).
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
388 ENGINE is a symbol designating the searching engine. FUNCTION is also
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
389 a symbol, giving the function that does the search. The third element
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
390 ARGS is a list of cons pairs (PARAM . PROMPT). When issuing a query,
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
391 the FUNCTION will issue a query for each of the PARAMs, using PROMPT.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
392
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
393 The value of `nnir-search-engine' must be one of the ENGINE symbols.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
394 For example, use the following line for searching using freeWAIS-sf:
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
395 (setq nnir-search-engine 'wais)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
396 Use the following line if you read your mail via IMAP and your IMAP
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
397 server supports searching:
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
398 (setq nnir-search-engine 'imap)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
399 Note that you have to set additional variables for most backends. For
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
400 example, the `wais' backend needs the variables `nnir-wais-program',
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
401 `nnir-wais-database' and `nnir-wais-remove-prefix'.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
402
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
403 Add an entry here when adding a new search engine.")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
404
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
405 ;;; User Customizable Variables:
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
406
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
407 (defgroup nnir nil
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
408 "Search nnmh and nnml groups in Gnus with swish-e, freeWAIS-sf, or EWS."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
409 :group 'gnus)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
410
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
411 ;; Mail backend.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
412
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
413 ;; TODO:
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
414 ;; If `nil', use server parameters to find out which server to search. CCC
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
415 ;;
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
416 (defcustom nnir-mail-backend '(nnml "")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
417 "*Specifies which backend should be searched.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
418 More precisely, this is used to determine from which backend to fetch the
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
419 messages found.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
420
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
421 This must be equal to an existing server, so maybe it is best to use
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
422 something like the following:
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
423 (setq nnir-mail-backend (nth 0 gnus-secondary-select-methods))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
424 The above line works fine if the mail backend you want to search is
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
425 the first element of gnus-secondary-select-methods (`nth' starts counting
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
426 at zero)."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
427 :type '(sexp)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
428 :group 'nnir)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
429
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
430 ;; Search engine to use.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
431
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
432 (defcustom nnir-search-engine 'wais
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
433 "*The search engine to use. Must be a symbol.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
434 See `nnir-engines' for a list of supported engines, and for example
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
435 settings of `nnir-search-engine'."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
436 :type '(sexp)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
437 :group 'nnir)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
438
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
439 ;; freeWAIS-sf.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
440
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
441 (defcustom nnir-wais-program "waissearch"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
442 "*Name of waissearch executable."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
443 :type '(string)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
444 :group 'nnir)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
445
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
446 (defcustom nnir-wais-database (expand-file-name "~/.wais/mail")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
447 "*Name of Wais database containing the mail.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
448
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
449 Note that this should be a file name without extension. For example,
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
450 if you have a file /home/john/.wais/mail.fmt, use this:
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
451 (setq nnir-wais-database \"/home/john/.wais/mail\")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
452 The string given here is passed to `waissearch -d' as-is."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
453 :type '(file)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
454 :group 'nnir)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
455
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
456 (defcustom nnir-wais-remove-prefix (concat (getenv "HOME") "/Mail/")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
457 "*The prefix to remove from each directory name returned by waissearch
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
458 in order to get a group name (albeit with / instead of .). This is a
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
459 regular expression.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
460
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
461 For example, suppose that Wais returns file names such as
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
462 \"/home/john/Mail/mail/misc/42\". For this example, use the following
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
463 setting: (setq nnir-wais-remove-prefix \"/home/john/Mail/\")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
464 Note the trailing slash. Removing this prefix gives \"mail/misc/42\".
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
465 `nnir' knows to remove the \"/42\" and to replace \"/\" with \".\" to
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
466 arrive at the correct group name, \"mail.misc\"."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
467 :type '(regexp)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
468 :group 'nnir)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
469
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
470 (defcustom nnir-swish++-configuration-file
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
471 (expand-file-name "~/Mail/swish++.conf")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
472 "*Configuration file for swish++."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
473 :type '(file)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
474 :group 'nnir)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
475
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
476 (defcustom nnir-swish++-program "search"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
477 "*Name of swish++ search executable."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
478 :type '(string)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
479 :group 'nnir)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
480
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
481 (defcustom nnir-swish++-additional-switches '()
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
482 "*A list of strings, to be given as additional arguments to swish++.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
483
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
484 Note that this should be a list. Ie, do NOT use the following:
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
485 (setq nnir-swish++-additional-switches \"-i -w\") ; wrong
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
486 Instead, use this:
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
487 (setq nnir-swish++-additional-switches '(\"-i\" \"-w\"))"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
488 :type '(repeat (string))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
489 :group 'nnir)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
490
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
491 (defcustom nnir-swish++-remove-prefix (concat (getenv "HOME") "/Mail/")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
492 "*The prefix to remove from each file name returned by swish++
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
493 in order to get a group name (albeit with / instead of .). This is a
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
494 regular expression.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
495
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
496 This variable is very similar to `nnir-wais-remove-prefix', except
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
497 that it is for swish++, not Wais."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
498 :type '(regexp)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
499 :group 'nnir)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
500
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
501 ;; Swish-E.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
502 ;; URL: http://sunsite.berkeley.edu/SWISH-E/
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
503 ;; New version: http://www.boe.es/swish-e
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
504 ;; Variables `nnir-swish-e-index-file', `nnir-swish-e-program' and
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
505 ;; `nnir-swish-e-additional-switches'
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
506
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
507 (make-obsolete-variable 'nnir-swish-e-index-file
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
508 'nnir-swish-e-index-files)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
509 (defcustom nnir-swish-e-index-file
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
510 (expand-file-name "~/Mail/index.swish-e")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
511 "*Index file for swish-e.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
512 This could be a server parameter.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
513 It is never consulted once `nnir-swish-e-index-files', which should be
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
514 used instead, has been customized."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
515 :type '(file)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
516 :group 'nnir)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
517
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
518 (defcustom nnir-swish-e-index-files
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
519 (list nnir-swish-e-index-file)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
520 "*List of index files for swish-e.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
521 This could be a server parameter."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
522 :type '(repeat (file))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
523 :group 'nnir)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
524
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
525 (defcustom nnir-swish-e-program "swish-e"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
526 "*Name of swish-e search executable.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
527 This cannot be a server parameter."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
528 :type '(string)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
529 :group 'nnir)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
530
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
531 (defcustom nnir-swish-e-additional-switches '()
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
532 "*A list of strings, to be given as additional arguments to swish-e.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
533
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
534 Note that this should be a list. Ie, do NOT use the following:
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
535 (setq nnir-swish-e-additional-switches \"-i -w\") ; wrong
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
536 Instead, use this:
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
537 (setq nnir-swish-e-additional-switches '(\"-i\" \"-w\"))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
538
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
539 This could be a server parameter."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
540 :type '(repeat (string))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
541 :group 'nnir)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
542
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
543 (defcustom nnir-swish-e-remove-prefix (concat (getenv "HOME") "/Mail/")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
544 "*The prefix to remove from each file name returned by swish-e
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
545 in order to get a group name (albeit with / instead of .). This is a
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
546 regular expression.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
547
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
548 This variable is very similar to `nnir-wais-remove-prefix', except
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
549 that it is for swish-e, not Wais.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
550
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
551 This could be a server parameter."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
552 :type '(regexp)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
553 :group 'nnir)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
554
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
555 ;; HyREX engine, see <URL:http://ls6-www.cs.uni-dortmund.de/>
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
556
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
557 (defcustom nnir-hyrex-program "nnir-search"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
558 "*Name of the nnir-search executable."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
559 :type '(string)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
560 :group 'nnir)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
561
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
562 (defcustom nnir-hyrex-additional-switches '()
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
563 "*A list of strings, to be given as additional arguments for nnir-search.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
564 Note that this should be a list. Ie, do NOT use the following:
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
565 (setq nnir-hyrex-additional-switches \"-ddl ddl.xml -c nnir\") ; wrong !
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
566 Instead, use this:
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
567 (setq nnir-hyrex-additional-switches '(\"-ddl\" \"ddl.xml\" \"-c\" \"nnir\"))"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
568 :type '(repeat (string))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
569 :group 'nnir)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
570
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
571 (defcustom nnir-hyrex-index-directory (getenv "HOME")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
572 "*Index directory for HyREX."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
573 :type '(directory)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
574 :group 'nnir)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
575
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
576 (defcustom nnir-hyrex-remove-prefix (concat (getenv "HOME") "/Mail/")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
577 "*The prefix to remove from each file name returned by HyREX
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
578 in order to get a group name (albeit with / instead of .).
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
579
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
580 For example, suppose that HyREX returns file names such as
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
581 \"/home/john/Mail/mail/misc/42\". For this example, use the following
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
582 setting: (setq nnir-hyrex-remove-prefix \"/home/john/Mail/\")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
583 Note the trailing slash. Removing this prefix gives \"mail/misc/42\".
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
584 `nnir' knows to remove the \"/42\" and to replace \"/\" with \".\" to
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
585 arrive at the correct group name, \"mail.misc\"."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
586 :type '(directory)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
587 :group 'nnir)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
588
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
589 ;; Namazu engine, see <URL:http://ww.namazu.org/>
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
590
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
591 (defcustom nnir-namazu-program "namazu"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
592 "*Name of Namazu search executable."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
593 :type '(string)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
594 :group 'nnir)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
595
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
596 (defcustom nnir-namazu-index-directory (expand-file-name "~/Mail/namazu/")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
597 "*Index directory for Namazu."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
598 :type '(directory)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
599 :group 'nnir)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
600
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
601 (defcustom nnir-namazu-additional-switches '()
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
602 "*A list of strings, to be given as additional arguments to namazu.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
603 The switches `-q', `-a', and `-s' are always used, very few other switches
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
604 make any sense in this context.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
605
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
606 Note that this should be a list. Ie, do NOT use the following:
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
607 (setq nnir-namazu-additional-switches \"-i -w\") ; wrong
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
608 Instead, use this:
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
609 (setq nnir-namazu-additional-switches '(\"-i\" \"-w\"))"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
610 :type '(repeat (string))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
611 :group 'nnir)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
612
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
613 (defcustom nnir-namazu-remove-prefix (concat (getenv "HOME") "/Mail/")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
614 "*The prefix to remove from each file name returned by Namazu
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
615 in order to get a group name (albeit with / instead of .).
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
616
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
617 This variable is very similar to `nnir-wais-remove-prefix', except
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
618 that it is for Namazu, not Wais."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
619 :type '(directory)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
620 :group 'nnir)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
621
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
622 ;;; Internal Variables:
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
623
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
624 (defvar nnir-current-query nil
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
625 "Internal: stores current query (= group name).")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
626
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
627 (defvar nnir-current-server nil
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
628 "Internal: stores current server (does it ever change?).")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
629
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
630 (defvar nnir-current-group-marked nil
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
631 "Internal: stores current list of process-marked groups.")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
632
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
633 (defvar nnir-artlist nil
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
634 "Internal: stores search result.")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
635
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
636 (defvar nnir-tmp-buffer " *nnir*"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
637 "Internal: temporary buffer.")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
638
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
639 ;;; Code:
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
640
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
641 ;; Gnus glue.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
642
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
643 (defun gnus-group-make-nnir-group (extra-parms query)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
644 "Create an nnir group. Asks for query."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
645 (interactive "P\nsQuery: ")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
646 (setq nnir-current-query nil
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
647 nnir-current-server nil
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
648 nnir-current-group-marked nil
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
649 nnir-artlist nil)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
650 (let ((parms nil))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
651 (if extra-parms
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
652 (setq parms (nnir-read-parms query))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
653 (setq parms (list (cons 'query query))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
654 (add-to-list 'parms (cons 'unique-id (message-unique-id)) t)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
655 (gnus-group-read-ephemeral-group
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
656 (concat "nnir:" (prin1-to-string parms)) '(nnir "") t
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
657 (cons (current-buffer)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
658 gnus-current-window-configuration)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
659 nil)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
660
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
661 (defun nnir-group-mode-hook ()
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
662 (define-key gnus-group-mode-map (kbd "G G")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
663 'gnus-group-make-nnir-group))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
664 (add-hook 'gnus-group-mode-hook 'nnir-group-mode-hook)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
665
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
666 ;; Why is this needed? Is this for compatibility with old/new gnusae? Using
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
667 ;; gnus-group-server instead works for me. -- Justus Piater
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
668 (defmacro nnir-group-server (group)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
669 "Return the server for a newsgroup GROUP.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
670 The returned format is as `gnus-server-to-method' needs it. See
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
671 `gnus-group-real-prefix' and `gnus-group-real-name'."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
672 `(let ((gname ,group))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
673 (if (string-match "^\\([^:]+\\):" gname)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
674 (progn
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
675 (setq gname (match-string 1 gname))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
676 (if (string-match "^\\([^+]+\\)\\+\\(.+\\)$" gname)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
677 (format "%s:%s" (match-string 1 gname) (match-string 2 gname))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
678 (concat gname ":")))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
679 (format "%s:%s" (car gnus-select-method) (cadr gnus-select-method)))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
680
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
681 ;; Summary mode commands.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
682
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
683 (defun gnus-summary-nnir-goto-thread ()
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
684 "Only applies to nnir groups. Go to group this article came from
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
685 and show thread that contains this article."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
686 (interactive)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
687 (unless (eq 'nnir (car (gnus-find-method-for-group gnus-newsgroup-name)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
688 (error "Can't execute this command unless in nnir group."))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
689 (let* ((cur (gnus-summary-article-number))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
690 (group (nnir-artlist-artitem-group nnir-artlist cur))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
691 (backend-number (nnir-artlist-artitem-number nnir-artlist cur))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
692 server backend-group)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
693 (setq server (nnir-group-server group))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
694 (setq backend-group (gnus-group-real-name group))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
695 (gnus-group-read-ephemeral-group
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
696 backend-group
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
697 (gnus-server-to-method server)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
698 t ; activate
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
699 (cons (current-buffer)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
700 'summary) ; window config
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
701 nil
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
702 (list backend-number))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
703 (gnus-summary-limit (list backend-number))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
704 (gnus-summary-refer-thread)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
705
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
706 (if (fboundp 'eval-after-load)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
707 (eval-after-load "gnus-sum"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
708 '(define-key gnus-summary-goto-map
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
709 "T" 'gnus-summary-nnir-goto-thread))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
710 (add-hook 'gnus-summary-mode-hook
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
711 (function (lambda ()
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
712 (define-key gnus-summary-goto-map
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
713 "T" 'gnus-summary-nnir-goto-thread)))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
714
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
715
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
716
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
717 ;; Gnus backend interface functions.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
718
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
719 (deffoo nnir-open-server (server &optional definitions)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
720 ;; Just set the server variables appropriately.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
721 (nnoo-change-server 'nnir server definitions))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
722
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
723 (deffoo nnir-request-group (group &optional server fast)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
724 "GROUP is the query string."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
725 (nnir-possibly-change-server server)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
726 ;; Check for cache and return that if appropriate.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
727 (if (and (equal group nnir-current-query)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
728 (equal gnus-group-marked nnir-current-group-marked)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
729 (or (null server)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
730 (equal server nnir-current-server)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
731 nnir-artlist
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
732 ;; Cache miss.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
733 (setq nnir-artlist (nnir-run-query group)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
734 (save-excursion
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
735 (set-buffer nntp-server-buffer)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
736 (if (zerop (length nnir-artlist))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
737 (progn
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
738 (setq nnir-current-query nil
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
739 nnir-current-server nil
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
740 nnir-current-group-marked nil
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
741 nnir-artlist nil)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
742 (nnheader-report 'nnir "Search produced empty results."))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
743 ;; Remember data for cache.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
744 (setq nnir-current-query group)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
745 (when server (setq nnir-current-server server))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
746 (setq nnir-current-group-marked gnus-group-marked)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
747 (nnheader-insert "211 %d %d %d %s\n"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
748 (nnir-artlist-length nnir-artlist) ; total #
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
749 1 ; first #
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
750 (nnir-artlist-length nnir-artlist) ; last #
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
751 group)))) ; group name
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
752
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
753 (deffoo nnir-retrieve-headers (articles &optional group server fetch-old)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
754 (save-excursion
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
755 (let ((artlist (copy-sequence articles))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
756 art artitem artgroup artno artrsv artfullgroup
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
757 novitem novdata foo server)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
758 (while (not (null artlist))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
759 (setq art (car artlist))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
760 (or (numberp art)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
761 (nnheader-report
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
762 'nnir
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
763 "nnir-retrieve-headers doesn't grok message ids: %s"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
764 art))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
765 (setq artitem (nnir-artlist-article nnir-artlist art))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
766 (setq artrsv (nnir-artitem-rsv artitem))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
767 (setq artfullgroup (nnir-artitem-group artitem))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
768 (setq artno (nnir-artitem-number artitem))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
769 (setq artgroup (gnus-group-real-name artfullgroup))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
770 (setq server (nnir-group-server artfullgroup))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
771 ;; retrieve NOV or HEAD data for this article, transform into
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
772 ;; NOV data and prepend to `novdata'
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
773 (set-buffer nntp-server-buffer)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
774 (nnir-possibly-change-server server)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
775 (let ((gnus-override-method
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
776 (gnus-server-to-method server)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
777 (case (setq foo (gnus-retrieve-headers (list artno) artfullgroup nil))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
778 (nov
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
779 (goto-char (point-min))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
780 (setq novitem (nnheader-parse-nov))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
781 (unless novitem
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
782 (pop-to-buffer nntp-server-buffer)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
783 (error
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
784 "nnheader-parse-nov returned nil for article %s in group %s"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
785 artno artfullgroup)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
786 (headers
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
787 (goto-char (point-min))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
788 (setq novitem (nnheader-parse-head))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
789 (unless novitem
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
790 (pop-to-buffer nntp-server-buffer)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
791 (error
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
792 "nnheader-parse-head returned nil for article %s in group %s"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
793 artno artfullgroup)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
794 (t (error "Unknown header type %s while requesting article %s of group %s"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
795 foo artno artfullgroup))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
796 ;; replace article number in original group with article number
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
797 ;; in nnir group
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
798 (mail-header-set-number novitem art)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
799 (mail-header-set-from novitem
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
800 (mail-header-from novitem))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
801 (mail-header-set-subject
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
802 novitem
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
803 (format "[%d: %s/%d] %s"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
804 artrsv artgroup artno
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
805 (mail-header-subject novitem)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
806 ;;-(mail-header-set-extra novitem nil)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
807 (push novitem novdata)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
808 (setq artlist (cdr artlist)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
809 (setq novdata (nreverse novdata))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
810 (set-buffer nntp-server-buffer) (erase-buffer)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
811 (mapc 'nnheader-insert-nov novdata)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
812 'nov)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
813
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
814 (deffoo nnir-request-article (article
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
815 &optional group server to-buffer)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
816 (if (stringp article)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
817 (nnheader-report
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
818 'nnir
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
819 "nnir-retrieve-headers doesn't grok message ids: %s"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
820 article)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
821 (save-excursion
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
822 (let* ((artitem (nnir-artlist-article nnir-artlist
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
823 article))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
824 (artfullgroup (nnir-artitem-group artitem))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
825 (artno (nnir-artitem-number artitem))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
826 ;; Bug?
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
827 ;; Why must we bind nntp-server-buffer here? It won't
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
828 ;; work if `buf' is used, say. (Of course, the set-buffer
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
829 ;; line below must then be updated, too.)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
830 (nntp-server-buffer (or to-buffer nntp-server-buffer)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
831 (set-buffer nntp-server-buffer)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
832 (erase-buffer)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
833 (message "Requesting article %d from group %s"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
834 artno artfullgroup)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
835 (gnus-request-article artno artfullgroup nntp-server-buffer)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
836 (cons artfullgroup artno)))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
837
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
838
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
839 (nnoo-define-skeleton nnir)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
840
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
841
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
842 (defmacro nnir-add-result (dirnam artno score prefix server artlist)
95616
49755ce71b9e Formatting fixes.
Glenn Morris <rgm@gnu.org>
parents: 95610
diff changeset
843 "Ask `nnir-compose-result' to construct a result vector,
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
844 and if it is non-nil, add it to artlist."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
845 `(let ((result (nnir-compose-result ,dirnam ,artno ,score ,prefix ,server)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
846 (when (not (null result))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
847 (push result ,artlist))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
848
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
849 (autoload 'nnmaildir-base-name-to-article-number "nnmaildir")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
850
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
851 ;; Helper function currently used by the Swish++ and Namazu backends;
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
852 ;; perhaps useful for other backends as well
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
853 (defun nnir-compose-result (dirnam article score prefix server)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
854 "Extract the group from dirnam, and create a result vector
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
855 ready to be added to the list of search results."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
856
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
857 ;; remove nnir-*-remove-prefix from beginning of dirnam filename
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
858 (when (string-match (concat "^" prefix) dirnam)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
859 (setq dirnam (replace-match "" t t dirnam)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
860
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
861 (when (file-readable-p (concat prefix dirnam article))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
862 ;; remove trailing slash and, for nnmaildir, cur/new/tmp
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
863 (setq dirnam
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
864 (substring dirnam 0 (if (string= server "nnmaildir:") -5 -1)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
865
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
866 ;; Set group to dirnam without any leading dots or slashes,
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
867 ;; and with all subsequent slashes replaced by dots
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
868 (let ((group (gnus-replace-in-string
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
869 (gnus-replace-in-string dirnam "^[./\\]" "" t)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
870 "[/\\]" "." t)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
871
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
872 (vector (nnir-group-full-name group server)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
873 (if (string= server "nnmaildir:")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
874 (nnmaildir-base-name-to-article-number
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
875 (substring article 0 (string-match ":" article))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
876 group nil)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
877 (string-to-number article))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
878 (string-to-number score)))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
879
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
880 ;;; Search Engine Interfaces:
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
881
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
882 ;; freeWAIS-sf interface.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
883 (defun nnir-run-waissearch (query server &optional group)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
884 "Run given query agains waissearch. Returns vector of (group name, file name)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
885 pairs (also vectors, actually)."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
886 (when group
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
887 (error "The freeWAIS-sf backend cannot search specific groups."))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
888 (save-excursion
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
889 (let ((qstring (cdr (assq 'query query)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
890 (prefix (nnir-read-server-parm 'nnir-wais-remove-prefix server))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
891 artlist score artno dirnam)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
892 (set-buffer (get-buffer-create nnir-tmp-buffer))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
893 (erase-buffer)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
894 (message "Doing WAIS query %s..." query)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
895 (call-process nnir-wais-program
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
896 nil ; input from /dev/null
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
897 t ; output to current buffer
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
898 nil ; don't redisplay
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
899 "-d" (nnir-read-server-parm 'nnir-wais-database server) ; database to search
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
900 qstring)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
901 (message "Massaging waissearch output...")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
902 ;; remove superfluous lines
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
903 (keep-lines "Score:")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
904 ;; extract data from result lines
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
905 (goto-char (point-min))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
906 (while (re-search-forward
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
907 "Score: +\\([0-9]+\\).*'\\([0-9]+\\) +\\([^']+\\)/'" nil t)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
908 (setq score (match-string 1)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
909 artno (match-string 2)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
910 dirnam (match-string 3))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
911 (unless (string-match prefix dirnam)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
912 (nnheader-report 'nnir "Dir name %s doesn't contain prefix %s"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
913 dirnam prefix))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
914 (setq group (substitute ?. ?/ (replace-match "" t t dirnam)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
915 (push (vector (nnir-group-full-name group server)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
916 (string-to-number artno)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
917 (string-to-number score))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
918 artlist))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
919 (message "Massaging waissearch output...done")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
920 (apply 'vector
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
921 (sort* artlist
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
922 (function (lambda (x y)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
923 (> (nnir-artitem-rsv x)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
924 (nnir-artitem-rsv y)))))))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
925
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
926 ;; IMAP interface.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
927 ;; todo:
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
928 ;; nnir invokes this two (2) times???!
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
929 ;; we should not use nnimap at all but open our own server connection
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
930 ;; we should not LIST * but use nnimap-list-pattern from defs
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
931 ;; send queries as literals
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
932 ;; handle errors
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
933
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
934 (autoload 'nnimap-open-server "nnimap")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
935 (defvar nnimap-server-buffer) ;; nnimap.el
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
936 (autoload 'imap-mailbox-select "imap")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
937 (autoload 'imap-search "imap")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
938 (autoload 'imap-quote-specials "imap")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
939
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
940 (defun nnir-run-imap (query srv &optional group-option)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
941 "Run a search against an IMAP back-end server.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
942 This uses a custom query language parser; see `nnir-imap-make-query' for
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
943 details on the language and supported extensions"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
944 (save-excursion
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
945 (let ((qstring (cdr (assq 'query query)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
946 (server (cadr (gnus-server-to-method srv)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
947 (group (or group-option (gnus-group-group-name)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
948 (defs (caddr (gnus-server-to-method srv)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
949 (criteria (or (cdr (assq 'criteria query))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
950 nnir-imap-search-field))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
951 artlist buf)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
952 (message "Opening server %s" server)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
953 (condition-case ()
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
954 (when (nnimap-open-server server defs) ;; xxx
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
955 (setq buf nnimap-server-buffer) ;; xxx
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
956 (message "Searching %s..." group)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
957 (let ((arts 0)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
958 (mbx (gnus-group-real-name group)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
959 (when (imap-mailbox-select mbx nil buf)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
960 (mapc
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
961 (lambda (artnum)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
962 (push (vector group artnum 1) artlist)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
963 (setq arts (1+ arts)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
964 (imap-search (nnir-imap-make-query criteria qstring) buf))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
965 (message "Searching %s... %d matches" mbx arts)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
966 (message "Searching %s...done" group))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
967 (quit nil))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
968 (reverse artlist))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
969
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
970 (defun nnir-imap-make-query (criteria qstring)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
971 "Parse the query string and criteria into an appropriate IMAP search
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
972 expression, returning the string query to make.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
973
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
974 This implements a little language designed to return the expected results
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
975 to an arbitrary query string to the end user.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
976
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
977 The search is always case-insensitive, as defined by RFC2060, and supports
95616
49755ce71b9e Formatting fixes.
Glenn Morris <rgm@gnu.org>
parents: 95610
diff changeset
978 the following features (inspired by the Google search input language):
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
979
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
980 Automatic \"and\" queries
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
981 If you specify multiple words then they will be treated as an \"and\"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
982 expression intended to match all components.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
983
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
984 Phrase searches
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
985 If you wrap your query in double-quotes then it will be treated as a
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
986 literal string.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
987
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
988 Negative terms
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
989 If you precede a term with \"-\" then it will negate that.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
990
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
991 \"OR\" queries
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
992 If you include an upper-case \"OR\" in your search it will cause the
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
993 term before it and the term after it to be treated as alternatives.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
994
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
995 In future the following will be added to the language:
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
996 * support for date matches
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
997 * support for location of text matching within the query
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
998 * from/to/etc headers
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
999 * additional search terms
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1000 * flag based searching
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1001 * anything else that the RFC supports, basically."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1002 ;; Walk through the query and turn it into an IMAP query string.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1003 (nnir-imap-query-to-imap criteria (nnir-imap-parse-query qstring)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1004
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1005
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1006 (defun nnir-imap-query-to-imap (criteria query)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1007 "Turn a s-expression format query into IMAP."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1008 (mapconcat
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1009 ;; Turn the expressions into IMAP text
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1010 (lambda (item)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1011 (nnir-imap-expr-to-imap criteria item))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1012 ;; The query, already in s-expr format.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1013 query
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1014 ;; Append a space between each expression
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1015 " "))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1016
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1017
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1018 (defun nnir-imap-expr-to-imap (criteria expr)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1019 "Convert EXPR into an IMAP search expression on CRITERIA"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1020 ;; What sort of expression is this, eh?
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1021 (cond
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1022 ;; Simple string term
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1023 ((stringp expr)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1024 (format "%s \"%s\"" criteria (imap-quote-specials expr)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1025 ;; Trivial term: and
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1026 ((eq expr 'and) nil)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1027 ;; Composite term: or expression
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1028 ((eq (car-safe expr) 'or)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1029 (format "OR %s %s"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1030 (nnir-imap-expr-to-imap criteria (second expr))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1031 (nnir-imap-expr-to-imap criteria (third expr))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1032 ;; Composite term: just the fax, mam
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1033 ((eq (car-safe expr) 'not)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1034 (format "NOT (%s)" (nnir-imap-query-to-imap criteria (rest expr))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1035 ;; Composite term: just expand it all.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1036 ((and (not (null expr)) (listp expr))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1037 (format "(%s)" (nnir-imap-query-to-imap criteria expr)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1038 ;; Complex value, give up for now.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1039 (t (error "Unhandled input: %S" expr))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1040
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1041
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1042 (defun nnir-imap-parse-query (string)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1043 "Turn STRING into an s-expression based query based on the IMAP
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1044 query language as defined in `nnir-imap-make-query'.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1045
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1046 This involves turning individual tokens into higher level terms
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1047 that the search language can then understand and use."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1048 (with-temp-buffer
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1049 ;; Set up the parsing environment.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1050 (insert string)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1051 (goto-char (point-min))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1052 ;; Now, collect the output terms and return them.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1053 (let (out)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1054 (while (not (nnir-imap-end-of-input))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1055 (push (nnir-imap-next-expr) out))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1056 (reverse out))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1057
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1058
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1059 (defun nnir-imap-next-expr (&optional count)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1060 "Return the next expression from the current buffer."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1061 (let ((term (nnir-imap-next-term count))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1062 (next (nnir-imap-peek-symbol)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1063 ;; Are we looking at an 'or' expression?
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1064 (cond
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1065 ;; Handle 'expr or expr'
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1066 ((eq next 'or)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1067 (list 'or term (nnir-imap-next-expr 2)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1068 ;; Anything else
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1069 (t term))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1070
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1071
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1072 (defun nnir-imap-next-term (&optional count)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1073 "Return the next TERM from the current buffer."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1074 (let ((term (nnir-imap-next-symbol count)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1075 ;; What sort of term is this?
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1076 (cond
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1077 ;; and -- just ignore it
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1078 ((eq term 'and) 'and)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1079 ;; negated term
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1080 ((eq term 'not) (list 'not (nnir-imap-next-expr)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1081 ;; generic term
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1082 (t term))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1083
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1084
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1085 (defun nnir-imap-peek-symbol ()
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1086 "Return the next symbol from the current buffer, but don't consume it."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1087 (save-excursion
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1088 (nnir-imap-next-symbol)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1089
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1090 (defun nnir-imap-next-symbol (&optional count)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1091 "Return the next symbol from the current buffer, or nil if we are
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1092 at the end of the buffer. If supplied COUNT skips some symbols before
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1093 returning the one at the supplied position."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1094 (when (and (numberp count) (> count 1))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1095 (nnir-imap-next-symbol (1- count)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1096 (let ((case-fold-search t))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1097 ;; end of input stream?
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1098 (unless (nnir-imap-end-of-input)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1099 ;; No, return the next symbol from the stream.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1100 (cond
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1101 ;; negated expression -- return it and advance one char.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1102 ((looking-at "-") (forward-char 1) 'not)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1103 ;; quoted string
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1104 ((looking-at "\"") (nnir-imap-delimited-string "\""))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1105 ;; list expression -- we parse the content and return this as a list.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1106 ((looking-at "(")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1107 (nnir-imap-parse-query (nnir-imap-delimited-string ")")))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1108 ;; keyword input -- return a symbol version
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1109 ((looking-at "\\band\\b") (forward-char 3) 'and)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1110 ((looking-at "\\bor\\b") (forward-char 2) 'or)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1111 ((looking-at "\\bnot\\b") (forward-char 3) 'not)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1112 ;; Simple, boring keyword
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1113 (t (let ((start (point))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1114 (end (if (search-forward-regexp "[[:blank:]]" nil t)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1115 (prog1
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1116 (match-beginning 0)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1117 ;; unskip if we hit a non-blank terminal character.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1118 (when (string-match "[^[:blank:]]" (match-string 0))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1119 (backward-char 1)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1120 (goto-char (point-max)))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1121 (buffer-substring start end)))))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1122
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1123 (defun nnir-imap-delimited-string (delimiter)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1124 "Return a delimited string from the current buffer."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1125 (let ((start (point)) end)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1126 (forward-char 1) ; skip the first delimiter.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1127 (while (not end)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1128 (unless (search-forward delimiter nil t)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1129 (error "Unmatched delimited input with %s in query" delimiter))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1130 (let ((here (point)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1131 (unless (equal (buffer-substring (- here 2) (- here 1)) "\\")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1132 (setq end (point)))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1133 (buffer-substring (1+ start) (1- end))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1134
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1135 (defun nnir-imap-end-of-input ()
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1136 "Are we at the end of input?"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1137 (skip-chars-forward "[[:blank:]]")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1138 (looking-at "$"))
95616
49755ce71b9e Formatting fixes.
Glenn Morris <rgm@gnu.org>
parents: 95610
diff changeset
1139
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1140
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1141 ;; Swish++ interface.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1142 ;; -cc- Todo
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1143 ;; Search by
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1144 ;; - group
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1145 ;; Sort by
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1146 ;; - rank (default)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1147 ;; - article number
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1148 ;; - file size
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1149 ;; - group
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1150 (defun nnir-run-swish++ (query server &optional group)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1151 "Run QUERY against swish++.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1152 Returns a vector of (group name, file name) pairs (also vectors,
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1153 actually).
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1154
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1155 Tested with swish++ 4.7 on GNU/Linux and with swish++ 5.0b2 on
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1156 Windows NT 4.0."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1157
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1158 (when group
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1159 (error "The swish++ backend cannot search specific groups."))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1160
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1161 (save-excursion
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1162 (let ( (qstring (cdr (assq 'query query)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1163 (groupspec (cdr (assq 'group query)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1164 (prefix (nnir-read-server-parm 'nnir-swish++-remove-prefix server))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1165 artlist
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1166 ;; nnml-use-compressed-files might be any string, but probably this
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1167 ;; is sufficient. Note that we can't only use the value of
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1168 ;; nnml-use-compressed-files because old articles might have been
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1169 ;; saved with a different value.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1170 (article-pattern (if (string= server "nnmaildir:")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1171 ":[0-9]+"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1172 "^[0-9]+\\(\\.[a-z0-9]+\\)?$"))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1173 score artno dirnam filenam)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1174
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1175 (when (equal "" qstring)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1176 (error "swish++: You didn't enter anything."))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1177
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1178 (set-buffer (get-buffer-create nnir-tmp-buffer))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1179 (erase-buffer)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1180
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1181 (if groupspec
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1182 (message "Doing swish++ query %s on %s..." qstring groupspec)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1183 (message "Doing swish++ query %s..." qstring))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1184
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1185 (let* ((cp-list `( ,nnir-swish++-program
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1186 nil ; input from /dev/null
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1187 t ; output
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1188 nil ; don't redisplay
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1189 "--config-file" ,(nnir-read-server-parm 'nnir-swish++-configuration-file server)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1190 ,@(nnir-read-server-parm 'nnir-swish++-additional-switches server)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1191 ,qstring ; the query, in swish++ format
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1192 ))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1193 (exitstatus
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1194 (progn
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1195 (message "%s args: %s" nnir-swish++-program
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1196 (mapconcat 'identity (cddddr cp-list) " ")) ;; ???
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1197 (apply 'call-process cp-list))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1198 (unless (or (null exitstatus)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1199 (zerop exitstatus))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1200 (nnheader-report 'nnir "Couldn't run swish++: %s" exitstatus)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1201 ;; swish++ failure reason is in this buffer, show it if
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1202 ;; the user wants it.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1203 (when (> gnus-verbose 6)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1204 (display-buffer nnir-tmp-buffer))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1205
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1206 ;; The results are output in the format of:
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1207 ;; V 4.7 Linux
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1208 ;; rank relative-path-name file-size file-title
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1209 ;; V 5.0b2:
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1210 ;; rank relative-path-name file-size topic??
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1211 ;; where rank is an integer from 1 to 100.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1212 (goto-char (point-min))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1213 (while (re-search-forward
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1214 "\\(^[0-9]+\\) \\([^ ]+\\) [0-9]+ \\(.*\\)$" nil t)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1215 (setq score (match-string 1)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1216 filenam (match-string 2)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1217 artno (file-name-nondirectory filenam)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1218 dirnam (file-name-directory filenam))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1219
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1220 ;; don't match directories
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1221 (when (string-match article-pattern artno)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1222 (when (not (null dirnam))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1223
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1224 ;; maybe limit results to matching groups.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1225 (when (or (not groupspec)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1226 (string-match groupspec dirnam))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1227 (nnir-add-result dirnam artno score prefix server artlist)))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1228
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1229 (message "Massaging swish++ output...done")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1230
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1231 ;; Sort by score
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1232 (apply 'vector
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1233 (sort* artlist
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1234 (function (lambda (x y)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1235 (> (nnir-artitem-rsv x)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1236 (nnir-artitem-rsv y)))))))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1237
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1238 ;; Swish-E interface.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1239 (defun nnir-run-swish-e (query server &optional group)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1240 "Run given query against swish-e.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1241 Returns a vector of (group name, file name) pairs (also vectors,
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1242 actually).
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1243
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1244 Tested with swish-e-2.0.1 on Windows NT 4.0."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1245
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1246 ;; swish-e crashes with empty parameter to "-w" on commandline...
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1247 (when group
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1248 (error "The swish-e backend cannot search specific groups."))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1249
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1250 (save-excursion
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1251 (let ((qstring (cdr (assq 'query query)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1252 (prefix
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1253 (or (nnir-read-server-parm 'nnir-swish-e-remove-prefix server)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1254 (error "Missing parameter `nnir-swish-e-remove-prefix'")))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1255 artlist score artno dirnam group )
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1256
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1257 (when (equal "" qstring)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1258 (error "swish-e: You didn't enter anything."))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1259
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1260 (set-buffer (get-buffer-create nnir-tmp-buffer))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1261 (erase-buffer)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1262
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1263 (message "Doing swish-e query %s..." query)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1264 (let* ((index-files
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1265 (or (nnir-read-server-parm
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1266 'nnir-swish-e-index-files server)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1267 (error "Missing parameter `nnir-swish-e-index-files'")))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1268 (additional-switches
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1269 (nnir-read-server-parm
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1270 'nnir-swish-e-additional-switches server))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1271 (cp-list `(,nnir-swish-e-program
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1272 nil ; input from /dev/null
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1273 t ; output
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1274 nil ; don't redisplay
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1275 "-f" ,@index-files
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1276 ,@additional-switches
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1277 "-w"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1278 ,qstring ; the query, in swish-e format
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1279 ))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1280 (exitstatus
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1281 (progn
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1282 (message "%s args: %s" nnir-swish-e-program
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1283 (mapconcat 'identity (cddddr cp-list) " "))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1284 (apply 'call-process cp-list))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1285 (unless (or (null exitstatus)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1286 (zerop exitstatus))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1287 (nnheader-report 'nnir "Couldn't run swish-e: %s" exitstatus)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1288 ;; swish-e failure reason is in this buffer, show it if
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1289 ;; the user wants it.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1290 (when (> gnus-verbose 6)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1291 (display-buffer nnir-tmp-buffer))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1292
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1293 ;; The results are output in the format of:
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1294 ;; rank path-name file-title file-size
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1295 (goto-char (point-min))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1296 (while (re-search-forward
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1297 "\\(^[0-9]+\\) \\([^ ]+\\) \"\\([^\"]+\\)\" [0-9]+$" nil t)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1298 (setq score (match-string 1)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1299 artno (match-string 3)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1300 dirnam (file-name-directory (match-string 2)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1301
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1302 ;; don't match directories
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1303 (when (string-match "^[0-9]+$" artno)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1304 (when (not (null dirnam))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1305
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1306 ;; remove nnir-swish-e-remove-prefix from beginning of dirname
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1307 (when (string-match (concat "^" prefix) dirnam)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1308 (setq dirnam (replace-match "" t t dirnam)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1309
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1310 (setq dirnam (substring dirnam 0 -1))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1311 ;; eliminate all ".", "/", "\" from beginning. Always matches.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1312 (string-match "^[./\\]*\\(.*\\)$" dirnam)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1313 ;; "/" -> "."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1314 (setq group (substitute ?. ?/ (match-string 1 dirnam)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1315 ;; Windows "\\" -> "."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1316 (setq group (substitute ?. ?\\ group))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1317
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1318 (push (vector (nnir-group-full-name group server)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1319 (string-to-number artno)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1320 (string-to-number score))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1321 artlist))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1322
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1323 (message "Massaging swish-e output...done")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1324
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1325 ;; Sort by score
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1326 (apply 'vector
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1327 (sort* artlist
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1328 (function (lambda (x y)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1329 (> (nnir-artitem-rsv x)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1330 (nnir-artitem-rsv y)))))))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1331
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1332 ;; HyREX interface
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1333 (defun nnir-run-hyrex (query server &optional group)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1334 (save-excursion
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1335 (let ((artlist nil)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1336 (groupspec (cdr (assq 'group query)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1337 (qstring (cdr (assq 'query query)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1338 (prefix (nnir-read-server-parm 'nnir-hyrex-remove-prefix server))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1339 score artno dirnam)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1340 (when (and group groupspec)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1341 (error (concat "It does not make sense to use a group spec"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1342 " with process-marked groups.")))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1343 (when group
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1344 (setq groupspec (gnus-group-real-name group)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1345 (when (and group (not (equal group (nnir-group-full-name groupspec server))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1346 (message "%s vs. %s" group (nnir-group-full-name groupspec server))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1347 (error "Server with groupspec doesn't match group !"))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1348 (set-buffer (get-buffer-create nnir-tmp-buffer))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1349 (erase-buffer)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1350 (if groupspec
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1351 (message "Doing hyrex-search query %s on %s..." query groupspec)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1352 (message "Doing hyrex-search query %s..." query))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1353 (let* ((cp-list
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1354 `( ,nnir-hyrex-program
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1355 nil ; input from /dev/null
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1356 t ; output
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1357 nil ; don't redisplay
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1358 "-i",(nnir-read-server-parm 'nnir-hyrex-index-directory server) ; index directory
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1359 ,@(nnir-read-server-parm 'nnir-hyrex-additional-switches server)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1360 ,qstring ; the query, in hyrex-search format
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1361 ))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1362 (exitstatus
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1363 (progn
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1364 (message "%s args: %s" nnir-hyrex-program
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1365 (mapconcat 'identity (cddddr cp-list) " "))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1366 (apply 'call-process cp-list))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1367 (unless (or (null exitstatus)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1368 (zerop exitstatus))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1369 (nnheader-report 'nnir "Couldn't run hyrex-search: %s" exitstatus)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1370 ;; nnir-search failure reason is in this buffer, show it if
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1371 ;; the user wants it.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1372 (when (> gnus-verbose 6)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1373 (display-buffer nnir-tmp-buffer)))) ;; FIXME: Dont clear buffer !
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1374 (if groupspec
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1375 (message "Doing hyrex-search query \"%s\" on %s...done" qstring groupspec)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1376 (message "Doing hyrex-search query \"%s\"...done" qstring))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1377 (sit-for 0)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1378 ;; nnir-search returns:
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1379 ;; for nnml/nnfolder: "filename mailid weigth"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1380 ;; for nnimap: "group mailid weigth"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1381 (goto-char (point-min))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1382 (delete-non-matching-lines "^\\S + [0-9]+ [0-9]+$")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1383 ;; HyREX couldn't search directly in groups -- so filter out here.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1384 (when groupspec
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1385 (keep-lines groupspec))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1386 ;; extract data from result lines
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1387 (goto-char (point-min))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1388 (while (re-search-forward
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1389 "\\(\\S +\\) \\([0-9]+\\) \\([0-9]+\\)" nil t)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1390 (setq dirnam (match-string 1)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1391 artno (match-string 2)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1392 score (match-string 3))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1393 (when (string-match prefix dirnam)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1394 (setq dirnam (replace-match "" t t dirnam)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1395 (push (vector (nnir-group-full-name (substitute ?. ?/ dirnam) server)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1396 (string-to-number artno)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1397 (string-to-number score))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1398 artlist))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1399 (message "Massaging hyrex-search output...done.")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1400 (apply 'vector
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1401 (sort* artlist
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1402 (function (lambda (x y)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1403 (if (string-lessp (nnir-artitem-group x)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1404 (nnir-artitem-group y))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1405 t
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1406 (< (nnir-artitem-number x)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1407 (nnir-artitem-number y)))))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1408 )))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1409
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1410 ;; Namazu interface
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1411 (defun nnir-run-namazu (query server &optional group)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1412 "Run given query against Namazu. Returns a vector of (group name, file name)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1413 pairs (also vectors, actually).
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1414
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1415 Tested with Namazu 2.0.6 on a GNU/Linux system."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1416 (when group
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1417 (error "The Namazu backend cannot search specific groups"))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1418 (save-excursion
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1419 (let ((article-pattern (if (string= server "nnmaildir:")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1420 ":[0-9]+"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1421 "^[0-9]+$"))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1422 artlist
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1423 (qstring (cdr (assq 'query query)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1424 (prefix (nnir-read-server-parm 'nnir-namazu-remove-prefix server))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1425 score group article
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1426 (process-environment (copy-sequence process-environment)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1427 (setenv "LC_MESSAGES" "C")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1428 (set-buffer (get-buffer-create nnir-tmp-buffer))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1429 (erase-buffer)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1430 (let* ((cp-list
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1431 `( ,nnir-namazu-program
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1432 nil ; input from /dev/null
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1433 t ; output
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1434 nil ; don't redisplay
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1435 "-q" ; don't be verbose
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1436 "-a" ; show all matches
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1437 "-s" ; use short format
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1438 ,@(nnir-read-server-parm 'nnir-namazu-additional-switches server)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1439 ,qstring ; the query, in namazu format
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1440 ,(nnir-read-server-parm 'nnir-namazu-index-directory server) ; index directory
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1441 ))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1442 (exitstatus
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1443 (progn
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1444 (message "%s args: %s" nnir-namazu-program
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1445 (mapconcat 'identity (cddddr cp-list) " "))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1446 (apply 'call-process cp-list))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1447 (unless (or (null exitstatus)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1448 (zerop exitstatus))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1449 (nnheader-report 'nnir "Couldn't run namazu: %s" exitstatus)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1450 ;; Namazu failure reason is in this buffer, show it if
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1451 ;; the user wants it.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1452 (when (> gnus-verbose 6)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1453 (display-buffer nnir-tmp-buffer))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1454
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1455 ;; Namazu output looks something like this:
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1456 ;; 2. Re: Gnus agent expire broken (score: 55)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1457 ;; /home/henrik/Mail/mail/sent/1310 (4,138 bytes)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1458
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1459 (goto-char (point-min))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1460 (while (re-search-forward
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1461 "^\\([0-9]+\\.\\).*\\((score: \\([0-9]+\\)\\))\n\\([^ ]+\\)"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1462 nil t)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1463 (setq score (match-string 3)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1464 group (file-name-directory (match-string 4))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1465 article (file-name-nondirectory (match-string 4)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1466
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1467 ;; make sure article and group is sane
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1468 (when (and (string-match article-pattern article)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1469 (not (null group)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1470 (nnir-add-result group article score prefix server artlist)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1471
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1472 ;; sort artlist by score
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1473 (apply 'vector
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1474 (sort* artlist
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1475 (function (lambda (x y)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1476 (> (nnir-artitem-rsv x)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1477 (nnir-artitem-rsv y)))))))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1478
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1479 (defun nnir-run-find-grep (query server &optional group)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1480 "Run find and grep to obtain matching articles."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1481 (let* ((method (gnus-server-to-method server))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1482 (sym (intern
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1483 (concat (symbol-name (car method)) "-directory")))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1484 (directory (cadr (assoc sym (cddr method))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1485 (regexp (cdr (assoc 'query query)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1486 (grep-options (cdr (assoc 'grep-options query)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1487 artlist)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1488 (unless directory
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1489 (error "No directory found in method specification of server %s"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1490 server))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1491 (message "Searching %s using find-grep..." (or group server))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1492 (save-window-excursion
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1493 (set-buffer (get-buffer-create nnir-tmp-buffer))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1494 (erase-buffer)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1495 (if (> gnus-verbose 6)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1496 (pop-to-buffer (current-buffer)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1497 (cd directory) ; Using relative paths simplifies postprocessing.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1498 (let ((group
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1499 (if (not group)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1500 "."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1501 ;; Try accessing the group literally as well as
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1502 ;; interpreting dots as directory separators so the
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1503 ;; engine works with plain nnml as well as the Gnus
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1504 ;; Cache.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1505 (find-if 'file-directory-p
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1506 (let ((group (gnus-group-real-name group)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1507 (list group (gnus-replace-in-string group "\\." "/" t)))))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1508 (unless group
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1509 (error "Cannot locate directory for group"))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1510 (save-excursion
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1511 (apply
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1512 'call-process "find" nil t
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1513 "find" group "-type" "f" "-name" "[0-9]*" "-exec"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1514 "grep"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1515 `("-l" ,@(and grep-options (split-string grep-options "\\s-" t))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1516 "-e" ,regexp "{}" "+"))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1517
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1518 ;; Translate relative paths to group names.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1519 (while (not (eobp))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1520 (let* ((path (split-string
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1521 (buffer-substring (point) (line-end-position)) "/" t))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1522 (art (string-to-number (car (last path)))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1523 (while (string= "." (car path))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1524 (setq path (cdr path)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1525 (let ((group (mapconcat 'identity (subseq path 0 -1) ".")))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1526 (push (vector (nnir-group-full-name group server) art 0)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1527 artlist))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1528 (forward-line 1)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1529 (message "Searching %s using find-grep...done" (or group server))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1530 artlist)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1531
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1532 ;;; Util Code:
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1533
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1534 (defun nnir-read-parms (query)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1535 "Reads additional search parameters according to `nnir-engines'."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1536 (let ((parmspec (caddr (assoc nnir-search-engine nnir-engines))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1537 (cons (cons 'query query)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1538 (mapcar 'nnir-read-parm parmspec))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1539
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1540 (defun nnir-read-parm (parmspec)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1541 "Reads a single search parameter.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1542 `parmspec' is a cons cell, the car is a symbol, the cdr is a prompt."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1543 (let ((sym (car parmspec))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1544 (prompt (cdr parmspec)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1545 (if (listp prompt)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1546 (let* ((result (apply 'completing-read prompt))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1547 (mapping (or (assoc result nnir-imap-search-arguments)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1548 (assoc nil nnir-imap-search-arguments))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1549 (cons sym (format (cdr mapping) result)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1550 (cons sym (read-string prompt)))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1551
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1552 (defun nnir-run-query (query)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1553 "Invoke appropriate search engine function (see `nnir-engines').
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1554 If some groups were process-marked, run the query for each of the groups
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1555 and concat the results."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1556 (let ((q (car (read-from-string query))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1557 (if gnus-group-marked
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1558 (apply 'vconcat
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1559 (mapcar (lambda (x)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1560 (let ((server (nnir-group-server x))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1561 search-func)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1562 (setq search-func (cadr
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1563 (assoc
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1564 (nnir-read-server-parm 'nnir-search-engine server) nnir-engines)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1565 (if search-func
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1566 (funcall search-func q server x)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1567 nil)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1568 gnus-group-marked)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1569 )
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1570 (apply 'vconcat
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1571 (mapcar (lambda (x)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1572 (if (and (equal (cadr x) 'ok) (not (equal (cadar x) "-ephemeral")))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1573 (let ((server (format "%s:%s" (caar x) (cadar x)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1574 search-func)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1575 (setq search-func (cadr
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1576 (assoc
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1577 (nnir-read-server-parm 'nnir-search-engine server) nnir-engines)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1578 (if search-func
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1579 (funcall search-func q server nil)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1580 nil))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1581 nil))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1582 gnus-opened-servers)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1583 ))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1584 ))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1585
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1586 (defun nnir-read-server-parm (key server)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1587 "Returns the parameter value of for the given server, where server is of
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1588 form 'backend:name'."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1589 (let ((method (gnus-server-to-method server)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1590 (cond ((and method (assq key (cddr method)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1591 (nth 1 (assq key (cddr method))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1592 ((and nnir-mail-backend
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1593 (gnus-server-equal method nnir-mail-backend))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1594 (symbol-value key))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1595 (t nil))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1596 ;; (if method
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1597 ;; (if (assq key (cddr method))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1598 ;; (nth 1 (assq key (cddr method)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1599 ;; (symbol-value key))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1600 ;; (symbol-value key))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1601 ;; ))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1602
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1603 (defun nnir-group-full-name (shortname server)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1604 "For the given group name, return a full Gnus group name.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1605 The Gnus backend/server information is added."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1606 (gnus-group-prefixed-name shortname (gnus-server-to-method server)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1607
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1608 (defun nnir-possibly-change-server (server)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1609 (unless (and server (nnir-server-opened server))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1610 (nnir-open-server server)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1611
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1612
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1613 ;; Data type article list.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1614
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1615 (defun nnir-artlist-length (artlist)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1616 "Returns number of articles in artlist."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1617 (length artlist))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1618
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1619 (defun nnir-artlist-article (artlist n)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1620 "Returns from ARTLIST the Nth artitem (counting starting at 1)."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1621 (elt artlist (1- n)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1622
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1623 (defun nnir-artitem-group (artitem)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1624 "Returns the group from the ARTITEM."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1625 (elt artitem 0))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1626
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1627 (defun nnir-artlist-artitem-group (artlist n)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1628 "Returns from ARTLIST the group of the Nth artitem (counting from 1)."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1629 (nnir-artitem-group (nnir-artlist-article artlist n)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1630
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1631 (defun nnir-artitem-number (artitem)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1632 "Returns the number from the ARTITEM."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1633 (elt artitem 1))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1634
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1635 (defun nnir-artlist-artitem-number (artlist n)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1636 "Returns from ARTLIST the number of the Nth artitem (counting from 1)."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1637 (nnir-artitem-number (nnir-artlist-article artlist n)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1638
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1639 (defun nnir-artitem-rsv (artitem)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1640 "Returns the Retrieval Status Value (RSV, score) from the ARTITEM."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1641 (elt artitem 2))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1642
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1643 (defun nnir-artlist-artitem-rsv (artlist n)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1644 "Returns from ARTLIST the Retrieval Status Value of the Nth artitem
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1645 \(counting from 1)."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1646 (nnir-artitem-rsv (nnir-artlist-article artlist n)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1647
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1648 ;; unused?
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1649 (defun nnir-artlist-groups (artlist)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1650 "Returns a list of all groups in the given ARTLIST."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1651 (let ((res nil)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1652 (with-dups nil))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1653 ;; from each artitem, extract group component
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1654 (setq with-dups (mapcar 'nnir-artitem-group artlist))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1655 ;; remove duplicates from above
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1656 (mapc (function (lambda (x) (add-to-list 'res x)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1657 with-dups)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1658 res))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1659
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1660
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1661 ;; The end.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1662 (provide 'nnir)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1663
95616
49755ce71b9e Formatting fixes.
Glenn Morris <rgm@gnu.org>
parents: 95610
diff changeset
1664 ;; arch-tag: 9b3fecf8-4397-4bbb-bf3c-6ac3cbbc6664
49755ce71b9e Formatting fixes.
Glenn Morris <rgm@gnu.org>
parents: 95610
diff changeset
1665 ;;; nnir.el ends here