annotate lisp/gnus/nnir.el @ 100111:70331b8d068a

(c-tab-always-indent, c-insert-tab-function): Doc fix. (Bug#1368)
author Glenn Morris <rgm@gnu.org>
date Tue, 02 Dec 2008 03:32:05 +0000
parents 4bbbc2594f0b
children a9dc0e7c3f2b
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
95830
4bbbc2594f0b Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95616
diff changeset
661 (eval-when-compile
4bbbc2594f0b Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95616
diff changeset
662 (when (featurep 'xemacs)
4bbbc2594f0b Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95616
diff changeset
663 ;; The `kbd' macro requires that the `read-kbd-macro' macro is available.
4bbbc2594f0b Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95616
diff changeset
664 (require 'edmacro)))
4bbbc2594f0b Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95616
diff changeset
665
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
666 (defun nnir-group-mode-hook ()
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
667 (define-key gnus-group-mode-map (kbd "G G")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
668 'gnus-group-make-nnir-group))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
669 (add-hook 'gnus-group-mode-hook 'nnir-group-mode-hook)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
670
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
671 ;; 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
672 ;; gnus-group-server instead works for me. -- Justus Piater
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
673 (defmacro nnir-group-server (group)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
674 "Return the server for a newsgroup GROUP.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
675 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
676 `gnus-group-real-prefix' and `gnus-group-real-name'."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
677 `(let ((gname ,group))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
678 (if (string-match "^\\([^:]+\\):" gname)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
679 (progn
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
680 (setq gname (match-string 1 gname))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
681 (if (string-match "^\\([^+]+\\)\\+\\(.+\\)$" gname)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
682 (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
683 (concat gname ":")))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
684 (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
685
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
686 ;; Summary mode commands.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
687
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
688 (defun gnus-summary-nnir-goto-thread ()
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
689 "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
690 and show thread that contains this article."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
691 (interactive)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
692 (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
693 (error "Can't execute this command unless in nnir group."))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
694 (let* ((cur (gnus-summary-article-number))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
695 (group (nnir-artlist-artitem-group nnir-artlist cur))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
696 (backend-number (nnir-artlist-artitem-number nnir-artlist cur))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
697 server backend-group)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
698 (setq server (nnir-group-server group))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
699 (setq backend-group (gnus-group-real-name group))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
700 (gnus-group-read-ephemeral-group
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
701 backend-group
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
702 (gnus-server-to-method server)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
703 t ; activate
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
704 (cons (current-buffer)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
705 'summary) ; window config
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
706 nil
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
707 (list backend-number))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
708 (gnus-summary-limit (list backend-number))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
709 (gnus-summary-refer-thread)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
710
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
711 (if (fboundp 'eval-after-load)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
712 (eval-after-load "gnus-sum"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
713 '(define-key gnus-summary-goto-map
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
714 "T" 'gnus-summary-nnir-goto-thread))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
715 (add-hook 'gnus-summary-mode-hook
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
716 (function (lambda ()
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
717 (define-key gnus-summary-goto-map
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
718 "T" 'gnus-summary-nnir-goto-thread)))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
719
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
720
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
721
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
722 ;; Gnus backend interface functions.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
723
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
724 (deffoo nnir-open-server (server &optional definitions)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
725 ;; Just set the server variables appropriately.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
726 (nnoo-change-server 'nnir server definitions))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
727
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
728 (deffoo nnir-request-group (group &optional server fast)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
729 "GROUP is the query string."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
730 (nnir-possibly-change-server server)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
731 ;; Check for cache and return that if appropriate.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
732 (if (and (equal group nnir-current-query)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
733 (equal gnus-group-marked nnir-current-group-marked)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
734 (or (null server)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
735 (equal server nnir-current-server)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
736 nnir-artlist
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
737 ;; Cache miss.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
738 (setq nnir-artlist (nnir-run-query group)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
739 (save-excursion
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
740 (set-buffer nntp-server-buffer)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
741 (if (zerop (length nnir-artlist))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
742 (progn
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
743 (setq nnir-current-query nil
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
744 nnir-current-server nil
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
745 nnir-current-group-marked nil
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
746 nnir-artlist nil)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
747 (nnheader-report 'nnir "Search produced empty results."))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
748 ;; Remember data for cache.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
749 (setq nnir-current-query group)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
750 (when server (setq nnir-current-server server))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
751 (setq nnir-current-group-marked gnus-group-marked)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
752 (nnheader-insert "211 %d %d %d %s\n"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
753 (nnir-artlist-length nnir-artlist) ; total #
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
754 1 ; first #
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
755 (nnir-artlist-length nnir-artlist) ; last #
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
756 group)))) ; group name
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
757
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
758 (deffoo nnir-retrieve-headers (articles &optional group server fetch-old)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
759 (save-excursion
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
760 (let ((artlist (copy-sequence articles))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
761 art artitem artgroup artno artrsv artfullgroup
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
762 novitem novdata foo server)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
763 (while (not (null artlist))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
764 (setq art (car artlist))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
765 (or (numberp art)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
766 (nnheader-report
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
767 'nnir
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
768 "nnir-retrieve-headers doesn't grok message ids: %s"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
769 art))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
770 (setq artitem (nnir-artlist-article nnir-artlist art))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
771 (setq artrsv (nnir-artitem-rsv artitem))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
772 (setq artfullgroup (nnir-artitem-group artitem))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
773 (setq artno (nnir-artitem-number artitem))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
774 (setq artgroup (gnus-group-real-name artfullgroup))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
775 (setq server (nnir-group-server artfullgroup))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
776 ;; retrieve NOV or HEAD data for this article, transform into
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
777 ;; NOV data and prepend to `novdata'
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
778 (set-buffer nntp-server-buffer)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
779 (nnir-possibly-change-server server)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
780 (let ((gnus-override-method
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
781 (gnus-server-to-method server)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
782 (case (setq foo (gnus-retrieve-headers (list artno) artfullgroup nil))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
783 (nov
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
784 (goto-char (point-min))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
785 (setq novitem (nnheader-parse-nov))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
786 (unless novitem
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
787 (pop-to-buffer nntp-server-buffer)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
788 (error
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
789 "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
790 artno artfullgroup)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
791 (headers
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
792 (goto-char (point-min))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
793 (setq novitem (nnheader-parse-head))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
794 (unless novitem
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
795 (pop-to-buffer nntp-server-buffer)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
796 (error
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
797 "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
798 artno artfullgroup)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
799 (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
800 foo artno artfullgroup))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
801 ;; replace article number in original group with article number
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
802 ;; in nnir group
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
803 (mail-header-set-number novitem art)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
804 (mail-header-set-from novitem
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
805 (mail-header-from novitem))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
806 (mail-header-set-subject
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
807 novitem
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
808 (format "[%d: %s/%d] %s"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
809 artrsv artgroup artno
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
810 (mail-header-subject novitem)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
811 ;;-(mail-header-set-extra novitem nil)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
812 (push novitem novdata)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
813 (setq artlist (cdr artlist)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
814 (setq novdata (nreverse novdata))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
815 (set-buffer nntp-server-buffer) (erase-buffer)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
816 (mapc 'nnheader-insert-nov novdata)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
817 'nov)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
818
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
819 (deffoo nnir-request-article (article
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
820 &optional group server to-buffer)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
821 (if (stringp article)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
822 (nnheader-report
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
823 'nnir
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
824 "nnir-retrieve-headers doesn't grok message ids: %s"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
825 article)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
826 (save-excursion
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
827 (let* ((artitem (nnir-artlist-article nnir-artlist
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
828 article))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
829 (artfullgroup (nnir-artitem-group artitem))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
830 (artno (nnir-artitem-number artitem))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
831 ;; Bug?
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
832 ;; 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
833 ;; 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
834 ;; line below must then be updated, too.)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
835 (nntp-server-buffer (or to-buffer nntp-server-buffer)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
836 (set-buffer nntp-server-buffer)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
837 (erase-buffer)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
838 (message "Requesting article %d from group %s"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
839 artno artfullgroup)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
840 (gnus-request-article artno artfullgroup nntp-server-buffer)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
841 (cons artfullgroup artno)))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
842
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
843
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
844 (nnoo-define-skeleton nnir)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
845
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
846
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
847 (defmacro nnir-add-result (dirnam artno score prefix server artlist)
95616
49755ce71b9e Formatting fixes.
Glenn Morris <rgm@gnu.org>
parents: 95610
diff changeset
848 "Ask `nnir-compose-result' to construct a result vector,
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
849 and if it is non-nil, add it to artlist."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
850 `(let ((result (nnir-compose-result ,dirnam ,artno ,score ,prefix ,server)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
851 (when (not (null result))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
852 (push result ,artlist))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
853
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
854 (autoload 'nnmaildir-base-name-to-article-number "nnmaildir")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
855
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
856 ;; Helper function currently used by the Swish++ and Namazu backends;
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
857 ;; perhaps useful for other backends as well
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
858 (defun nnir-compose-result (dirnam article score prefix server)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
859 "Extract the group from dirnam, and create a result vector
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
860 ready to be added to the list of search results."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
861
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
862 ;; remove nnir-*-remove-prefix from beginning of dirnam filename
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
863 (when (string-match (concat "^" prefix) dirnam)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
864 (setq dirnam (replace-match "" t t dirnam)))
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 (when (file-readable-p (concat prefix dirnam article))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
867 ;; remove trailing slash and, for nnmaildir, cur/new/tmp
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
868 (setq dirnam
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
869 (substring dirnam 0 (if (string= server "nnmaildir:") -5 -1)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
870
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
871 ;; Set group to dirnam without any leading dots or slashes,
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
872 ;; and with all subsequent slashes replaced by dots
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
873 (let ((group (gnus-replace-in-string
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
874 (gnus-replace-in-string dirnam "^[./\\]" "" t)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
875 "[/\\]" "." t)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
876
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
877 (vector (nnir-group-full-name group server)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
878 (if (string= server "nnmaildir:")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
879 (nnmaildir-base-name-to-article-number
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
880 (substring article 0 (string-match ":" article))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
881 group nil)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
882 (string-to-number article))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
883 (string-to-number score)))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
884
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
885 ;;; Search Engine Interfaces:
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
886
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
887 ;; freeWAIS-sf interface.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
888 (defun nnir-run-waissearch (query server &optional group)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
889 "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
890 pairs (also vectors, actually)."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
891 (when group
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
892 (error "The freeWAIS-sf backend cannot search specific groups."))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
893 (save-excursion
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
894 (let ((qstring (cdr (assq 'query query)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
895 (prefix (nnir-read-server-parm 'nnir-wais-remove-prefix server))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
896 artlist score artno dirnam)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
897 (set-buffer (get-buffer-create nnir-tmp-buffer))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
898 (erase-buffer)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
899 (message "Doing WAIS query %s..." query)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
900 (call-process nnir-wais-program
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
901 nil ; input from /dev/null
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
902 t ; output to current buffer
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
903 nil ; don't redisplay
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
904 "-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
905 qstring)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
906 (message "Massaging waissearch output...")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
907 ;; remove superfluous lines
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
908 (keep-lines "Score:")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
909 ;; extract data from result lines
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
910 (goto-char (point-min))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
911 (while (re-search-forward
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
912 "Score: +\\([0-9]+\\).*'\\([0-9]+\\) +\\([^']+\\)/'" nil t)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
913 (setq score (match-string 1)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
914 artno (match-string 2)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
915 dirnam (match-string 3))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
916 (unless (string-match prefix dirnam)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
917 (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
918 dirnam prefix))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
919 (setq group (substitute ?. ?/ (replace-match "" t t dirnam)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
920 (push (vector (nnir-group-full-name group server)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
921 (string-to-number artno)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
922 (string-to-number score))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
923 artlist))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
924 (message "Massaging waissearch output...done")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
925 (apply 'vector
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
926 (sort* artlist
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
927 (function (lambda (x y)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
928 (> (nnir-artitem-rsv x)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
929 (nnir-artitem-rsv y)))))))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
930
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
931 ;; IMAP interface.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
932 ;; todo:
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
933 ;; nnir invokes this two (2) times???!
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
934 ;; 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
935 ;; 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
936 ;; send queries as literals
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
937 ;; handle errors
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
938
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
939 (autoload 'nnimap-open-server "nnimap")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
940 (defvar nnimap-server-buffer) ;; nnimap.el
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
941 (autoload 'imap-mailbox-select "imap")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
942 (autoload 'imap-search "imap")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
943 (autoload 'imap-quote-specials "imap")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
944
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
945 (defun nnir-run-imap (query srv &optional group-option)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
946 "Run a search against an IMAP back-end server.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
947 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
948 details on the language and supported extensions"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
949 (save-excursion
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
950 (let ((qstring (cdr (assq 'query query)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
951 (server (cadr (gnus-server-to-method srv)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
952 (group (or group-option (gnus-group-group-name)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
953 (defs (caddr (gnus-server-to-method srv)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
954 (criteria (or (cdr (assq 'criteria query))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
955 nnir-imap-search-field))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
956 artlist buf)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
957 (message "Opening server %s" server)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
958 (condition-case ()
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
959 (when (nnimap-open-server server defs) ;; xxx
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
960 (setq buf nnimap-server-buffer) ;; xxx
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
961 (message "Searching %s..." group)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
962 (let ((arts 0)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
963 (mbx (gnus-group-real-name group)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
964 (when (imap-mailbox-select mbx nil buf)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
965 (mapc
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
966 (lambda (artnum)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
967 (push (vector group artnum 1) artlist)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
968 (setq arts (1+ arts)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
969 (imap-search (nnir-imap-make-query criteria qstring) buf))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
970 (message "Searching %s... %d matches" mbx arts)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
971 (message "Searching %s...done" group))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
972 (quit nil))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
973 (reverse artlist))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
974
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
975 (defun nnir-imap-make-query (criteria qstring)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
976 "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
977 expression, returning the string query to make.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
978
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
979 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
980 to an arbitrary query string to the end user.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
981
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
982 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
983 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
984
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
985 Automatic \"and\" queries
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
986 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
987 expression intended to match all components.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
988
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
989 Phrase searches
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
990 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
991 literal string.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
992
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
993 Negative terms
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
994 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
995
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
996 \"OR\" queries
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
997 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
998 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
999
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1000 In future the following will be added to the language:
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1001 * support for date matches
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1002 * support for location of text matching within the query
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1003 * from/to/etc headers
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1004 * additional search terms
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1005 * flag based searching
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1006 * anything else that the RFC supports, basically."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1007 ;; 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
1008 (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
1009
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1010
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1011 (defun nnir-imap-query-to-imap (criteria query)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1012 "Turn a s-expression format query into IMAP."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1013 (mapconcat
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1014 ;; Turn the expressions into IMAP text
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1015 (lambda (item)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1016 (nnir-imap-expr-to-imap criteria item))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1017 ;; The query, already in s-expr format.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1018 query
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1019 ;; Append a space between each expression
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1020 " "))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1021
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1022
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1023 (defun nnir-imap-expr-to-imap (criteria expr)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1024 "Convert EXPR into an IMAP search expression on CRITERIA"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1025 ;; What sort of expression is this, eh?
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1026 (cond
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1027 ;; Simple string term
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1028 ((stringp expr)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1029 (format "%s \"%s\"" criteria (imap-quote-specials expr)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1030 ;; Trivial term: and
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1031 ((eq expr 'and) nil)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1032 ;; Composite term: or expression
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1033 ((eq (car-safe expr) 'or)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1034 (format "OR %s %s"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1035 (nnir-imap-expr-to-imap criteria (second expr))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1036 (nnir-imap-expr-to-imap criteria (third expr))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1037 ;; Composite term: just the fax, mam
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1038 ((eq (car-safe expr) 'not)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1039 (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
1040 ;; Composite term: just expand it all.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1041 ((and (not (null expr)) (listp expr))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1042 (format "(%s)" (nnir-imap-query-to-imap criteria expr)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1043 ;; Complex value, give up for now.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1044 (t (error "Unhandled input: %S" expr))))
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
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1047 (defun nnir-imap-parse-query (string)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1048 "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
1049 query language as defined in `nnir-imap-make-query'.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1050
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1051 This involves turning individual tokens into higher level terms
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1052 that the search language can then understand and use."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1053 (with-temp-buffer
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1054 ;; Set up the parsing environment.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1055 (insert string)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1056 (goto-char (point-min))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1057 ;; Now, collect the output terms and return them.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1058 (let (out)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1059 (while (not (nnir-imap-end-of-input))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1060 (push (nnir-imap-next-expr) out))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1061 (reverse out))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1062
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1063
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1064 (defun nnir-imap-next-expr (&optional count)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1065 "Return the next expression from the current buffer."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1066 (let ((term (nnir-imap-next-term count))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1067 (next (nnir-imap-peek-symbol)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1068 ;; Are we looking at an 'or' expression?
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1069 (cond
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1070 ;; Handle 'expr or expr'
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1071 ((eq next 'or)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1072 (list 'or term (nnir-imap-next-expr 2)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1073 ;; Anything else
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1074 (t term))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1075
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1076
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1077 (defun nnir-imap-next-term (&optional count)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1078 "Return the next TERM from the current buffer."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1079 (let ((term (nnir-imap-next-symbol count)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1080 ;; What sort of term is this?
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1081 (cond
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1082 ;; and -- just ignore it
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1083 ((eq term 'and) 'and)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1084 ;; negated term
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1085 ((eq term 'not) (list 'not (nnir-imap-next-expr)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1086 ;; generic term
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1087 (t term))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1088
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-peek-symbol ()
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1091 "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
1092 (save-excursion
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1093 (nnir-imap-next-symbol)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1094
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1095 (defun nnir-imap-next-symbol (&optional count)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1096 "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
1097 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
1098 returning the one at the supplied position."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1099 (when (and (numberp count) (> count 1))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1100 (nnir-imap-next-symbol (1- count)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1101 (let ((case-fold-search t))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1102 ;; end of input stream?
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1103 (unless (nnir-imap-end-of-input)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1104 ;; No, return the next symbol from the stream.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1105 (cond
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1106 ;; negated expression -- return it and advance one char.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1107 ((looking-at "-") (forward-char 1) 'not)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1108 ;; quoted string
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1109 ((looking-at "\"") (nnir-imap-delimited-string "\""))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1110 ;; 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
1111 ((looking-at "(")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1112 (nnir-imap-parse-query (nnir-imap-delimited-string ")")))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1113 ;; keyword input -- return a symbol version
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1114 ((looking-at "\\band\\b") (forward-char 3) 'and)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1115 ((looking-at "\\bor\\b") (forward-char 2) 'or)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1116 ((looking-at "\\bnot\\b") (forward-char 3) 'not)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1117 ;; Simple, boring keyword
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1118 (t (let ((start (point))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1119 (end (if (search-forward-regexp "[[:blank:]]" nil t)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1120 (prog1
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1121 (match-beginning 0)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1122 ;; unskip if we hit a non-blank terminal character.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1123 (when (string-match "[^[:blank:]]" (match-string 0))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1124 (backward-char 1)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1125 (goto-char (point-max)))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1126 (buffer-substring start end)))))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1127
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1128 (defun nnir-imap-delimited-string (delimiter)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1129 "Return a delimited string from the current buffer."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1130 (let ((start (point)) end)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1131 (forward-char 1) ; skip the first delimiter.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1132 (while (not end)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1133 (unless (search-forward delimiter nil t)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1134 (error "Unmatched delimited input with %s in query" delimiter))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1135 (let ((here (point)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1136 (unless (equal (buffer-substring (- here 2) (- here 1)) "\\")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1137 (setq end (point)))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1138 (buffer-substring (1+ start) (1- end))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1139
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1140 (defun nnir-imap-end-of-input ()
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1141 "Are we at the end of input?"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1142 (skip-chars-forward "[[:blank:]]")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1143 (looking-at "$"))
95616
49755ce71b9e Formatting fixes.
Glenn Morris <rgm@gnu.org>
parents: 95610
diff changeset
1144
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1145
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1146 ;; Swish++ interface.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1147 ;; -cc- Todo
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1148 ;; Search by
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 ;; Sort by
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1151 ;; - rank (default)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1152 ;; - article number
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1153 ;; - file size
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1154 ;; - group
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1155 (defun nnir-run-swish++ (query server &optional group)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1156 "Run QUERY against swish++.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1157 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
1158 actually).
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1159
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1160 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
1161 Windows NT 4.0."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1162
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1163 (when group
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1164 (error "The swish++ backend cannot search specific groups."))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1165
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1166 (save-excursion
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1167 (let ( (qstring (cdr (assq 'query query)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1168 (groupspec (cdr (assq 'group query)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1169 (prefix (nnir-read-server-parm 'nnir-swish++-remove-prefix server))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1170 artlist
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1171 ;; 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
1172 ;; 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
1173 ;; nnml-use-compressed-files because old articles might have been
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1174 ;; saved with a different value.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1175 (article-pattern (if (string= server "nnmaildir:")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1176 ":[0-9]+"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1177 "^[0-9]+\\(\\.[a-z0-9]+\\)?$"))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1178 score artno dirnam filenam)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1179
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1180 (when (equal "" qstring)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1181 (error "swish++: You didn't enter anything."))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1182
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1183 (set-buffer (get-buffer-create nnir-tmp-buffer))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1184 (erase-buffer)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1185
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1186 (if groupspec
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1187 (message "Doing swish++ query %s on %s..." qstring groupspec)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1188 (message "Doing swish++ query %s..." qstring))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1189
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1190 (let* ((cp-list `( ,nnir-swish++-program
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1191 nil ; input from /dev/null
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1192 t ; output
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1193 nil ; don't redisplay
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1194 "--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
1195 ,@(nnir-read-server-parm 'nnir-swish++-additional-switches server)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1196 ,qstring ; the query, in swish++ format
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1197 ))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1198 (exitstatus
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1199 (progn
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1200 (message "%s args: %s" nnir-swish++-program
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1201 (mapconcat 'identity (cddddr cp-list) " ")) ;; ???
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1202 (apply 'call-process cp-list))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1203 (unless (or (null exitstatus)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1204 (zerop exitstatus))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1205 (nnheader-report 'nnir "Couldn't run swish++: %s" exitstatus)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1206 ;; swish++ failure reason is in this buffer, show it if
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1207 ;; the user wants it.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1208 (when (> gnus-verbose 6)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1209 (display-buffer nnir-tmp-buffer))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1210
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1211 ;; The results are output in the format of:
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1212 ;; V 4.7 Linux
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1213 ;; rank relative-path-name file-size file-title
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1214 ;; V 5.0b2:
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1215 ;; rank relative-path-name file-size topic??
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1216 ;; where rank is an integer from 1 to 100.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1217 (goto-char (point-min))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1218 (while (re-search-forward
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1219 "\\(^[0-9]+\\) \\([^ ]+\\) [0-9]+ \\(.*\\)$" nil t)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1220 (setq score (match-string 1)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1221 filenam (match-string 2)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1222 artno (file-name-nondirectory filenam)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1223 dirnam (file-name-directory filenam))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1224
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1225 ;; don't match directories
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1226 (when (string-match article-pattern artno)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1227 (when (not (null dirnam))
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 ;; maybe limit results to matching groups.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1230 (when (or (not groupspec)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1231 (string-match groupspec dirnam))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1232 (nnir-add-result dirnam artno score prefix server artlist)))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1233
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1234 (message "Massaging swish++ output...done")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1235
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1236 ;; Sort by score
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1237 (apply 'vector
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1238 (sort* artlist
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1239 (function (lambda (x y)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1240 (> (nnir-artitem-rsv x)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1241 (nnir-artitem-rsv y)))))))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1242
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1243 ;; Swish-E interface.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1244 (defun nnir-run-swish-e (query server &optional group)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1245 "Run given query against swish-e.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1246 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
1247 actually).
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1248
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1249 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
1250
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1251 ;; swish-e crashes with empty parameter to "-w" on commandline...
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1252 (when group
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1253 (error "The swish-e backend cannot search specific groups."))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1254
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1255 (save-excursion
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1256 (let ((qstring (cdr (assq 'query query)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1257 (prefix
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1258 (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
1259 (error "Missing parameter `nnir-swish-e-remove-prefix'")))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1260 artlist score artno dirnam group )
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1261
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1262 (when (equal "" qstring)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1263 (error "swish-e: You didn't enter anything."))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1264
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1265 (set-buffer (get-buffer-create nnir-tmp-buffer))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1266 (erase-buffer)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1267
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1268 (message "Doing swish-e query %s..." query)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1269 (let* ((index-files
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1270 (or (nnir-read-server-parm
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1271 'nnir-swish-e-index-files server)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1272 (error "Missing parameter `nnir-swish-e-index-files'")))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1273 (additional-switches
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1274 (nnir-read-server-parm
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1275 'nnir-swish-e-additional-switches server))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1276 (cp-list `(,nnir-swish-e-program
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1277 nil ; input from /dev/null
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1278 t ; output
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1279 nil ; don't redisplay
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1280 "-f" ,@index-files
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1281 ,@additional-switches
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1282 "-w"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1283 ,qstring ; the query, in swish-e format
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1284 ))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1285 (exitstatus
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1286 (progn
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1287 (message "%s args: %s" nnir-swish-e-program
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1288 (mapconcat 'identity (cddddr cp-list) " "))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1289 (apply 'call-process cp-list))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1290 (unless (or (null exitstatus)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1291 (zerop exitstatus))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1292 (nnheader-report 'nnir "Couldn't run swish-e: %s" exitstatus)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1293 ;; 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
1294 ;; the user wants it.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1295 (when (> gnus-verbose 6)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1296 (display-buffer nnir-tmp-buffer))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1297
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1298 ;; The results are output in the format of:
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1299 ;; rank path-name file-title file-size
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1300 (goto-char (point-min))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1301 (while (re-search-forward
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1302 "\\(^[0-9]+\\) \\([^ ]+\\) \"\\([^\"]+\\)\" [0-9]+$" nil t)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1303 (setq score (match-string 1)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1304 artno (match-string 3)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1305 dirnam (file-name-directory (match-string 2)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1306
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1307 ;; don't match directories
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1308 (when (string-match "^[0-9]+$" artno)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1309 (when (not (null dirnam))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1310
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1311 ;; remove nnir-swish-e-remove-prefix from beginning of dirname
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1312 (when (string-match (concat "^" prefix) dirnam)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1313 (setq dirnam (replace-match "" t t dirnam)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1314
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1315 (setq dirnam (substring dirnam 0 -1))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1316 ;; eliminate all ".", "/", "\" from beginning. Always matches.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1317 (string-match "^[./\\]*\\(.*\\)$" dirnam)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1318 ;; "/" -> "."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1319 (setq group (substitute ?. ?/ (match-string 1 dirnam)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1320 ;; Windows "\\" -> "."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1321 (setq group (substitute ?. ?\\ group))
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 (push (vector (nnir-group-full-name group server)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1324 (string-to-number artno)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1325 (string-to-number score))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1326 artlist))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1327
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1328 (message "Massaging swish-e output...done")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1329
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1330 ;; Sort by score
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1331 (apply 'vector
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1332 (sort* artlist
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1333 (function (lambda (x y)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1334 (> (nnir-artitem-rsv x)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1335 (nnir-artitem-rsv y)))))))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1336
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1337 ;; HyREX interface
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1338 (defun nnir-run-hyrex (query server &optional group)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1339 (save-excursion
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1340 (let ((artlist nil)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1341 (groupspec (cdr (assq 'group query)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1342 (qstring (cdr (assq 'query query)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1343 (prefix (nnir-read-server-parm 'nnir-hyrex-remove-prefix server))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1344 score artno dirnam)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1345 (when (and group groupspec)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1346 (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
1347 " with process-marked groups.")))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1348 (when group
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1349 (setq groupspec (gnus-group-real-name group)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1350 (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
1351 (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
1352 (error "Server with groupspec doesn't match group !"))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1353 (set-buffer (get-buffer-create nnir-tmp-buffer))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1354 (erase-buffer)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1355 (if groupspec
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1356 (message "Doing hyrex-search query %s on %s..." query groupspec)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1357 (message "Doing hyrex-search query %s..." query))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1358 (let* ((cp-list
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1359 `( ,nnir-hyrex-program
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1360 nil ; input from /dev/null
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1361 t ; output
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1362 nil ; don't redisplay
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1363 "-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
1364 ,@(nnir-read-server-parm 'nnir-hyrex-additional-switches server)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1365 ,qstring ; the query, in hyrex-search format
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1366 ))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1367 (exitstatus
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1368 (progn
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1369 (message "%s args: %s" nnir-hyrex-program
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1370 (mapconcat 'identity (cddddr cp-list) " "))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1371 (apply 'call-process cp-list))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1372 (unless (or (null exitstatus)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1373 (zerop exitstatus))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1374 (nnheader-report 'nnir "Couldn't run hyrex-search: %s" exitstatus)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1375 ;; 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
1376 ;; the user wants it.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1377 (when (> gnus-verbose 6)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1378 (display-buffer nnir-tmp-buffer)))) ;; FIXME: Dont clear buffer !
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1379 (if groupspec
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1380 (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
1381 (message "Doing hyrex-search query \"%s\"...done" qstring))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1382 (sit-for 0)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1383 ;; nnir-search returns:
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1384 ;; for nnml/nnfolder: "filename mailid weigth"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1385 ;; for nnimap: "group mailid weigth"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1386 (goto-char (point-min))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1387 (delete-non-matching-lines "^\\S + [0-9]+ [0-9]+$")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1388 ;; 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
1389 (when groupspec
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1390 (keep-lines groupspec))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1391 ;; extract data from result lines
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1392 (goto-char (point-min))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1393 (while (re-search-forward
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1394 "\\(\\S +\\) \\([0-9]+\\) \\([0-9]+\\)" nil t)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1395 (setq dirnam (match-string 1)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1396 artno (match-string 2)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1397 score (match-string 3))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1398 (when (string-match prefix dirnam)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1399 (setq dirnam (replace-match "" t t dirnam)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1400 (push (vector (nnir-group-full-name (substitute ?. ?/ dirnam) server)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1401 (string-to-number artno)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1402 (string-to-number score))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1403 artlist))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1404 (message "Massaging hyrex-search output...done.")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1405 (apply 'vector
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1406 (sort* artlist
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1407 (function (lambda (x y)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1408 (if (string-lessp (nnir-artitem-group x)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1409 (nnir-artitem-group y))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1410 t
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1411 (< (nnir-artitem-number x)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1412 (nnir-artitem-number y)))))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1413 )))
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 ;; Namazu interface
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1416 (defun nnir-run-namazu (query server &optional group)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1417 "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
1418 pairs (also vectors, actually).
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1419
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1420 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
1421 (when group
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1422 (error "The Namazu backend cannot search specific groups"))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1423 (save-excursion
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1424 (let ((article-pattern (if (string= server "nnmaildir:")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1425 ":[0-9]+"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1426 "^[0-9]+$"))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1427 artlist
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1428 (qstring (cdr (assq 'query query)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1429 (prefix (nnir-read-server-parm 'nnir-namazu-remove-prefix server))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1430 score group article
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1431 (process-environment (copy-sequence process-environment)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1432 (setenv "LC_MESSAGES" "C")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1433 (set-buffer (get-buffer-create nnir-tmp-buffer))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1434 (erase-buffer)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1435 (let* ((cp-list
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1436 `( ,nnir-namazu-program
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1437 nil ; input from /dev/null
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1438 t ; output
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1439 nil ; don't redisplay
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1440 "-q" ; don't be verbose
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1441 "-a" ; show all matches
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1442 "-s" ; use short format
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1443 ,@(nnir-read-server-parm 'nnir-namazu-additional-switches server)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1444 ,qstring ; the query, in namazu format
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1445 ,(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
1446 ))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1447 (exitstatus
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1448 (progn
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1449 (message "%s args: %s" nnir-namazu-program
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1450 (mapconcat 'identity (cddddr cp-list) " "))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1451 (apply 'call-process cp-list))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1452 (unless (or (null exitstatus)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1453 (zerop exitstatus))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1454 (nnheader-report 'nnir "Couldn't run namazu: %s" exitstatus)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1455 ;; Namazu failure reason is in this buffer, show it if
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1456 ;; the user wants it.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1457 (when (> gnus-verbose 6)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1458 (display-buffer nnir-tmp-buffer))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1459
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1460 ;; Namazu output looks something like this:
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1461 ;; 2. Re: Gnus agent expire broken (score: 55)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1462 ;; /home/henrik/Mail/mail/sent/1310 (4,138 bytes)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1463
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1464 (goto-char (point-min))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1465 (while (re-search-forward
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1466 "^\\([0-9]+\\.\\).*\\((score: \\([0-9]+\\)\\))\n\\([^ ]+\\)"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1467 nil t)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1468 (setq score (match-string 3)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1469 group (file-name-directory (match-string 4))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1470 article (file-name-nondirectory (match-string 4)))
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 ;; make sure article and group is sane
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1473 (when (and (string-match article-pattern article)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1474 (not (null group)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1475 (nnir-add-result group article score prefix server artlist)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1476
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1477 ;; sort artlist by score
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1478 (apply 'vector
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1479 (sort* artlist
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1480 (function (lambda (x y)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1481 (> (nnir-artitem-rsv x)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1482 (nnir-artitem-rsv y)))))))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1483
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1484 (defun nnir-run-find-grep (query server &optional group)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1485 "Run find and grep to obtain matching articles."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1486 (let* ((method (gnus-server-to-method server))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1487 (sym (intern
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1488 (concat (symbol-name (car method)) "-directory")))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1489 (directory (cadr (assoc sym (cddr method))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1490 (regexp (cdr (assoc 'query query)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1491 (grep-options (cdr (assoc 'grep-options query)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1492 artlist)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1493 (unless directory
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1494 (error "No directory found in method specification of server %s"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1495 server))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1496 (message "Searching %s using find-grep..." (or group server))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1497 (save-window-excursion
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1498 (set-buffer (get-buffer-create nnir-tmp-buffer))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1499 (erase-buffer)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1500 (if (> gnus-verbose 6)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1501 (pop-to-buffer (current-buffer)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1502 (cd directory) ; Using relative paths simplifies postprocessing.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1503 (let ((group
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1504 (if (not group)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1505 "."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1506 ;; Try accessing the group literally as well as
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1507 ;; interpreting dots as directory separators so the
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1508 ;; engine works with plain nnml as well as the Gnus
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1509 ;; Cache.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1510 (find-if 'file-directory-p
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1511 (let ((group (gnus-group-real-name group)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1512 (list group (gnus-replace-in-string group "\\." "/" t)))))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1513 (unless group
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1514 (error "Cannot locate directory for group"))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1515 (save-excursion
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1516 (apply
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1517 'call-process "find" nil t
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1518 "find" group "-type" "f" "-name" "[0-9]*" "-exec"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1519 "grep"
95830
4bbbc2594f0b Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95616
diff changeset
1520 `("-l" ,@(and grep-options
4bbbc2594f0b Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95616
diff changeset
1521 ;; Note: the 3rd arg of `split-string' is not
4bbbc2594f0b Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95616
diff changeset
1522 ;; available in Emacs 21.
4bbbc2594f0b Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95616
diff changeset
1523 (delete "" (split-string grep-options "\\s-")))
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1524 "-e" ,regexp "{}" "+"))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1525
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1526 ;; Translate relative paths to group names.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1527 (while (not (eobp))
95830
4bbbc2594f0b Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95616
diff changeset
1528 (let* ((path (delete
4bbbc2594f0b Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95616
diff changeset
1529 ""
4bbbc2594f0b Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95616
diff changeset
1530 (split-string
4bbbc2594f0b Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95616
diff changeset
1531 (buffer-substring (point) (line-end-position)) "/")))
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1532 (art (string-to-number (car (last path)))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1533 (while (string= "." (car path))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1534 (setq path (cdr path)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1535 (let ((group (mapconcat 'identity (subseq path 0 -1) ".")))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1536 (push (vector (nnir-group-full-name group server) art 0)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1537 artlist))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1538 (forward-line 1)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1539 (message "Searching %s using find-grep...done" (or group server))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1540 artlist)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1541
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1542 ;;; Util Code:
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1543
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1544 (defun nnir-read-parms (query)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1545 "Reads additional search parameters according to `nnir-engines'."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1546 (let ((parmspec (caddr (assoc nnir-search-engine nnir-engines))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1547 (cons (cons 'query query)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1548 (mapcar 'nnir-read-parm parmspec))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1549
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1550 (defun nnir-read-parm (parmspec)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1551 "Reads a single search parameter.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1552 `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
1553 (let ((sym (car parmspec))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1554 (prompt (cdr parmspec)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1555 (if (listp prompt)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1556 (let* ((result (apply 'completing-read prompt))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1557 (mapping (or (assoc result nnir-imap-search-arguments)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1558 (assoc nil nnir-imap-search-arguments))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1559 (cons sym (format (cdr mapping) result)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1560 (cons sym (read-string prompt)))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1561
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1562 (defun nnir-run-query (query)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1563 "Invoke appropriate search engine function (see `nnir-engines').
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1564 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
1565 and concat the results."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1566 (let ((q (car (read-from-string query))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1567 (if gnus-group-marked
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1568 (apply 'vconcat
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1569 (mapcar (lambda (x)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1570 (let ((server (nnir-group-server x))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1571 search-func)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1572 (setq search-func (cadr
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1573 (assoc
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1574 (nnir-read-server-parm 'nnir-search-engine server) nnir-engines)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1575 (if search-func
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1576 (funcall search-func q server x)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1577 nil)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1578 gnus-group-marked)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1579 )
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1580 (apply 'vconcat
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1581 (mapcar (lambda (x)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1582 (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
1583 (let ((server (format "%s:%s" (caar x) (cadar x)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1584 search-func)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1585 (setq search-func (cadr
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1586 (assoc
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1587 (nnir-read-server-parm 'nnir-search-engine server) nnir-engines)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1588 (if search-func
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1589 (funcall search-func q server nil)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1590 nil))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1591 nil))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1592 gnus-opened-servers)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1593 ))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1594 ))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1595
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1596 (defun nnir-read-server-parm (key server)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1597 "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
1598 form 'backend:name'."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1599 (let ((method (gnus-server-to-method server)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1600 (cond ((and method (assq key (cddr method)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1601 (nth 1 (assq key (cddr method))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1602 ((and nnir-mail-backend
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1603 (gnus-server-equal method nnir-mail-backend))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1604 (symbol-value key))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1605 (t nil))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1606 ;; (if method
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1607 ;; (if (assq key (cddr method))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1608 ;; (nth 1 (assq key (cddr method)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1609 ;; (symbol-value key))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1610 ;; (symbol-value key))
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 (defun nnir-group-full-name (shortname server)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1614 "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
1615 The Gnus backend/server information is added."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1616 (gnus-group-prefixed-name shortname (gnus-server-to-method server)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1617
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1618 (defun nnir-possibly-change-server (server)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1619 (unless (and server (nnir-server-opened server))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1620 (nnir-open-server server)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1621
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 ;; Data type article list.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1624
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1625 (defun nnir-artlist-length (artlist)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1626 "Returns number of articles in artlist."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1627 (length artlist))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1628
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1629 (defun nnir-artlist-article (artlist n)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1630 "Returns from ARTLIST the Nth artitem (counting starting at 1)."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1631 (elt artlist (1- n)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1632
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1633 (defun nnir-artitem-group (artitem)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1634 "Returns the group from the ARTITEM."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1635 (elt artitem 0))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1636
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1637 (defun nnir-artlist-artitem-group (artlist n)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1638 "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
1639 (nnir-artitem-group (nnir-artlist-article artlist n)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1640
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1641 (defun nnir-artitem-number (artitem)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1642 "Returns the number from the ARTITEM."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1643 (elt artitem 1))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1644
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1645 (defun nnir-artlist-artitem-number (artlist n)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1646 "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
1647 (nnir-artitem-number (nnir-artlist-article artlist n)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1648
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1649 (defun nnir-artitem-rsv (artitem)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1650 "Returns the Retrieval Status Value (RSV, score) from the ARTITEM."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1651 (elt artitem 2))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1652
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1653 (defun nnir-artlist-artitem-rsv (artlist n)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1654 "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
1655 \(counting from 1)."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1656 (nnir-artitem-rsv (nnir-artlist-article artlist n)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1657
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1658 ;; unused?
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1659 (defun nnir-artlist-groups (artlist)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1660 "Returns a list of all groups in the given ARTLIST."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1661 (let ((res nil)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1662 (with-dups nil))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1663 ;; from each artitem, extract group component
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1664 (setq with-dups (mapcar 'nnir-artitem-group artlist))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1665 ;; remove duplicates from above
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1666 (mapc (function (lambda (x) (add-to-list 'res x)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1667 with-dups)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1668 res))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1669
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1670
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1671 ;; The end.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1672 (provide 'nnir)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1673
95616
49755ce71b9e Formatting fixes.
Glenn Morris <rgm@gnu.org>
parents: 95610
diff changeset
1674 ;; arch-tag: 9b3fecf8-4397-4bbb-bf3c-6ac3cbbc6664
49755ce71b9e Formatting fixes.
Glenn Morris <rgm@gnu.org>
parents: 95610
diff changeset
1675 ;;; nnir.el ends here