annotate lisp/gnus/nnir.el @ 111986:faa4a1c986c6

Merge changes made in Gnus trunk. nnimap.el (nnimap-wait-for-response): Always look (at least) at the previous line. nnimap.el (nnimap-quirk): New function. (nnimap-retrieve-group-data-early): Use it. (nnimap-quirks): New alist. gnus.texi (Foreign Groups): Added clarification of foreign groups. gnus-sum.el (gnus-summary-push-marks-to-backend): Fix the logic for copying read-ness to the backends. gnus-group.el (gnus-group-kill-group): Notify the backend that the group has been killed. (gnus-group-yank-group): Ditto. gnus-start.el (gnus-subscribe-newsgroup): Notify the backend. nnir.el: Improve customizations. gnus.texi (Archived Messages): Removed outdated comment and text. nnfolder.el (nnfolder-save-all-buffers): Refactor out into its own function. (nnfolder-request-expire-articles): Save all the buffers after doing expiry. nnmail.el (nnmail-expiry-target-group): Revert the "all articles are the last article", since that led to serious performance regressions when expiring nnml groups. gnus-html.el (gnus-html-schedule-image-fetching): Make sure the HTML fetching stops when Gnus exits. gnus-srvr.el: Avoid passing nil regexp argument to delete-matching-lines. auth-source.el (auth-source-gpg-encrypt-to): New variable to set the list of recipient keys, or use symmetric encryption if not a list. (auth-source-create): Use it to make `epa-file-encrypt-to' local for an EPA override, replacing the call to `netrc-store-data'.
author Katsumi Yamaoka <yamaoka@jpl.org>
date Thu, 16 Dec 2010 22:22:28 +0000
parents 44431106d60d
children c92e0a5c96e9
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,
106815
1d1d5d9bd884 Add 2010 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 105167
diff changeset
4 ;; 2007, 2008, 2009, 2010 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
111245
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
35 ;; Where in the existing gnus manual would this fit best?
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
36
111245
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
37 ;; What does it do? Well, it allows you to search your mail using
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
38 ;; some search engine (imap, namazu, swish-e, gmane and others -- see
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
39 ;; later) by typing `G G' in the Group buffer. You will then get a
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
40 ;; buffer which shows all articles matching the query, sorted by
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
41 ;; Retrieval Status Value (score).
95610
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 ;; When looking at the retrieval result (in the Summary buffer) you
111669
ed117caa918e Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111584
diff changeset
44 ;; can type `A W' (aka M-x gnus-warp-to-article RET) on an article. You
111789
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
45 ;; will be warped into the group this article came from. Typing `A T'
111430
b75e6634a171 gnus-int.el, nnimap.el, nnir.el: More improvements to thread-referral.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111401
diff changeset
46 ;; (aka M-x gnus-summary-refer-thread RET) will warp to the group and
b75e6634a171 gnus-int.el, nnimap.el, nnir.el: More improvements to thread-referral.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111401
diff changeset
47 ;; also show the thread this article is part of.
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
48
111245
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
49 ;; The Lisp setup may involve setting a few variables and setting up the
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
50 ;; 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
51 ;; like this :
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
52 ;; (setq gnus-secondary-select-methods '(
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
53 ;; (nnimap "" (nnimap-address "localhost")
111217
7be484934a7c nnir.el (nnir-run-swish-e): Remove hyrex support.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111138
diff changeset
54 ;; (nnir-search-engine namazu)
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
55 ;; )))
111245
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
56 ;; The main variable to set is `nnir-search-engine'. Choose one of
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
57 ;; the engines listed in `nnir-engines'. (Actually `nnir-engines' is
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
58 ;; an alist, type `C-h v nnir-engines RET' for more information; this
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
59 ;; includes examples for setting `nnir-search-engine', too.)
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
60
111245
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
61 ;; If you use one of the local indices (namazu, find-grep, swish) you
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
62 ;; must also set up a search engine backend.
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
63
111245
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
64 ;; 1. Namazu
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
65 ;;
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
66 ;; 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
67 ;; 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
68 ;; variable. To function the `nnir-namazu-remove-prefix' variable must
111245
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
69 ;; also be correct, see the documentation for `nnir-namazu-remove-prefix'
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
70 ;; above.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
71 ;;
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
72 ;; 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
73 ;; 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
74 ;; `--sort', `--ascending', `--early' and `--late'. Refer to the Namazu
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
75 ;; documentation for further information on valid switches.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
76 ;;
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
77 ;; 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
78 ;; configuration file:
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
79 ;;
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 ;; | package conf; # Don't remove this line!
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
82 ;; |
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
83 ;; | # 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
84 ;; | $EXCLUDE_PATH = "spam|sent";
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
85 ;; |
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
86 ;; | # Header fields which should be searchable. case-insensitive
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
87 ;; | $REMAIN_HEADER = "from|date|message-id|subject";
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
88 ;; |
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
89 ;; | # Searchable fields. case-insensitive
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
90 ;; | $SEARCH_FIELD = "from|date|message-id|subject";
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
91 ;; |
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
92 ;; | # The max length of a word.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
93 ;; | $WORD_LENG_MAX = 128;
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
94 ;; |
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
95 ;; | # The max length of a field.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
96 ;; | $MAX_FIELD_LENGTH = 256;
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
97 ;; `----
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
98 ;;
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
99 ;; 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
100 ;; ~/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
101 ;; `nnir-namazu-index-directory' and issue the following command.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
102 ;;
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
103 ;; mknmz --mailnews ~/Mail/archive/ ~/Mail/mail/ ~/Mail/lists/
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
104 ;;
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
105 ;; 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
106 ;; command every four hours.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
107
111245
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
108 ;; 2. find-grep
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
109 ;;
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
110 ;; 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
111 ;; 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
112 ;; 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
113 ;; 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
114 ;; means for searching. The method specification of the server to
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
115 ;; 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
116 ;; `nnml-directory'). The tools must be POSIX compliant. GNU Find
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
117 ;; 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
118 ;; handling) does not work.
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 ;; | ;; find-grep configuration for searching the Gnus Cache
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
121 ;; |
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
122 ;; | (nnml "cache"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
123 ;; | (nnml-get-new-mail nil)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
124 ;; | (nnir-search-engine find-grep)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
125 ;; | (nnml-directory "~/News/cache/")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
126 ;; | (nnml-active-file "~/News/cache/active"))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
127 ;; `----
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 ;; Developer information:
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
130
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
131 ;; 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
132 ;; into two layers. The upper layer is somewhat like the `nnvirtual'
110100
8f51744211eb Remove nndb, nnkiboze and related code.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 107978
diff changeset
133 ;; backend: given a specification of what articles to show from
8f51744211eb Remove nndb, nnkiboze and related code.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 107978
diff changeset
134 ;; another backend, it creates a group containing exactly those
8f51744211eb Remove nndb, nnkiboze and related code.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 107978
diff changeset
135 ;; articles. The lower layer issues a query to a search engine and
8f51744211eb Remove nndb, nnkiboze and related code.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 107978
diff changeset
136 ;; produces such a specification of what articles to show from the
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
137 ;; other backend.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
138
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
139 ;; The interface between the two layers consists of the single
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
140 ;; function `nnir-run-query', which just selects the appropriate
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
141 ;; 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
142 ;; `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
143 ;; 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
144 ;; 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
145 ;; 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
146 ;; 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
147 ;; 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
148 ;; 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
149 ;; the search engine. For Boolean search engines, the
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
150 ;; 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
151
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
152 ;; 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
153 ;; 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
154 ;; 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
155 ;; 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
156 ;; sorted differently?
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 ;; 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
159 ;; engine? You write a function that executes the query. Temporary
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
160 ;; 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
161 ;; 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
162 ;; described above. Then, you need to register this backend in
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
163 ;; `nnir-engines'. Then, users can choose the backend by setting
111245
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
164 ;; `nnir-search-engine' as a server variable.
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
165
111812
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
166 ;;; Code:
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
167
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
168 ;;; Setup:
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
169
111288
6bc575569d37 Silence nnir.el compilation.
Glenn Morris <rgm@gnu.org>
parents: 111269
diff changeset
170 ;; For Emacs <22.2 and XEmacs.
6bc575569d37 Silence nnir.el compilation.
Glenn Morris <rgm@gnu.org>
parents: 111269
diff changeset
171 (eval-and-compile
6bc575569d37 Silence nnir.el compilation.
Glenn Morris <rgm@gnu.org>
parents: 111269
diff changeset
172 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
6bc575569d37 Silence nnir.el compilation.
Glenn Morris <rgm@gnu.org>
parents: 111269
diff changeset
173
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
174 (require 'nnoo)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
175 (require 'gnus-group)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
176 (require 'message)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
177 (require 'gnus-util)
104584
f540e84a920d (top-level): Don't require cl at run-time.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
178 (eval-when-compile
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
179 (require 'cl))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
180
111812
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
181 ;;; Internal Variables:
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
182
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
183 (defvar nnir-current-query nil
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
184 "Internal: stores current query (= group name).")
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
185
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
186 (defvar nnir-current-server nil
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
187 "Internal: stores current server (does it ever change?).")
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
188
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
189 (defvar nnir-current-group-marked nil
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
190 "Internal: stores current list of process-marked groups.")
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
191
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
192 (defvar nnir-artlist nil
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
193 "Internal: stores search result.")
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
194
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
195 (defvar nnir-tmp-buffer " *nnir*"
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
196 "Internal: temporary buffer.")
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
197
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
198 (defvar nnir-search-history ()
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
199 "Internal: the history for querying search options in nnir")
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
200
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
201 (defvar nnir-extra-parms nil
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
202 "Internal: stores request for extra search parms")
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
203
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
204 ;; Imap variables
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
205
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
206 (defvar nnir-imap-search-arguments
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
207 '(("Whole message" . "TEXT")
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
208 ("Subject" . "SUBJECT")
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
209 ("To" . "TO")
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
210 ("From" . "FROM")
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
211 ("Imap" . ""))
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
212 "Mapping from user readable keys to IMAP search items for use in nnir")
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
213
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
214 (defvar nnir-imap-search-other "HEADER %S"
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
215 "The IMAP search item to use for anything other than
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
216 `nnir-imap-search-arguments'. By default this is the name of an
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
217 email header field")
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
218
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
219 (defvar nnir-imap-search-argument-history ()
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
220 "The history for querying search options in nnir")
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
221
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
222 ;;; Helper macros
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
223
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
224 ;; Data type article list.
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
225
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
226 (defmacro nnir-artlist-length (artlist)
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
227 "Returns number of articles in artlist."
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
228 `(length ,artlist))
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
229
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
230 (defmacro nnir-artlist-article (artlist n)
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
231 "Returns from ARTLIST the Nth artitem (counting starting at 1)."
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
232 `(when (> ,n 0)
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
233 (elt ,artlist (1- ,n))))
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
234
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
235 (defmacro nnir-artitem-group (artitem)
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
236 "Returns the group from the ARTITEM."
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
237 `(elt ,artitem 0))
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
238
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
239 (defmacro nnir-artitem-number (artitem)
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
240 "Returns the number from the ARTITEM."
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
241 `(elt ,artitem 1))
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
242
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
243 (defmacro nnir-artitem-rsv (artitem)
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
244 "Returns the Retrieval Status Value (RSV, score) from the ARTITEM."
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
245 `(elt ,artitem 2))
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
246
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
247 (defmacro nnir-article-group (article)
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
248 "Returns the group for ARTICLE"
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
249 `(nnir-artitem-group (nnir-artlist-article nnir-artlist ,article)))
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
250
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
251 (defmacro nnir-article-number (article)
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
252 "Returns the number for ARTICLE"
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
253 `(nnir-artitem-number (nnir-artlist-article nnir-artlist ,article)))
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
254
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
255 (defmacro nnir-article-rsv (article)
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
256 "Returns the rsv for ARTICLE"
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
257 `(nnir-artitem-rsv (nnir-artlist-article nnir-artlist ,article)))
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
258
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
259 (defsubst nnir-article-ids (article)
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
260 "Returns the pair `(nnir id . real id)' of ARTICLE"
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
261 (cons article (nnir-article-number article)))
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
262
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
263 (defmacro nnir-categorize (sequence keyfunc &optional valuefunc)
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
264 "Sorts a sequence into categories and returns a list of the form
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
265 `((key1 (element11 element12)) (key2 (element21 element22))'.
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
266 The category key for a member of the sequence is obtained
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
267 as `(keyfunc member)' and the corresponding element is just
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
268 `member'. If `valuefunc' is non-nil, the element of the list
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
269 is `(valuefunc member)'."
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
270 `(unless (null ,sequence)
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
271 (let (value)
111830
79219ca01c7b Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111812
diff changeset
272 (mapc
111812
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
273 (lambda (member)
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
274 (let ((y (,keyfunc member))
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
275 (x ,(if valuefunc
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
276 `(,valuefunc member)
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
277 'member)))
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
278 (if (assoc y value)
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
279 (push x (cadr (assoc y value)))
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
280 (push (list y (list x)) value))))
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
281 ,sequence)
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
282 value)))
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
283
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
284 ;;; Finish setup:
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
285
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
286 (require 'gnus-sum)
110908
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
287
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
288 (eval-when-compile
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
289 (autoload 'nnimap-buffer "nnimap")
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
290 (autoload 'nnimap-command "nnimap")
111789
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
291 (autoload 'nnimap-possibly-change-group "nnimap")
111963
44431106d60d nnir.el (nnir-mode): Don't install registry hooks if user hasn't installed the registry.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111953
diff changeset
292 (autoload 'gnus-registry-action "gnus-registry")
44431106d60d nnir.el (nnir-mode): Don't install registry hooks if user hasn't installed the registry.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111953
diff changeset
293 (defvar gnus-registry-install))
44431106d60d nnir.el (nnir-mode): Don't install registry hooks if user hasn't installed the registry.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111953
diff changeset
294
110908
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
295
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
296 (nnoo-declare nnir)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
297 (nnoo-define-basics nnir)
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 (gnus-declare-backend "nnir" 'mail)
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
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
302 ;;; User Customizable Variables:
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
303
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
304 (defgroup nnir nil
111245
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
305 "Search groups in Gnus with assorted seach engines."
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
306 :group 'gnus)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
307
111789
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
308 (defcustom nnir-ignored-newsgroups ""
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
309 "*A regexp to match newsgroups in the active file that should
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
310 be skipped when searching."
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
311 :type '(regexp)
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
312 :group 'nnir)
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
313
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
314 (defcustom nnir-summary-line-format nil
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
315 "*The format specification of the lines in an nnir summary buffer.
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
316
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
317 All the items from `gnus-summary-line-format' are available, along
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
318 with three items unique to nnir summary buffers:
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
319
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
320 %Z Search retrieval score value (integer)
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
321 %G Article original full group name (string)
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
322 %g Article original short group name (string)
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
323
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
324 If nil this will use `gnus-summary-line-format'."
111986
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111963
diff changeset
325 :type '(string)
111789
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
326 :group 'nnir)
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
327
111812
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
328 (defcustom nnir-retrieve-headers-override-function nil
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
329 "*If non-nil, a function that accepts an article list and group
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
330 and populates the `nntp-server-buffer' with the retrieved
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
331 headers. Must return either 'nov or 'headers indicating the
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
332 retrieved header format.
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
333
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
334 If this variable is nil, or if the provided function returns nil for a search
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
335 result, `gnus-retrieve-headers' will be called instead."
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
336 :type '(function)
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
337 :group 'nnir)
5e488dbb17f7 nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
338
111245
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
339 (defcustom nnir-imap-default-search-key "Whole message"
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
340 "*The default IMAP search key for an nnir search. Must be one of
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
341 the keys in `nnir-imap-search-arguments'. To use raw imap queries
111789
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
342 by default set this to \"Imap\"."
111986
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111963
diff changeset
343 :type `(choice ,@(mapcar (lambda (elem) (list 'const (car elem)))
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111963
diff changeset
344 nnir-imap-search-arguments))
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
345 :group 'nnir)
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 (defcustom nnir-swish++-configuration-file
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
348 (expand-file-name "~/Mail/swish++.conf")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
349 "*Configuration file for swish++."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
350 :type '(file)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
351 :group 'nnir)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
352
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
353 (defcustom nnir-swish++-program "search"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
354 "*Name of swish++ search executable."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
355 :type '(string)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
356 :group '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 (defcustom nnir-swish++-additional-switches '()
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
359 "*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
360
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
361 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
362 (setq nnir-swish++-additional-switches \"-i -w\") ; wrong
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
363 Instead, use this:
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
364 (setq nnir-swish++-additional-switches '(\"-i\" \"-w\"))"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
365 :type '(repeat (string))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
366 :group 'nnir)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
367
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
368 (defcustom nnir-swish++-remove-prefix (concat (getenv "HOME") "/Mail/")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
369 "*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
370 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
371 regular expression.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
372
111245
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
373 This variable is very similar to `nnir-namazu-remove-prefix', except
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
374 that it is for swish++, not Namazu."
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
375 :type '(regexp)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
376 :group 'nnir)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
377
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
378 ;; Swish-E.
110790
1f25b03df4ad Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110777
diff changeset
379 ;; URL: http://swish-e.org/
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
380 ;; 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
381 ;; `nnir-swish-e-additional-switches'
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
382
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
383 (make-obsolete-variable 'nnir-swish-e-index-file
104700
9866b069527c * spam.el (spam-ifile-path, spam-bogofilter-path, spam-sa-learn-path)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 104584
diff changeset
384 'nnir-swish-e-index-files "Emacs 23.1")
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
385 (defcustom nnir-swish-e-index-file
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
386 (expand-file-name "~/Mail/index.swish-e")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
387 "*Index file for swish-e.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
388 This could be a server parameter.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
389 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
390 used instead, has been customized."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
391 :type '(file)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
392 :group 'nnir)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
393
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
394 (defcustom nnir-swish-e-index-files
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
395 (list nnir-swish-e-index-file)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
396 "*List of index files for swish-e.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
397 This could be a server parameter."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
398 :type '(repeat (file))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
399 :group 'nnir)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
400
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
401 (defcustom nnir-swish-e-program "swish-e"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
402 "*Name of swish-e search executable.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
403 This cannot be a server parameter."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
404 :type '(string)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
405 :group 'nnir)
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 (defcustom nnir-swish-e-additional-switches '()
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
408 "*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
409
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
410 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
411 (setq nnir-swish-e-additional-switches \"-i -w\") ; wrong
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
412 Instead, use this:
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
413 (setq nnir-swish-e-additional-switches '(\"-i\" \"-w\"))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
414
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
415 This could be a server parameter."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
416 :type '(repeat (string))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
417 :group 'nnir)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
418
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
419 (defcustom nnir-swish-e-remove-prefix (concat (getenv "HOME") "/Mail/")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
420 "*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
421 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
422 regular expression.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
423
111245
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
424 This variable is very similar to `nnir-namazu-remove-prefix', except
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
425 that it is for swish-e, not Namazu.
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
426
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
427 This could be a server parameter."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
428 :type '(regexp)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
429 :group 'nnir)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
430
111245
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
431 ;; HyREX engine, see <URL:http://ls6-www.cs.uni-dortmund.de/>
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
432
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
433 (defcustom nnir-hyrex-program "nnir-search"
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
434 "*Name of the nnir-search executable."
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
435 :type '(string)
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
436 :group 'nnir)
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
437
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
438 (defcustom nnir-hyrex-additional-switches '()
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
439 "*A list of strings, to be given as additional arguments for nnir-search.
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
440 Note that this should be a list. Ie, do NOT use the following:
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
441 (setq nnir-hyrex-additional-switches \"-ddl ddl.xml -c nnir\") ; wrong !
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
442 Instead, use this:
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
443 (setq nnir-hyrex-additional-switches '(\"-ddl\" \"ddl.xml\" \"-c\" \"nnir\"))"
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
444 :type '(repeat (string))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
445 :group 'nnir)
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
446
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
447 (defcustom nnir-hyrex-index-directory (getenv "HOME")
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
448 "*Index directory for HyREX."
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
449 :type '(directory)
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
450 :group 'nnir)
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
451
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
452 (defcustom nnir-hyrex-remove-prefix (concat (getenv "HOME") "/Mail/")
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
453 "*The prefix to remove from each file name returned by HyREX
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
454 in order to get a group name (albeit with / instead of .).
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
455
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
456 For example, suppose that HyREX returns file names such as
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
457 \"/home/john/Mail/mail/misc/42\". For this example, use the following
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
458 setting: (setq nnir-hyrex-remove-prefix \"/home/john/Mail/\")
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
459 Note the trailing slash. Removing this prefix gives \"mail/misc/42\".
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
460 `nnir' knows to remove the \"/42\" and to replace \"/\" with \".\" to
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
461 arrive at the correct group name, \"mail.misc\"."
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
462 :type '(directory)
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
463 :group 'nnir)
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
464
110790
1f25b03df4ad Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110777
diff changeset
465 ;; Namazu engine, see <URL:http://www.namazu.org/>
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
466
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
467 (defcustom nnir-namazu-program "namazu"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
468 "*Name of Namazu search executable."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
469 :type '(string)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
470 :group 'nnir)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
471
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
472 (defcustom nnir-namazu-index-directory (expand-file-name "~/Mail/namazu/")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
473 "*Index directory for Namazu."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
474 :type '(directory)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
475 :group 'nnir)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
476
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
477 (defcustom nnir-namazu-additional-switches '()
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
478 "*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
479 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
480 make any sense in this context.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
481
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
482 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
483 (setq nnir-namazu-additional-switches \"-i -w\") ; wrong
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
484 Instead, use this:
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
485 (setq nnir-namazu-additional-switches '(\"-i\" \"-w\"))"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
486 :type '(repeat (string))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
487 :group 'nnir)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
488
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
489 (defcustom nnir-namazu-remove-prefix (concat (getenv "HOME") "/Mail/")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
490 "*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
491 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
492
111245
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
493 For example, suppose that Namazu returns file names such as
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
494 \"/home/john/Mail/mail/misc/42\". For this example, use the following
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
495 setting: (setq nnir-namazu-remove-prefix \"/home/john/Mail/\")
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
496 Note the trailing slash. Removing this prefix gives \"mail/misc/42\".
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
497 `nnir' knows to remove the \"/42\" and to replace \"/\" with \".\" to
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
498 arrive at the correct group name, \"mail.misc\"."
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
499 :type '(directory)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
500 :group 'nnir)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
501
111245
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
502 ;;; Developer Extension Variable:
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
503
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
504 (defvar nnir-engines
111321
f4305de1a430 nnir: remove wais support
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111314
diff changeset
505 `((imap nnir-run-imap
111245
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
506 ((criteria
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
507 "Imap Search in" ; Prompt
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
508 ,(mapcar 'car nnir-imap-search-arguments) ; alist for completing
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
509 nil ; allow any user input
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
510 nil ; initial value
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
511 nnir-imap-search-argument-history ; the history to use
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
512 ,nnir-imap-default-search-key ; default
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
513 )))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
514 (gmane nnir-run-gmane
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
515 ((author . "Gmane Author: ")))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
516 (swish++ nnir-run-swish++
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
517 ((group . "Swish++ Group spec: ")))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
518 (swish-e nnir-run-swish-e
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
519 ((group . "Swish-e Group spec: ")))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
520 (namazu nnir-run-namazu
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
521 ())
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
522 (hyrex nnir-run-hyrex
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
523 ((group . "Hyrex Group spec: ")))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
524 (find-grep nnir-run-find-grep
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
525 ((grep-options . "Grep options: "))))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
526 "Alist of supported search engines.
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
527 Each element in the alist is a three-element list (ENGINE FUNCTION ARGS).
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
528 ENGINE is a symbol designating the searching engine. FUNCTION is also
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
529 a symbol, giving the function that does the search. The third element
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
530 ARGS is a list of cons pairs (PARAM . PROMPT). When issuing a query,
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
531 the FUNCTION will issue a query for each of the PARAMs, using PROMPT.
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
532
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
533 The value of `nnir-search-engine' must be one of the ENGINE symbols.
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
534 For example, for searching a server using namazu include
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
535 (nnir-search-engine namazu)
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
536 in the server definition. Note that you have to set additional
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
537 variables for most backends. For example, the `namazu' backend
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
538 needs the variables `nnir-namazu-program',
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
539 `nnir-namazu-index-directory' and `nnir-namazu-remove-prefix'.
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
540
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
541 Add an entry here when adding a new search engine.")
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
542
111986
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111963
diff changeset
543 (defcustom nnir-method-default-engines
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111963
diff changeset
544 '((nnimap . imap)
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111963
diff changeset
545 (nntp . gmane))
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111963
diff changeset
546 "*Alist of default search engines keyed by server method."
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111963
diff changeset
547 :type `(repeat (cons (choice (const nnimap) (const nttp) (const nnspool)
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111963
diff changeset
548 (const nneething) (const nndir) (const nnmbox)
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111963
diff changeset
549 (const nnml) (const nnmh) (const nndraft)
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111963
diff changeset
550 (const nnfolder) (const nnmaildir))
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111963
diff changeset
551 (choice
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111963
diff changeset
552 ,@(mapcar (lambda (elem) (list 'const (car elem)))
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111963
diff changeset
553 nnir-engines))))
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111963
diff changeset
554 :group 'nnir)
111789
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
555
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
556 ;; Gnus glue.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
557
111245
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
558 (defun gnus-group-make-nnir-group (nnir-extra-parms)
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
559 "Create an nnir group. Asks for query."
111245
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
560 (interactive "P")
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
561 (setq nnir-current-query nil
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
562 nnir-current-server nil
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
563 nnir-current-group-marked nil
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
564 nnir-artlist nil)
111245
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
565 (let* ((query (read-string "Query: " nil 'nnir-search-history))
111269
3d7a1caabf14 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111245
diff changeset
566 (parms (list (cons 'query query)))
3d7a1caabf14 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111245
diff changeset
567 (srv (if (gnus-server-server-name)
3d7a1caabf14 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111245
diff changeset
568 "all" "")))
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
569 (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
570 (gnus-group-read-ephemeral-group
111269
3d7a1caabf14 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111245
diff changeset
571 (concat "nnir:" (prin1-to-string parms)) (list 'nnir srv) t
111245
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
572 (cons (current-buffer) gnus-current-window-configuration)
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
573 nil)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
574
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 ;; Gnus backend interface functions.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
577
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
578 (deffoo nnir-open-server (server &optional definitions)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
579 ;; Just set the server variables appropriately.
111789
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
580 (add-hook 'gnus-summary-mode-hook 'nnir-mode)
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
581 (nnoo-change-server 'nnir server definitions))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
582
110422
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110410
diff changeset
583 (deffoo nnir-request-group (group &optional server fast info)
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
584 "GROUP is the query string."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
585 (nnir-possibly-change-server server)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
586 ;; Check for cache and return that if appropriate.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
587 (if (and (equal group nnir-current-query)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
588 (equal gnus-group-marked nnir-current-group-marked)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
589 (or (null server)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
590 (equal server nnir-current-server)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
591 nnir-artlist
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
592 ;; Cache miss.
111269
3d7a1caabf14 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111245
diff changeset
593 (setq nnir-artlist (nnir-run-query group server)))
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110111
diff changeset
594 (with-current-buffer nntp-server-buffer
111245
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
595 (setq nnir-current-query group)
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
596 (when server (setq nnir-current-server server))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
597 (setq nnir-current-group-marked gnus-group-marked)
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
598 (if (zerop (length nnir-artlist))
111245
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
599 (nnheader-report 'nnir "Search produced empty results.")
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
600 ;; Remember data for cache.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
601 (nnheader-insert "211 %d %d %d %s\n"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
602 (nnir-artlist-length nnir-artlist) ; total #
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
603 1 ; first #
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
604 (nnir-artlist-length nnir-artlist) ; last #
111245
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
605 group)))) ; group name
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
606
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
607 (deffoo nnir-retrieve-headers (articles &optional group server fetch-old)
111789
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
608 (with-current-buffer nntp-server-buffer
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
609 (let ((gnus-inhibit-demon t)
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
610 (articles-by-group (nnir-categorize
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
611 articles nnir-article-group nnir-article-ids))
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
612 headers)
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
613 (while (not (null articles-by-group))
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
614 (let* ((group-articles (pop articles-by-group))
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
615 (artgroup (car group-articles))
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
616 (articleids (cadr group-articles))
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
617 (artlist (sort (mapcar 'cdr articleids) '<))
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
618 (server (gnus-group-server artgroup))
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
619 (gnus-override-method (gnus-server-to-method server))
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
620 parsefunc)
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
621 ;; (or (numberp art)
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
622 ;; (nnheader-report
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
623 ;; 'nnir
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
624 ;; "nnir-retrieve-headers doesn't grok message ids: %s"
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
625 ;; art))
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
626 (nnir-possibly-change-server server)
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
627 ;; is this needed?
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
628 (erase-buffer)
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
629 (case (setq gnus-headers-retrieved-by
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
630 (or
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
631 (and
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
632 nnir-retrieve-headers-override-function
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
633 (funcall nnir-retrieve-headers-override-function
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
634 artlist artgroup))
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
635 (gnus-retrieve-headers artlist artgroup nil)))
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
636 (nov
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
637 (setq parsefunc 'nnheader-parse-nov))
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
638 (headers
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
639 (setq parsefunc 'nnheader-parse-head))
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
640 (t (error "Unknown header type %s while requesting articles \
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
641 of group %s" gnus-headers-retrieved-by artgroup)))
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
642 (goto-char (point-min))
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
643 (while (not (eobp))
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
644 (let* ((novitem (funcall parsefunc))
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
645 (artno (mail-header-number novitem))
111852
7b4048d45603 nnir.el (nnir-retrieve-headers): Use rassq when comparing article ids.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111843
diff changeset
646 (art (car (rassq artno articleids))))
111789
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
647 (when art
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
648 (mail-header-set-number novitem art)
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
649 (push novitem headers))
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
650 (forward-line 1)))))
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
651 (setq headers
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
652 (sort headers
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
653 (lambda (x y)
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
654 (< (mail-header-number x) (mail-header-number y)))))
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
655 (erase-buffer)
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
656 (mapc 'nnheader-insert-nov headers)
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
657 'nov)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
658
111789
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
659 (deffoo nnir-request-article (article &optional group server to-buffer)
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
660 (if (stringp article)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
661 (nnheader-report
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
662 'nnir
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
663 "nnir-retrieve-headers doesn't grok message ids: %s"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
664 article)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
665 (save-excursion
111789
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
666 (let ((artfullgroup (nnir-article-group article))
111843
94c9743593b9 nnir.el (nnir-run-gmane): Restore sub-optimal test for gmane server.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111832
diff changeset
667 (artno (nnir-article-number article)))
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
668 (message "Requesting article %d from group %s"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
669 artno artfullgroup)
111843
94c9743593b9 nnir.el (nnir-run-gmane): Restore sub-optimal test for gmane server.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111832
diff changeset
670 (if to-buffer
94c9743593b9 nnir.el (nnir-run-gmane): Restore sub-optimal test for gmane server.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111832
diff changeset
671 (with-current-buffer to-buffer
94c9743593b9 nnir.el (nnir-run-gmane): Restore sub-optimal test for gmane server.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111832
diff changeset
672 (let ((gnus-article-decode-hook nil))
94c9743593b9 nnir.el (nnir-run-gmane): Restore sub-optimal test for gmane server.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111832
diff changeset
673 (gnus-request-article-this-buffer artno artfullgroup)))
94c9743593b9 nnir.el (nnir-run-gmane): Restore sub-optimal test for gmane server.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111832
diff changeset
674 (gnus-request-article artno artfullgroup))
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
675 (cons artfullgroup artno)))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
676
111324
ab83881bb97a nnir.el (nnir-request-move-article): call the underlying backend to move articles from nnir.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111321
diff changeset
677 (deffoo nnir-request-move-article (article group server accept-form
ab83881bb97a nnir.el (nnir-request-move-article): call the underlying backend to move articles from nnir.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111321
diff changeset
678 &optional last internal-move-group)
111789
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
679 (let* ((artfullgroup (nnir-article-group article))
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
680 (artno (nnir-article-number article))
111324
ab83881bb97a nnir.el (nnir-request-move-article): call the underlying backend to move articles from nnir.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111321
diff changeset
681 (to-newsgroup (nth 1 accept-form))
ab83881bb97a nnir.el (nnir-request-move-article): call the underlying backend to move articles from nnir.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111321
diff changeset
682 (to-method (gnus-find-method-for-group to-newsgroup))
ab83881bb97a nnir.el (nnir-request-move-article): call the underlying backend to move articles from nnir.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111321
diff changeset
683 (from-method (gnus-find-method-for-group artfullgroup))
111832
7e8cf0f45075 nnir.el (nnir-request-move-article): Remove obsolete code.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111830
diff changeset
684 (move-is-internal (gnus-server-equal from-method to-method)))
111789
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
685 (unless (gnus-check-backend-function
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
686 'request-move-article artfullgroup)
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
687 (error "The group %s does not support article moving" artfullgroup))
111324
ab83881bb97a nnir.el (nnir-request-move-article): call the underlying backend to move articles from nnir.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111321
diff changeset
688 (gnus-request-move-article
ab83881bb97a nnir.el (nnir-request-move-article): call the underlying backend to move articles from nnir.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111321
diff changeset
689 artno
ab83881bb97a nnir.el (nnir-request-move-article): call the underlying backend to move articles from nnir.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111321
diff changeset
690 artfullgroup
ab83881bb97a nnir.el (nnir-request-move-article): call the underlying backend to move articles from nnir.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111321
diff changeset
691 (nth 1 from-method)
ab83881bb97a nnir.el (nnir-request-move-article): call the underlying backend to move articles from nnir.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111321
diff changeset
692 accept-form
ab83881bb97a nnir.el (nnir-request-move-article): call the underlying backend to move articles from nnir.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111321
diff changeset
693 last
ab83881bb97a nnir.el (nnir-request-move-article): call the underlying backend to move articles from nnir.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111321
diff changeset
694 (and move-is-internal
ab83881bb97a nnir.el (nnir-request-move-article): call the underlying backend to move articles from nnir.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111321
diff changeset
695 to-newsgroup ; Not respooling
111482
0aa164743cb3 nnir.el (nnir-request-move-article): fix to provide original group and subject.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111430
diff changeset
696 (gnus-group-real-name to-newsgroup)))))
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
697
111853
f7152aa1cc94 nnir.el (nnir-request-expire-articles): New function.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111852
diff changeset
698 (deffoo nnir-request-expire-articles (articles group &optional server force)
111872
a264bb877bc7 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111853
diff changeset
699 (if force
a264bb877bc7 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111853
diff changeset
700 (let ((articles-by-group (nnir-categorize
a264bb877bc7 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111853
diff changeset
701 articles nnir-article-group nnir-article-ids))
a264bb877bc7 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111853
diff changeset
702 not-deleted)
a264bb877bc7 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111853
diff changeset
703 (while (not (null articles-by-group))
a264bb877bc7 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111853
diff changeset
704 (let* ((group-articles (pop articles-by-group))
a264bb877bc7 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111853
diff changeset
705 (artgroup (car group-articles))
a264bb877bc7 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111853
diff changeset
706 (articleids (cadr group-articles))
a264bb877bc7 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111853
diff changeset
707 (artlist (sort (mapcar 'cdr articleids) '<)))
a264bb877bc7 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111853
diff changeset
708 (unless (gnus-check-backend-function 'request-expire-articles
a264bb877bc7 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111853
diff changeset
709 artgroup)
a264bb877bc7 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111853
diff changeset
710 (error "The group %s does not support article deletion" artgroup))
a264bb877bc7 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111853
diff changeset
711 (unless (gnus-check-server (gnus-find-method-for-group artgroup))
a264bb877bc7 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111853
diff changeset
712 (error "Couldn't open server for group %s" artgroup))
a264bb877bc7 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111853
diff changeset
713 (push (gnus-request-expire-articles
a264bb877bc7 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111853
diff changeset
714 artlist artgroup force)
a264bb877bc7 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111853
diff changeset
715 not-deleted)))
a264bb877bc7 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111853
diff changeset
716 (sort (delq nil not-deleted) '<))
a264bb877bc7 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111853
diff changeset
717 articles))
111853
f7152aa1cc94 nnir.el (nnir-request-expire-articles): New function.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111852
diff changeset
718
111430
b75e6634a171 gnus-int.el, nnimap.el, nnir.el: More improvements to thread-referral.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111401
diff changeset
719 (deffoo nnir-warp-to-article ()
111482
0aa164743cb3 nnir.el (nnir-request-move-article): fix to provide original group and subject.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111430
diff changeset
720 (let* ((cur (if (> (gnus-summary-article-number) 0)
0aa164743cb3 nnir.el (nnir-request-move-article): fix to provide original group and subject.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111430
diff changeset
721 (gnus-summary-article-number)
0aa164743cb3 nnir.el (nnir-request-move-article): fix to provide original group and subject.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111430
diff changeset
722 (error "This is not a real article.")))
111789
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
723 (gnus-newsgroup-name (nnir-article-group cur))
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
724 (backend-number (nnir-article-number cur)))
111430
b75e6634a171 gnus-int.el, nnimap.el, nnir.el: More improvements to thread-referral.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111401
diff changeset
725 (gnus-summary-read-group-1 gnus-newsgroup-name t t gnus-summary-buffer
b75e6634a171 gnus-int.el, nnimap.el, nnir.el: More improvements to thread-referral.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111401
diff changeset
726 nil (list backend-number))))
b75e6634a171 gnus-int.el, nnimap.el, nnir.el: More improvements to thread-referral.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111401
diff changeset
727
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
728 (nnoo-define-skeleton nnir)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
729
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
730
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
731 (defmacro nnir-add-result (dirnam artno score prefix server artlist)
95616
49755ce71b9e Formatting fixes.
Glenn Morris <rgm@gnu.org>
parents: 95610
diff changeset
732 "Ask `nnir-compose-result' to construct a result vector,
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
733 and if it is non-nil, add it to artlist."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
734 `(let ((result (nnir-compose-result ,dirnam ,artno ,score ,prefix ,server)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
735 (when (not (null result))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
736 (push result ,artlist))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
737
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
738 (autoload 'nnmaildir-base-name-to-article-number "nnmaildir")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
739
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
740 ;; Helper function currently used by the Swish++ and Namazu backends;
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
741 ;; perhaps useful for other backends as well
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
742 (defun nnir-compose-result (dirnam article score prefix server)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
743 "Extract the group from dirnam, and create a result vector
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
744 ready to be added to the list of search results."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
745
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
746 ;; remove nnir-*-remove-prefix from beginning of dirnam filename
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
747 (when (string-match (concat "^" prefix) dirnam)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
748 (setq dirnam (replace-match "" t t dirnam)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
749
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
750 (when (file-readable-p (concat prefix dirnam article))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
751 ;; remove trailing slash and, for nnmaildir, cur/new/tmp
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
752 (setq dirnam
110666
3b9bd3888ee9 nnimap.el (nnimap-request-accept-article): Get the Message-ID without the \r.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110661
diff changeset
753 (substring dirnam 0
3b9bd3888ee9 nnimap.el (nnimap-request-accept-article): Get the Message-ID without the \r.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110661
diff changeset
754 (if (string= (gnus-group-server server) "nnmaildir")
3b9bd3888ee9 nnimap.el (nnimap-request-accept-article): Get the Message-ID without the \r.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110661
diff changeset
755 -5 -1)))
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
756
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
757 ;; Set group to dirnam without any leading dots or slashes,
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
758 ;; and with all subsequent slashes replaced by dots
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
759 (let ((group (gnus-replace-in-string
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
760 (gnus-replace-in-string dirnam "^[./\\]" "" t)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
761 "[/\\]" "." t)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
762
111789
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
763 (vector (gnus-group-full-name group server)
110666
3b9bd3888ee9 nnimap.el (nnimap-request-accept-article): Get the Message-ID without the \r.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110661
diff changeset
764 (if (string= (gnus-group-server server) "nnmaildir")
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
765 (nnmaildir-base-name-to-article-number
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
766 (substring article 0 (string-match ":" article))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
767 group nil)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
768 (string-to-number article))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
769 (string-to-number score)))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
770
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
771 ;;; Search Engine Interfaces:
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
772
111245
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
773 ;; imap interface
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
774 (defun nnir-run-imap (query srv &optional groups)
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
775 "Run a search against an IMAP back-end server.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
776 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
777 details on the language and supported extensions"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
778 (save-excursion
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
779 (let ((qstring (cdr (assq 'query query)))
111245
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
780 (server (cadr (gnus-server-to-method srv)))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
781 (defs (caddr (gnus-server-to-method srv)))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
782 (criteria (or (cdr (assq 'criteria query))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
783 (cdr (assoc nnir-imap-default-search-key
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
784 nnir-imap-search-arguments))))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
785 (gnus-inhibit-demon t)
111584
4273d2312244 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111491
diff changeset
786 (groups (or groups (nnir-get-active srv))))
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
787 (message "Opening server %s" server)
111245
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
788 (apply
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
789 'vconcat
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
790 (mapcar
111669
ed117caa918e Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111584
diff changeset
791 (lambda (group)
ed117caa918e Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111584
diff changeset
792 (let (artlist)
111245
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
793 (condition-case ()
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
794 (when (nnimap-possibly-change-group
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
795 (gnus-group-short-name group) server)
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
796 (with-current-buffer (nnimap-buffer)
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
797 (message "Searching %s..." group)
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
798 (let ((arts 0)
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
799 (result (nnimap-command "UID SEARCH %s"
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
800 (if (string= criteria "")
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
801 qstring
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
802 (nnir-imap-make-query
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
803 criteria qstring)))))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
804 (mapc
111872
a264bb877bc7 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111853
diff changeset
805 (lambda (artnum)
a264bb877bc7 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111853
diff changeset
806 (let ((artn (string-to-number artnum)))
a264bb877bc7 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111853
diff changeset
807 (when (> artn 0)
a264bb877bc7 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111853
diff changeset
808 (push (vector group artn 100)
a264bb877bc7 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111853
diff changeset
809 artlist)
a264bb877bc7 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111853
diff changeset
810 (setq arts (1+ arts)))))
a264bb877bc7 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111853
diff changeset
811 (and (car result) (cdr (assoc "SEARCH" (cdr result)))))
111245
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
812 (message "Searching %s... %d matches" group arts)))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
813 (message "Searching %s...done" group))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
814 (quit nil))
111952
db63bc492d85 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111872
diff changeset
815 (nreverse artlist)))
111245
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
816 groups)))))
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
817
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
818 (defun nnir-imap-make-query (criteria qstring)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
819 "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
820 expression, returning the string query to make.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
821
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
822 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
823 to an arbitrary query string to the end user.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
824
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
825 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
826 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
827
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
828 Automatic \"and\" queries
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
829 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
830 expression intended to match all components.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
831
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
832 Phrase searches
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
833 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
834 literal string.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
835
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
836 Negative terms
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
837 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
838
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
839 \"OR\" queries
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
840 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
841 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
842
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
843 In future the following will be added to the language:
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
844 * support for date matches
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
845 * support for location of text matching within the query
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
846 * from/to/etc headers
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
847 * additional search terms
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
848 * flag based searching
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
849 * anything else that the RFC supports, basically."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
850 ;; 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
851 (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
852
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 (defun nnir-imap-query-to-imap (criteria query)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
855 "Turn a s-expression format query into IMAP."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
856 (mapconcat
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
857 ;; Turn the expressions into IMAP text
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
858 (lambda (item)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
859 (nnir-imap-expr-to-imap criteria item))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
860 ;; The query, already in s-expr format.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
861 query
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
862 ;; Append a space between each expression
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
863 " "))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
864
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 (defun nnir-imap-expr-to-imap (criteria expr)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
867 "Convert EXPR into an IMAP search expression on CRITERIA"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
868 ;; What sort of expression is this, eh?
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
869 (cond
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
870 ;; Simple string term
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
871 ((stringp expr)
110908
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
872 (format "%s %S" criteria expr))
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
873 ;; Trivial term: and
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
874 ((eq expr 'and) nil)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
875 ;; Composite term: or expression
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
876 ((eq (car-safe expr) 'or)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
877 (format "OR %s %s"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
878 (nnir-imap-expr-to-imap criteria (second expr))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
879 (nnir-imap-expr-to-imap criteria (third expr))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
880 ;; Composite term: just the fax, mam
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
881 ((eq (car-safe expr) 'not)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
882 (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
883 ;; Composite term: just expand it all.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
884 ((and (not (null expr)) (listp expr))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
885 (format "(%s)" (nnir-imap-query-to-imap criteria expr)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
886 ;; Complex value, give up for now.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
887 (t (error "Unhandled input: %S" expr))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
888
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
889
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
890 (defun nnir-imap-parse-query (string)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
891 "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
892 query language as defined in `nnir-imap-make-query'.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
893
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
894 This involves turning individual tokens into higher level terms
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
895 that the search language can then understand and use."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
896 (with-temp-buffer
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
897 ;; Set up the parsing environment.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
898 (insert string)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
899 (goto-char (point-min))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
900 ;; Now, collect the output terms and return them.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
901 (let (out)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
902 (while (not (nnir-imap-end-of-input))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
903 (push (nnir-imap-next-expr) out))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
904 (reverse out))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
905
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
906
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
907 (defun nnir-imap-next-expr (&optional count)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
908 "Return the next expression from the current buffer."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
909 (let ((term (nnir-imap-next-term count))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
910 (next (nnir-imap-peek-symbol)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
911 ;; Are we looking at an 'or' expression?
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
912 (cond
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
913 ;; Handle 'expr or expr'
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
914 ((eq next 'or)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
915 (list 'or term (nnir-imap-next-expr 2)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
916 ;; Anything else
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
917 (t term))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
918
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
919
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
920 (defun nnir-imap-next-term (&optional count)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
921 "Return the next TERM from the current buffer."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
922 (let ((term (nnir-imap-next-symbol count)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
923 ;; What sort of term is this?
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
924 (cond
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
925 ;; and -- just ignore it
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
926 ((eq term 'and) 'and)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
927 ;; negated term
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
928 ((eq term 'not) (list 'not (nnir-imap-next-expr)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
929 ;; generic term
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
930 (t term))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
931
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
932
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
933 (defun nnir-imap-peek-symbol ()
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
934 "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
935 (save-excursion
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
936 (nnir-imap-next-symbol)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
937
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
938 (defun nnir-imap-next-symbol (&optional count)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
939 "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
940 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
941 returning the one at the supplied position."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
942 (when (and (numberp count) (> count 1))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
943 (nnir-imap-next-symbol (1- count)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
944 (let ((case-fold-search t))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
945 ;; end of input stream?
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
946 (unless (nnir-imap-end-of-input)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
947 ;; No, return the next symbol from the stream.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
948 (cond
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
949 ;; negated expression -- return it and advance one char.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
950 ((looking-at "-") (forward-char 1) 'not)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
951 ;; quoted string
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
952 ((looking-at "\"") (nnir-imap-delimited-string "\""))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
953 ;; 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
954 ((looking-at "(")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
955 (nnir-imap-parse-query (nnir-imap-delimited-string ")")))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
956 ;; keyword input -- return a symbol version
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
957 ((looking-at "\\band\\b") (forward-char 3) 'and)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
958 ((looking-at "\\bor\\b") (forward-char 2) 'or)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
959 ((looking-at "\\bnot\\b") (forward-char 3) 'not)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
960 ;; Simple, boring keyword
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
961 (t (let ((start (point))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
962 (end (if (search-forward-regexp "[[:blank:]]" nil t)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
963 (prog1
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
964 (match-beginning 0)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
965 ;; unskip if we hit a non-blank terminal character.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
966 (when (string-match "[^[:blank:]]" (match-string 0))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
967 (backward-char 1)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
968 (goto-char (point-max)))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
969 (buffer-substring start end)))))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
970
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
971 (defun nnir-imap-delimited-string (delimiter)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
972 "Return a delimited string from the current buffer."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
973 (let ((start (point)) end)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
974 (forward-char 1) ; skip the first delimiter.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
975 (while (not end)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
976 (unless (search-forward delimiter nil t)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
977 (error "Unmatched delimited input with %s in query" delimiter))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
978 (let ((here (point)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
979 (unless (equal (buffer-substring (- here 2) (- here 1)) "\\")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
980 (setq end (point)))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
981 (buffer-substring (1+ start) (1- end))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
982
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
983 (defun nnir-imap-end-of-input ()
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
984 "Are we at the end of input?"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
985 (skip-chars-forward "[[:blank:]]")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
986 (looking-at "$"))
95616
49755ce71b9e Formatting fixes.
Glenn Morris <rgm@gnu.org>
parents: 95610
diff changeset
987
95610
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 ;; Swish++ interface.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
990 ;; -cc- Todo
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
991 ;; Search by
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
992 ;; - group
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
993 ;; Sort by
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
994 ;; - rank (default)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
995 ;; - article number
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
996 ;; - file size
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
997 ;; - group
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
998 (defun nnir-run-swish++ (query server &optional group)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
999 "Run QUERY against swish++.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1000 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
1001 actually).
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1002
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1003 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
1004 Windows NT 4.0."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1005
111245
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1006 ;; (when group
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1007 ;; (error "The swish++ backend cannot search specific groups"))
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1008
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1009 (save-excursion
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1010 (let ( (qstring (cdr (assq 'query query)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1011 (groupspec (cdr (assq 'group query)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1012 (prefix (nnir-read-server-parm 'nnir-swish++-remove-prefix server))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1013 artlist
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1014 ;; 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
1015 ;; 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
1016 ;; nnml-use-compressed-files because old articles might have been
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1017 ;; saved with a different value.
110666
3b9bd3888ee9 nnimap.el (nnimap-request-accept-article): Get the Message-ID without the \r.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110661
diff changeset
1018 (article-pattern (if (string= (gnus-group-server server) "nnmaildir")
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1019 ":[0-9]+"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1020 "^[0-9]+\\(\\.[a-z0-9]+\\)?$"))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1021 score artno dirnam filenam)
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 (when (equal "" qstring)
105167
e14dfafc8256 * gnus-art.el (gnus-article-encrypt-body):
Juanma Barranquero <lekktu@gmail.com>
parents: 104700
diff changeset
1024 (error "swish++: You didn't enter anything"))
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1025
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1026 (set-buffer (get-buffer-create nnir-tmp-buffer))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1027 (erase-buffer)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1028
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1029 (if groupspec
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1030 (message "Doing swish++ query %s on %s..." qstring groupspec)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1031 (message "Doing swish++ query %s..." qstring))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1032
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1033 (let* ((cp-list `( ,nnir-swish++-program
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1034 nil ; input from /dev/null
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1035 t ; output
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1036 nil ; don't redisplay
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1037 "--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
1038 ,@(nnir-read-server-parm 'nnir-swish++-additional-switches server)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1039 ,qstring ; the query, in swish++ format
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1040 ))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1041 (exitstatus
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1042 (progn
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1043 (message "%s args: %s" nnir-swish++-program
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1044 (mapconcat 'identity (cddddr cp-list) " ")) ;; ???
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1045 (apply 'call-process cp-list))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1046 (unless (or (null exitstatus)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1047 (zerop exitstatus))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1048 (nnheader-report 'nnir "Couldn't run swish++: %s" exitstatus)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1049 ;; swish++ failure reason is in this buffer, show it if
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1050 ;; the user wants it.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1051 (when (> gnus-verbose 6)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1052 (display-buffer nnir-tmp-buffer))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1053
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1054 ;; The results are output in the format of:
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1055 ;; V 4.7 Linux
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1056 ;; rank relative-path-name file-size file-title
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1057 ;; V 5.0b2:
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1058 ;; rank relative-path-name file-size topic??
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1059 ;; where rank is an integer from 1 to 100.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1060 (goto-char (point-min))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1061 (while (re-search-forward
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1062 "\\(^[0-9]+\\) \\([^ ]+\\) [0-9]+ \\(.*\\)$" nil t)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1063 (setq score (match-string 1)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1064 filenam (match-string 2)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1065 artno (file-name-nondirectory filenam)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1066 dirnam (file-name-directory filenam))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1067
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1068 ;; don't match directories
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1069 (when (string-match article-pattern artno)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1070 (when (not (null dirnam))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1071
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1072 ;; maybe limit results to matching groups.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1073 (when (or (not groupspec)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1074 (string-match groupspec dirnam))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1075 (nnir-add-result dirnam artno score prefix server artlist)))))
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 (message "Massaging swish++ output...done")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1078
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1079 ;; Sort by score
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1080 (apply 'vector
104584
f540e84a920d (top-level): Don't require cl at run-time.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
1081 (sort artlist
f540e84a920d (top-level): Don't require cl at run-time.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
1082 (function (lambda (x y)
f540e84a920d (top-level): Don't require cl at run-time.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
1083 (> (nnir-artitem-rsv x)
f540e84a920d (top-level): Don't require cl at run-time.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
1084 (nnir-artitem-rsv y)))))))))
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1085
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1086 ;; Swish-E interface.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1087 (defun nnir-run-swish-e (query server &optional group)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1088 "Run given query against swish-e.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1089 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
1090 actually).
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1091
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1092 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
1093
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1094 ;; swish-e crashes with empty parameter to "-w" on commandline...
111245
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1095 ;; (when group
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1096 ;; (error "The swish-e backend cannot search specific groups"))
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1097
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1098 (save-excursion
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1099 (let ((qstring (cdr (assq 'query query)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1100 (prefix
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1101 (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
1102 (error "Missing parameter `nnir-swish-e-remove-prefix'")))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1103 artlist score artno dirnam group )
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1104
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1105 (when (equal "" qstring)
105167
e14dfafc8256 * gnus-art.el (gnus-article-encrypt-body):
Juanma Barranquero <lekktu@gmail.com>
parents: 104700
diff changeset
1106 (error "swish-e: You didn't enter anything"))
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1107
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1108 (set-buffer (get-buffer-create nnir-tmp-buffer))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1109 (erase-buffer)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1110
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1111 (message "Doing swish-e query %s..." query)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1112 (let* ((index-files
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1113 (or (nnir-read-server-parm
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1114 'nnir-swish-e-index-files server)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1115 (error "Missing parameter `nnir-swish-e-index-files'")))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1116 (additional-switches
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1117 (nnir-read-server-parm
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1118 'nnir-swish-e-additional-switches server))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1119 (cp-list `(,nnir-swish-e-program
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1120 nil ; input from /dev/null
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1121 t ; output
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1122 nil ; don't redisplay
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1123 "-f" ,@index-files
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1124 ,@additional-switches
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1125 "-w"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1126 ,qstring ; the query, in swish-e format
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 (exitstatus
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1129 (progn
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1130 (message "%s args: %s" nnir-swish-e-program
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1131 (mapconcat 'identity (cddddr cp-list) " "))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1132 (apply 'call-process cp-list))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1133 (unless (or (null exitstatus)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1134 (zerop exitstatus))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1135 (nnheader-report 'nnir "Couldn't run swish-e: %s" exitstatus)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1136 ;; 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
1137 ;; the user wants it.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1138 (when (> gnus-verbose 6)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1139 (display-buffer nnir-tmp-buffer))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1140
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1141 ;; The results are output in the format of:
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1142 ;; rank path-name file-title file-size
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1143 (goto-char (point-min))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1144 (while (re-search-forward
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1145 "\\(^[0-9]+\\) \\([^ ]+\\) \"\\([^\"]+\\)\" [0-9]+$" nil t)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1146 (setq score (match-string 1)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1147 artno (match-string 3)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1148 dirnam (file-name-directory (match-string 2)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1149
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1150 ;; don't match directories
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1151 (when (string-match "^[0-9]+$" artno)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1152 (when (not (null dirnam))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1153
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1154 ;; remove nnir-swish-e-remove-prefix from beginning of dirname
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1155 (when (string-match (concat "^" prefix) dirnam)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1156 (setq dirnam (replace-match "" t t dirnam)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1157
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1158 (setq dirnam (substring dirnam 0 -1))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1159 ;; eliminate all ".", "/", "\" from beginning. Always matches.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1160 (string-match "^[./\\]*\\(.*\\)$" dirnam)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1161 ;; "/" -> "."
104584
f540e84a920d (top-level): Don't require cl at run-time.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
1162 (setq group (gnus-replace-in-string (match-string 1 dirnam) "/" "."))
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1163 ;; Windows "\\" -> "."
104584
f540e84a920d (top-level): Don't require cl at run-time.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
1164 (setq group (gnus-replace-in-string group "\\\\" "."))
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1165
111789
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1166 (push (vector (gnus-group-full-name group server)
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1167 (string-to-number artno)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1168 (string-to-number score))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1169 artlist))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1170
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1171 (message "Massaging swish-e output...done")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1172
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1173 ;; Sort by score
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1174 (apply 'vector
104584
f540e84a920d (top-level): Don't require cl at run-time.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
1175 (sort artlist
f540e84a920d (top-level): Don't require cl at run-time.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
1176 (function (lambda (x y)
f540e84a920d (top-level): Don't require cl at run-time.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
1177 (> (nnir-artitem-rsv x)
f540e84a920d (top-level): Don't require cl at run-time.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
1178 (nnir-artitem-rsv y)))))))))
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1179
111245
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1180 ;; HyREX interface
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1181 (defun nnir-run-hyrex (query server &optional group)
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1182 (save-excursion
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1183 (let ((artlist nil)
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1184 (groupspec (cdr (assq 'group query)))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1185 (qstring (cdr (assq 'query query)))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1186 (prefix (nnir-read-server-parm 'nnir-hyrex-remove-prefix server))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1187 score artno dirnam)
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1188 (when (and (not groupspec) group)
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1189 (setq groupspec
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1190 (regexp-opt
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1191 (mapcar (lambda (x) (gnus-group-real-name x)) group))))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1192 (set-buffer (get-buffer-create nnir-tmp-buffer))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1193 (erase-buffer)
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1194 (message "Doing hyrex-search query %s..." query)
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1195 (let* ((cp-list
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1196 `( ,nnir-hyrex-program
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1197 nil ; input from /dev/null
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1198 t ; output
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1199 nil ; don't redisplay
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1200 "-i",(nnir-read-server-parm 'nnir-hyrex-index-directory server) ; index directory
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1201 ,@(nnir-read-server-parm 'nnir-hyrex-additional-switches server)
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1202 ,qstring ; the query, in hyrex-search format
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1203 ))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1204 (exitstatus
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1205 (progn
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1206 (message "%s args: %s" nnir-hyrex-program
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1207 (mapconcat 'identity (cddddr cp-list) " "))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1208 (apply 'call-process cp-list))))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1209 (unless (or (null exitstatus)
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1210 (zerop exitstatus))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1211 (nnheader-report 'nnir "Couldn't run hyrex-search: %s" exitstatus)
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1212 ;; nnir-search failure reason is in this buffer, show it if
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1213 ;; the user wants it.
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1214 (when (> gnus-verbose 6)
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1215 (display-buffer nnir-tmp-buffer)))) ;; FIXME: Dont clear buffer !
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1216 (message "Doing hyrex-search query \"%s\"...done" qstring)
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1217 (sit-for 0)
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1218 ;; nnir-search returns:
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1219 ;; for nnml/nnfolder: "filename mailid weigth"
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1220 ;; for nnimap: "group mailid weigth"
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1221 (goto-char (point-min))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1222 (delete-non-matching-lines "^\\S + [0-9]+ [0-9]+$")
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1223 ;; HyREX doesn't search directly in groups -- so filter out here.
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1224 (when groupspec
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1225 (keep-lines groupspec))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1226 ;; extract data from result lines
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1227 (goto-char (point-min))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1228 (while (re-search-forward
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1229 "\\(\\S +\\) \\([0-9]+\\) \\([0-9]+\\)" nil t)
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1230 (setq dirnam (match-string 1)
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1231 artno (match-string 2)
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1232 score (match-string 3))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1233 (when (string-match prefix dirnam)
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1234 (setq dirnam (replace-match "" t t dirnam)))
111789
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1235 (push (vector (gnus-group-full-name
111245
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1236 (gnus-replace-in-string dirnam "/" ".") server)
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1237 (string-to-number artno)
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1238 (string-to-number score))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1239 artlist))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1240 (message "Massaging hyrex-search output...done.")
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1241 (apply 'vector
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1242 (sort artlist
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1243 (function (lambda (x y)
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1244 (if (string-lessp (nnir-artitem-group x)
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1245 (nnir-artitem-group y))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1246 t
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1247 (< (nnir-artitem-number x)
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1248 (nnir-artitem-number y)))))))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1249 )))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1250
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1251 ;; Namazu interface
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1252 (defun nnir-run-namazu (query server &optional group)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1253 "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
1254 pairs (also vectors, actually).
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1255
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1256 Tested with Namazu 2.0.6 on a GNU/Linux system."
111245
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1257 ;; (when group
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1258 ;; (error "The Namazu backend cannot search specific groups"))
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1259 (save-excursion
110666
3b9bd3888ee9 nnimap.el (nnimap-request-accept-article): Get the Message-ID without the \r.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110661
diff changeset
1260 (let ((article-pattern (if (string= (gnus-group-server server) "nnmaildir")
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1261 ":[0-9]+"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1262 "^[0-9]+$"))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1263 artlist
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1264 (qstring (cdr (assq 'query query)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1265 (prefix (nnir-read-server-parm 'nnir-namazu-remove-prefix server))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1266 score group article
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1267 (process-environment (copy-sequence process-environment)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1268 (setenv "LC_MESSAGES" "C")
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1269 (set-buffer (get-buffer-create nnir-tmp-buffer))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1270 (erase-buffer)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1271 (let* ((cp-list
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1272 `( ,nnir-namazu-program
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1273 nil ; input from /dev/null
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1274 t ; output
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1275 nil ; don't redisplay
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1276 "-q" ; don't be verbose
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1277 "-a" ; show all matches
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1278 "-s" ; use short format
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1279 ,@(nnir-read-server-parm 'nnir-namazu-additional-switches server)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1280 ,qstring ; the query, in namazu format
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1281 ,(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
1282 ))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1283 (exitstatus
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1284 (progn
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1285 (message "%s args: %s" nnir-namazu-program
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1286 (mapconcat 'identity (cddddr cp-list) " "))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1287 (apply 'call-process cp-list))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1288 (unless (or (null exitstatus)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1289 (zerop exitstatus))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1290 (nnheader-report 'nnir "Couldn't run namazu: %s" exitstatus)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1291 ;; Namazu failure reason is in this buffer, show it if
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1292 ;; the user wants it.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1293 (when (> gnus-verbose 6)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1294 (display-buffer nnir-tmp-buffer))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1295
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1296 ;; Namazu output looks something like this:
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1297 ;; 2. Re: Gnus agent expire broken (score: 55)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1298 ;; /home/henrik/Mail/mail/sent/1310 (4,138 bytes)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1299
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]+\\.\\).*\\((score: \\([0-9]+\\)\\))\n\\([^ ]+\\)"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1303 nil t)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1304 (setq score (match-string 3)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1305 group (file-name-directory (match-string 4))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1306 article (file-name-nondirectory (match-string 4)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1307
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1308 ;; make sure article and group is sane
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1309 (when (and (string-match article-pattern article)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1310 (not (null group)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1311 (nnir-add-result group article score prefix server artlist)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1312
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1313 ;; sort artlist by score
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1314 (apply 'vector
104584
f540e84a920d (top-level): Don't require cl at run-time.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
1315 (sort artlist
f540e84a920d (top-level): Don't require cl at run-time.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
1316 (function (lambda (x y)
f540e84a920d (top-level): Don't require cl at run-time.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
1317 (> (nnir-artitem-rsv x)
f540e84a920d (top-level): Don't require cl at run-time.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
1318 (nnir-artitem-rsv y)))))))))
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1319
111245
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1320 (defun nnir-run-find-grep (query server &optional grouplist)
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1321 "Run find and grep to obtain matching articles."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1322 (let* ((method (gnus-server-to-method server))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1323 (sym (intern
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1324 (concat (symbol-name (car method)) "-directory")))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1325 (directory (cadr (assoc sym (cddr method))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1326 (regexp (cdr (assoc 'query query)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1327 (grep-options (cdr (assoc 'grep-options query)))
111789
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1328 (grouplist (or grouplist (nnir-get-active server)))
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1329 artlist)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1330 (unless directory
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1331 (error "No directory found in method specification of server %s"
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1332 server))
111245
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1333 (apply
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1334 'vconcat
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1335 (mapcar (lambda (x)
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1336 (let ((group x))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1337 (message "Searching %s using find-grep..."
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1338 (or group server))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1339 (save-window-excursion
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1340 (set-buffer (get-buffer-create nnir-tmp-buffer))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1341 (erase-buffer)
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1342 (if (> gnus-verbose 6)
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1343 (pop-to-buffer (current-buffer)))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1344 (cd directory) ; Using relative paths simplifies
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1345 ; postprocessing.
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1346 (let ((group
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1347 (if (not group)
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1348 "."
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1349 ;; Try accessing the group literally as
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1350 ;; well as interpreting dots as directory
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1351 ;; separators so the engine works with
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1352 ;; plain nnml as well as the Gnus Cache.
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1353 (let ((group (gnus-group-real-name group)))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1354 ;; Replace cl-func find-if.
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1355 (if (file-directory-p group)
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1356 group
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1357 (if (file-directory-p
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1358 (setq group
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1359 (gnus-replace-in-string
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1360 group
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1361 "\\." "/" t)))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1362 group))))))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1363 (unless group
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1364 (error "Cannot locate directory for group"))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1365 (save-excursion
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1366 (apply
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1367 'call-process "find" nil t
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1368 "find" group "-type" "f" "-name" "[0-9]*" "-exec"
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1369 "grep"
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1370 `("-l" ,@(and grep-options
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1371 (split-string grep-options "\\s-" t))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1372 "-e" ,regexp "{}" "+"))))
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1373
111245
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1374 ;; Translate relative paths to group names.
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1375 (while (not (eobp))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1376 (let* ((path (split-string
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1377 (buffer-substring
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1378 (point)
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1379 (line-end-position)) "/" t))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1380 (art (string-to-number (car (last path)))))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1381 (while (string= "." (car path))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1382 (setq path (cdr path)))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1383 (let ((group (mapconcat 'identity
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1384 ;; Replace cl-func:
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1385 ;; (subseq path 0 -1)
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1386 (let ((end (1- (length path)))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1387 res)
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1388 (while
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1389 (>= (setq end (1- end)) 0)
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1390 (push (pop path) res))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1391 (nreverse res))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1392 ".")))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1393 (push
111789
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1394 (vector (gnus-group-full-name group server) art 0)
111245
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1395 artlist))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1396 (forward-line 1)))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1397 (message "Searching %s using find-grep...done"
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1398 (or group server))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1399 artlist)))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1400 grouplist))))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1401
111288
6bc575569d37 Silence nnir.el compilation.
Glenn Morris <rgm@gnu.org>
parents: 111269
diff changeset
1402 (declare-function mm-url-insert "mm-url" (url &optional follow-refresh))
6bc575569d37 Silence nnir.el compilation.
Glenn Morris <rgm@gnu.org>
parents: 111269
diff changeset
1403 (declare-function mm-url-encode-www-form-urlencoded "mm-url" (pairs))
6bc575569d37 Silence nnir.el compilation.
Glenn Morris <rgm@gnu.org>
parents: 111269
diff changeset
1404
111245
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1405 ;; gmane interface
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1406 (defun nnir-run-gmane (query srv &optional groups)
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1407 "Run a search against a gmane back-end server."
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1408 (let* ((case-fold-search t)
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1409 (qstring (cdr (assq 'query query)))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1410 (server (cadr (gnus-server-to-method srv)))
111852
7b4048d45603 nnir.el (nnir-retrieve-headers): Use rassq when comparing article ids.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111843
diff changeset
1411 (groupspec (mapconcat
7b4048d45603 nnir.el (nnir-retrieve-headers): Use rassq when comparing article ids.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111843
diff changeset
1412 (lambda (x)
111953
9d703d5d5634 nnir.el (nnir-run-gmane): Better check for gmane groups: error out if groupname doesn't contain "gmane".
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111952
diff changeset
1413 (if (gnus-string-match-p "gmane" x)
9d703d5d5634 nnir.el (nnir-run-gmane): Better check for gmane groups: error out if groupname doesn't contain "gmane".
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111952
diff changeset
1414 (format "group:%s" (gnus-group-short-name x))
9d703d5d5634 nnir.el (nnir-run-gmane): Better check for gmane groups: error out if groupname doesn't contain "gmane".
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111952
diff changeset
1415 (error "Can't search non-gmane groups: %s" x)))
9d703d5d5634 nnir.el (nnir-run-gmane): Better check for gmane groups: error out if groupname doesn't contain "gmane".
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111952
diff changeset
1416 groups " "))
111245
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1417 (authorspec
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1418 (if (assq 'author query)
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1419 (format "author:%s" (cdr (assq 'author query))) ""))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1420 (search (format "%s %s %s"
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1421 qstring groupspec authorspec))
111314
1431aee91437 nnir.el: Fix various bugs.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111294
diff changeset
1422 (gnus-inhibit-demon t)
111245
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1423 artlist)
111288
6bc575569d37 Silence nnir.el compilation.
Glenn Morris <rgm@gnu.org>
parents: 111269
diff changeset
1424 (require 'mm-url)
111669
ed117caa918e Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111584
diff changeset
1425 (with-current-buffer (get-buffer-create nnir-tmp-buffer)
111245
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1426 (erase-buffer)
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1427 (mm-url-insert
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1428 (concat
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1429 "http://search.gmane.org/nov.php"
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1430 "?"
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1431 (mm-url-encode-www-form-urlencoded
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1432 `(("query" . ,search)
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1433 ("HITSPERPAGE" . "999")))))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1434 (unless (featurep 'xemacs) (set-buffer-multibyte t))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1435 (mm-decode-coding-region (point-min) (point-max) 'utf-8)
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1436 (goto-char (point-min))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1437 (forward-line 1)
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1438 (while (not (eobp))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1439 (unless (or (eolp) (looking-at "\x0d"))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1440 (let ((header (nnheader-parse-nov)))
111269
3d7a1caabf14 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111245
diff changeset
1441 (let ((xref (mail-header-xref header))
3d7a1caabf14 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111245
diff changeset
1442 (xscore (string-to-number (cdr (assoc 'X-Score
3d7a1caabf14 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111245
diff changeset
1443 (mail-header-extra header))))))
111245
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1444 (when (string-match " \\([^:]+\\)[:/]\\([0-9]+\\)" xref)
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1445 (push
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1446 (vector
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1447 (gnus-group-prefixed-name (match-string 1 xref) srv)
111269
3d7a1caabf14 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111245
diff changeset
1448 (string-to-number (match-string 2 xref)) xscore)
111245
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1449 artlist)))))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1450 (forward-line 1)))
111953
9d703d5d5634 nnir.el (nnir-run-gmane): Better check for gmane groups: error out if groupname doesn't contain "gmane".
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111952
diff changeset
1451 (apply 'vector (nreverse (mm-delete-duplicates artlist)))))
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1452
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1453 ;;; Util Code:
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1454
111245
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1455 (defun nnir-read-parms (query nnir-search-engine)
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1456 "Reads additional search parameters according to `nnir-engines'."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1457 (let ((parmspec (caddr (assoc nnir-search-engine nnir-engines))))
111314
1431aee91437 nnir.el: Fix various bugs.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111294
diff changeset
1458 (append query
111245
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1459 (mapcar 'nnir-read-parm parmspec))))
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1460
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1461 (defun nnir-read-parm (parmspec)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1462 "Reads a single search parameter.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1463 `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
1464 (let ((sym (car parmspec))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1465 (prompt (cdr parmspec)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1466 (if (listp prompt)
110874
7996424ed273 nnir.el (nnir-read-parm): Fix call to gnus-completing-read.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110790
diff changeset
1467 (let* ((result (apply 'gnus-completing-read prompt))
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1468 (mapping (or (assoc result nnir-imap-search-arguments)
110908
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
1469 (cons nil nnir-imap-search-other))))
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1470 (cons sym (format (cdr mapping) result)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1471 (cons sym (read-string prompt)))))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1472
111491
ea2c0f22a4ad * lisp/gnus/nnir.el (gnus-group-topic-name): Autoload.
Glenn Morris <rgm@gnu.org>
parents: 111482
diff changeset
1473 (autoload 'gnus-group-topic-name "gnus-topic")
ea2c0f22a4ad * lisp/gnus/nnir.el (gnus-group-topic-name): Autoload.
Glenn Morris <rgm@gnu.org>
parents: 111482
diff changeset
1474
111269
3d7a1caabf14 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111245
diff changeset
1475 (defun nnir-run-query (query nserver)
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1476 "Invoke appropriate search engine function (see `nnir-engines').
111245
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1477 If some groups were process-marked, run the query for each of the groups
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1478 and concat the results."
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1479 (let ((q (car (read-from-string query)))
111269
3d7a1caabf14 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111245
diff changeset
1480 (groups (if (string= "all-ephemeral" nserver)
3d7a1caabf14 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111245
diff changeset
1481 (with-current-buffer gnus-server-buffer
3d7a1caabf14 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111245
diff changeset
1482 (list (list (gnus-server-server-name))))
111789
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1483 (nnir-categorize
111314
1431aee91437 nnir.el: Fix various bugs.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111294
diff changeset
1484 (or gnus-group-marked
1431aee91437 nnir.el: Fix various bugs.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111294
diff changeset
1485 (if (gnus-group-group-name)
1431aee91437 nnir.el: Fix various bugs.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111294
diff changeset
1486 (list (gnus-group-group-name))
1431aee91437 nnir.el: Fix various bugs.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111294
diff changeset
1487 (cdr (assoc (gnus-group-topic-name)
111789
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1488 gnus-topic-alist))))
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1489 gnus-group-server))))
111245
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1490 (apply 'vconcat
111789
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1491 (mapcar
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1492 (lambda (x)
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1493 (let* ((server (car x))
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1494 (nnir-search-engine
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1495 (or (nnir-read-server-parm 'nnir-search-engine
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1496 server)
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1497 (cdr (assoc (car
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1498 (gnus-server-to-method server))
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1499 nnir-method-default-engines))))
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1500 search-func)
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1501 (setq search-func (cadr (assoc nnir-search-engine
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1502 nnir-engines)))
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1503 (if search-func
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1504 (funcall search-func
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1505 (if nnir-extra-parms
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1506 (nnir-read-parms q nnir-search-engine)
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1507 q)
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1508 server (cadr x))
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1509 nil)))
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1510 groups))))
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1511
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1512 (defun nnir-read-server-parm (key server)
111245
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1513 "Returns the parameter value of key for the given server, where
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1514 server is of form 'backend:name'."
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1515 (let ((method (gnus-server-to-method server)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1516 (cond ((and method (assq key (cddr method)))
111245
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1517 (nth 1 (assq key (cddr method))))
dd1304e89176 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111217
diff changeset
1518 (t nil))))
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1519
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1520 (defun nnir-possibly-change-server (server)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1521 (unless (and server (nnir-server-opened server))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1522 (nnir-open-server server)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1523
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1524
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 ;; unused?
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1527 (defun nnir-artlist-groups (artlist)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1528 "Returns a list of all groups in the given ARTLIST."
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1529 (let ((res nil)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1530 (with-dups nil))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1531 ;; from each artitem, extract group component
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1532 (setq with-dups (mapcar 'nnir-artitem-group artlist))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1533 ;; remove duplicates from above
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1534 (mapc (function (lambda (x) (add-to-list 'res x)))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1535 with-dups)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1536 res))
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1537
111269
3d7a1caabf14 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111245
diff changeset
1538 (defun nnir-get-active (srv)
3d7a1caabf14 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111245
diff changeset
1539 (let ((method (gnus-server-to-method srv))
3d7a1caabf14 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111245
diff changeset
1540 groups)
3d7a1caabf14 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111245
diff changeset
1541 (gnus-request-list method)
3d7a1caabf14 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111245
diff changeset
1542 (with-current-buffer nntp-server-buffer
3d7a1caabf14 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111245
diff changeset
1543 (let ((cur (current-buffer))
3d7a1caabf14 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111245
diff changeset
1544 name)
3d7a1caabf14 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111245
diff changeset
1545 (goto-char (point-min))
111789
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1546 (unless (string= nnir-ignored-newsgroups "")
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1547 (delete-matching-lines nnir-ignored-newsgroups))
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1548 (if (eq (car method) 'nntp)
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1549 (while (not (eobp))
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1550 (ignore-errors
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1551 (push (mm-string-as-unibyte
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1552 (gnus-group-full-name
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1553 (buffer-substring
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1554 (point)
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1555 (progn
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1556 (skip-chars-forward "^ \t")
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1557 (point))) method))
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1558 groups))
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1559 (forward-line))
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1560 (while (not (eobp))
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1561 (ignore-errors
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1562 (push (mm-string-as-unibyte
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1563 (if (eq (char-after) ?\")
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1564 (gnus-group-full-name (read cur) method)
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1565 (let ((p (point)) (name ""))
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1566 (skip-chars-forward "^ \t\\\\")
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1567 (setq name (buffer-substring p (point)))
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1568 (while (eq (char-after) ?\\)
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1569 (setq p (1+ (point)))
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1570 (forward-char 2)
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1571 (skip-chars-forward "^ \t\\\\")
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1572 (setq name (concat name (buffer-substring
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1573 p (point)))))
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1574 (gnus-group-full-name name method))))
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1575 groups))
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1576 (forward-line)))))
111269
3d7a1caabf14 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111245
diff changeset
1577 groups))
3d7a1caabf14 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111245
diff changeset
1578
111789
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1579 (defun nnir-registry-action (action data-header from &optional to method)
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1580 "Call `gnus-registry-action' with the original article group."
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1581 (gnus-registry-action
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1582 action
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1583 data-header
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1584 (nnir-article-group (mail-header-number data-header))
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1585 to
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1586 method))
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1587
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1588 (defun nnir-mode ()
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1589 (when (eq (car (gnus-find-method-for-group gnus-newsgroup-name)) 'nnir)
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1590 (setq gnus-summary-line-format
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1591 (or nnir-summary-line-format gnus-summary-line-format))
111963
44431106d60d nnir.el (nnir-mode): Don't install registry hooks if user hasn't installed the registry.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111953
diff changeset
1592 (when (eq gnus-registry-install t)
44431106d60d nnir.el (nnir-mode): Don't install registry hooks if user hasn't installed the registry.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111953
diff changeset
1593 (remove-hook 'gnus-summary-article-delete-hook 'gnus-registry-action t)
44431106d60d nnir.el (nnir-mode): Don't install registry hooks if user hasn't installed the registry.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111953
diff changeset
1594 (remove-hook 'gnus-summary-article-move-hook 'gnus-registry-action t)
44431106d60d nnir.el (nnir-mode): Don't install registry hooks if user hasn't installed the registry.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111953
diff changeset
1595 (remove-hook 'gnus-summary-article-expire-hook 'gnus-registry-action t)
44431106d60d nnir.el (nnir-mode): Don't install registry hooks if user hasn't installed the registry.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111953
diff changeset
1596 (add-hook 'gnus-summary-article-delete-hook 'nnir-registry-action t t)
44431106d60d nnir.el (nnir-mode): Don't install registry hooks if user hasn't installed the registry.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111953
diff changeset
1597 (add-hook 'gnus-summary-article-move-hook 'nnir-registry-action t t)
44431106d60d nnir.el (nnir-mode): Don't install registry hooks if user hasn't installed the registry.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111953
diff changeset
1598 (add-hook 'gnus-summary-article-expire-hook 'nnir-registry-action t t))))
111789
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1599
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1600
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111669
diff changeset
1601
95610
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1602 ;; The end.
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1603 (provide 'nnir)
cb95dadcb2de Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1604
95616
49755ce71b9e Formatting fixes.
Glenn Morris <rgm@gnu.org>
parents: 95610
diff changeset
1605 ;;; nnir.el ends here