Mercurial > emacs
annotate lisp/gnus/nnir.el @ 111789:f97704487fb3
Merge changes made in Gnus trunk.
nnir.el: Batch header retrieval.
proto-stream.el: New library to provide protocol-specific TLS/STARTTLS connections for IMAP, NNTP, SMTP, POP3 and similar protocols.
nnimap.el (nnimap-open-connection): Use it.
proto-stream.el (open-proto-stream): Complete the documentation.
nnimap.el (nnimap-open-connection): Check for "OK" from the greeting.
nntp.el: Use proto-streams for the relevant connections types.
nntp.el (nntp-open-connection): Switch on STARTTLS on supported servers.
proto-stream.el (open-proto-stream): Add a way to specify what the end of a command is.
proto-stream.el (proto-stream-open-tls): Delete output from openssl if we're using tls.el.
proto-stream.el (proto-stream-open-network): If we don't have gnutls-cli or gnutls built in, then don't try to establish a STARTTLS connection.
color.el (color-lab->srgb): Fix function call name.
proto-stream.el: Fix the syntax in the comment.
nntp.el (nntp-open-connection): Fix the STARTTLS command syntax.
proto-stream.el (proto-stream-open-starttls): Actually implement the starttls.el STARTTLS.
proto-stream.el (proto-stream-always-use-starttls): New variable.
proto-stream.el (proto-stream-open-starttls): De-duplicate the starttls code.
proto-stream.el (proto-stream-open-starttls): Folded back into the main function.
proto-stream.el (proto-stream-command): Refactor out.
nnimap.el (nnimap-stream): Change default to `undecided'.
nnimap.el (nnimap-open-connection): If `nnimap-stream' is `undecided', try ssl first, and then network.
nnimap.el (nnimap-open-connection-1): Respect nnimap-server-port.
nnimap.el (nnimap-open-connection): Be more backwards-compatible.
proto-stream.el (open-protocol-stream): Renamed from open-proto-stream.
proto-stream.el (proto-stream-open-network): When doing opportunistic TLS upgrades we don't really care about the identity of the peer.
gnus.texi (Customizing the IMAP Connection): Note the new defaults.
gnus.texi (Direct Functions): Note the STARTTLS upgrade.
proto-stream.el (proto-stream-open-network): Force starttls.el to use gnutls-cli, since that what we've checked for.
proto-stream.el (proto-stream-always-use-starttls): Only default to t if open-gnutls-stream exists.
proto-stream.el (proto-stream-open-network): If STARTTLS failed, then just open a normal connection.
proto-stream.el (proto-stream-open-network): Wait until the greeting before doing STARTTLS.
nnimap.el (nnimap-open-connection-1): Always upgrade to STARTTLS (for backwards compatibility).
nnimap.el (nnimap-open-connection-1): Really respect nnimap-server-port.
nntp.el (nntp-open-connection): Provide a :success condition.
nnimap.el (nnimap-open-connection-1): Ditto.
proto-stream.el (proto-stream-open-network): See what the response to the STARTTLS command is.
proto-stream.el (proto-stream-open-network): Add some comments.
proto-stream.el: Fix example.
proto-stream.el (open-protocol-stream): Actually mention the STARTTLS upgrade.
nnir.el (nnir-get-active): Skip nnir-ignored-newsgroups when searching.
nnir.el (nnir-ignore-newsgroups): Fix default value.
nnir.el (nnir-run-gmane): Use mm-delete-duplicates instead of delete-dups that is not available in XEmacs 21.4.
mm-util.el (mm-delete-duplicates): Add comment.
gnus-sum.el (gnus-summary-delete-article): If delete fails don't change the registry.
nnimap.el (nnimap-open-connection-1): w32 open-network-stream doesn't seem to accept strings-with-numbers as port numbers.
color.el: fix docstring to use English rather than math notation for intervals.
shr.el (shr-find-fill-point): Don't break before apostrophes.
nnir.el (nnir-request-move-article): Bail out if no move support in group.
color.el (color-rgb->hsv): Fix docstring.
nnir.el (nnir-get-active): Improve active list retrieval.
shr.el (shr-find-fill-point): Work better for kinsoku chars and apostrophes.
gnus-gravatar.el (gnus-gravatar-size): Set gnus-gravatar-size to nil.
nnimap.el (nnimap-open-connection-1): Use gnus-string-match-p.
nnimap.el (nnimap-open-connection-1): Fix PREAUTH.
proto-stream.el (open-protocol-stream): All starttls connections are handled by the network handler.
gnus-gravatar.el (gnus-gravatar-insert): Delete unnecessary binding to t of inhibit-read-only since it is inside gnus-with-article-headers.
gnus-gravatar.el (gnus-gravatar-transform-address): Use mail-extract-address-components that supports non-ASCII names rather than mail-header-parse-addresses.
shr.el (shr-find-fill-point): Don't break line between kinsoku-bol characters.
gnus-gravatar.el (gnus-gravatar-insert): Allow LWSP in the middle of names.
nnmaildir.el (nnmaildir-request-set-mark): Add article to add-mark funcall.
gnus-msg.el: Remove nastygram thing.
message.el (message-from-style): Fix comment.
message.el (message-user-organization): Do not use gnus-local-organization.
gnus.el: Remove gnus-local-organization.
rtree.el: New file to handle range trees.
nnir.el, gnus-sum.el: Redo the way nnir handles registry updates.
rtree.el (rtree-extract): Simplify.
gnus-win.el (gnus-configure-windows): Remove Gnus 3.x setting support.
gnus-msg.el: Mark gnus-outgoing-message-group as obsolete.
gnus.texi (Archived Messages): Remove gnus-outgoing-message-group.
gnus-win.el (gnus-configure-frame): Remove old compatibility code.
rtree.el (rtree-memq): Rewrite it as a non-recursive function.
rtree.el (rtree-add, rtree-delq, rtree-length): Implement.
rtree.el (rtree-add): Make code slightly faster.
nnir.el: Allow modified summary-line-format in nnir summary buffers.
author | Katsumi Yamaoka <yamaoka@jpl.org> |
---|---|
date | Thu, 02 Dec 2010 22:21:31 +0000 |
parents | ed117caa918e |
children | 5e488dbb17f7 |
rev | line source |
---|---|
95610 | 1 ;;; nnir.el --- search mail with various search engines -*- coding: iso-8859-1 -*- |
2 | |
95616 | 3 ;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, |
106815 | 4 ;; 2007, 2008, 2009, 2010 Free Software Foundation, Inc. |
95610 | 5 |
6 ;; Author: Kai Großjohann <grossjohann@ls6.cs.uni-dortmund.de> | |
7 ;; Swish-e and Swish++ backends by: | |
8 ;; Christoph Conrad <christoph.conrad@gmx.de>. | |
9 ;; IMAP backend by: Simon Josefsson <jas@pdc.kth.se>. | |
10 ;; IMAP search by: Torsten Hilbrich <torsten.hilbrich <at> gmx.net> | |
11 ;; IMAP search improved by Daniel Pittman <daniel@rimspace.net>. | |
12 ;; nnmaildir support for Swish++ and Namazu backends by: | |
13 ;; Justus Piater <Justus <at> Piater.name> | |
95616 | 14 ;; Keywords: news mail searching ir |
15 | |
16 ;; This file is part of GNU Emacs. | |
17 | |
18 ;; GNU Emacs is free software: you can redistribute it and/or modify | |
19 ;; it under the terms of the GNU General Public License as published by | |
20 ;; the Free Software Foundation, either version 3 of the License, or | |
21 ;; (at your option) any later version. | |
22 | |
23 ;; GNU Emacs is distributed in the hope that it will be useful, | |
24 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
25 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
26 ;; GNU General Public License for more details. | |
27 | |
28 ;; You should have received a copy of the GNU General Public License | |
29 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | |
30 | |
31 ;;; Commentary: | |
95610 | 32 |
33 ;; TODO: Documentation in the Gnus manual | |
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 | 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 | 42 |
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 | 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 | 50 ;; search engine. You can define the variables in the server definition |
51 ;; like this : | |
52 ;; (setq gnus-secondary-select-methods '( | |
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 | 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 | 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 | 63 |
111245
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
64 ;; 1. Namazu |
95610 | 65 ;; |
66 ;; The Namazu backend requires you to have one directory containing all | |
67 ;; index files, this is controlled by the `nnir-namazu-index-directory' | |
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 | 70 ;; above. |
71 ;; | |
72 ;; It is particularly important not to pass any any switches to namazu | |
73 ;; that will change the output format. Good switches to use include | |
74 ;; `--sort', `--ascending', `--early' and `--late'. Refer to the Namazu | |
75 ;; documentation for further information on valid switches. | |
76 ;; | |
77 ;; To index my mail with the `mknmz' program I use the following | |
78 ;; configuration file: | |
79 ;; | |
80 ;; ,---- | |
81 ;; | package conf; # Don't remove this line! | |
82 ;; | | |
83 ;; | # Paths which will not be indexed. Don't use `^' or `$' anchors. | |
84 ;; | $EXCLUDE_PATH = "spam|sent"; | |
85 ;; | | |
86 ;; | # Header fields which should be searchable. case-insensitive | |
87 ;; | $REMAIN_HEADER = "from|date|message-id|subject"; | |
88 ;; | | |
89 ;; | # Searchable fields. case-insensitive | |
90 ;; | $SEARCH_FIELD = "from|date|message-id|subject"; | |
91 ;; | | |
92 ;; | # The max length of a word. | |
93 ;; | $WORD_LENG_MAX = 128; | |
94 ;; | | |
95 ;; | # The max length of a field. | |
96 ;; | $MAX_FIELD_LENGTH = 256; | |
97 ;; `---- | |
98 ;; | |
99 ;; My mail is stored in the directories ~/Mail/mail/, ~/Mail/lists/ and | |
100 ;; ~/Mail/archive/, so to index them I go to the directory set in | |
101 ;; `nnir-namazu-index-directory' and issue the following command. | |
102 ;; | |
103 ;; mknmz --mailnews ~/Mail/archive/ ~/Mail/mail/ ~/Mail/lists/ | |
104 ;; | |
105 ;; For maximum searching efficiency I have a cron job set to run this | |
106 ;; command every four hours. | |
107 | |
111245
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
108 ;; 2. find-grep |
95610 | 109 ;; |
110 ;; The find-grep engine simply runs find(1) to locate eligible | |
111 ;; articles and searches them with grep(1). This, of course, is much | |
112 ;; slower than using a proper search engine but OTOH doesn't require | |
113 ;; maintenance of an index and is still faster than using any built-in | |
114 ;; means for searching. The method specification of the server to | |
115 ;; search must include a directory for this engine to work (E.g., | |
116 ;; `nnml-directory'). The tools must be POSIX compliant. GNU Find | |
117 ;; prior to version 4.2.12 (4.2.26 on Linux due to incorrect ARG_MAX | |
118 ;; handling) does not work. | |
119 ;; ,---- | |
120 ;; | ;; find-grep configuration for searching the Gnus Cache | |
121 ;; | | |
122 ;; | (nnml "cache" | |
123 ;; | (nnml-get-new-mail nil) | |
124 ;; | (nnir-search-engine find-grep) | |
125 ;; | (nnml-directory "~/News/cache/") | |
126 ;; | (nnml-active-file "~/News/cache/active")) | |
127 ;; `---- | |
128 | |
129 ;; Developer information: | |
130 | |
131 ;; I have tried to make the code expandable. Basically, it is divided | |
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 | 137 ;; other backend. |
138 | |
139 ;; The interface between the two layers consists of the single | |
140 ;; function `nnir-run-query', which just selects the appropriate | |
141 ;; function for the search engine one is using. The input to | |
142 ;; `nnir-run-query' is a string, representing the query as input by | |
143 ;; the user. The output of `nnir-run-query' is supposed to be a | |
144 ;; vector, each element of which should in turn be a three-element | |
145 ;; vector. The first element should be full group name of the article, | |
146 ;; the second element should be the article number, and the third | |
147 ;; element should be the Retrieval Status Value (RSV) as returned from | |
148 ;; the search engine. An RSV is the score assigned to the document by | |
149 ;; the search engine. For Boolean search engines, the | |
150 ;; RSV is always 1000 (or 1 or 100, or whatever you like). | |
151 | |
152 ;; The sorting order of the articles in the summary buffer created by | |
153 ;; nnir is based on the order of the articles in the above mentioned | |
154 ;; vector, so that's where you can do the sorting you'd like. Maybe | |
155 ;; it would be nice to have a way of displaying the search result | |
156 ;; sorted differently? | |
157 | |
158 ;; So what do you need to do when you want to add another search | |
159 ;; engine? You write a function that executes the query. Temporary | |
160 ;; data from the search engine can be put in `nnir-tmp-buffer'. This | |
161 ;; function should return the list of articles as a vector, as | |
162 ;; described above. Then, you need to register this backend in | |
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 | 165 |
166 ;;; Setup Code: | |
167 | |
111288 | 168 ;; For Emacs <22.2 and XEmacs. |
169 (eval-and-compile | |
170 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r)))) | |
171 | |
95610 | 172 (require 'nnoo) |
173 (require 'gnus-group) | |
174 (require 'gnus-sum) | |
175 (require 'message) | |
176 (require 'gnus-util) | |
104584
f540e84a920d
(top-level): Don't require cl at run-time.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
177 (eval-when-compile |
95610 | 178 (require 'cl)) |
179 | |
110908
2a4bfc24abf0
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110898
diff
changeset
|
180 |
2a4bfc24abf0
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110898
diff
changeset
|
181 (eval-when-compile |
2a4bfc24abf0
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110898
diff
changeset
|
182 (autoload 'nnimap-buffer "nnimap") |
2a4bfc24abf0
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110898
diff
changeset
|
183 (autoload 'nnimap-command "nnimap") |
111789
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
184 (autoload 'nnimap-possibly-change-group "nnimap") |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
185 (autoload 'gnus-registry-action "gnus-registry")) |
110908
2a4bfc24abf0
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110898
diff
changeset
|
186 |
95610 | 187 (nnoo-declare nnir) |
188 (nnoo-define-basics nnir) | |
189 | |
190 (gnus-declare-backend "nnir" 'mail) | |
191 | |
192 | |
193 ;;; User Customizable Variables: | |
194 | |
195 (defgroup nnir nil | |
111245
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
196 "Search groups in Gnus with assorted seach engines." |
95610 | 197 :group 'gnus) |
198 | |
111245
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
199 (defcustom nnir-method-default-engines |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
200 '((nnimap . imap) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
201 (nntp . gmane)) |
111789
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
202 "*Alist of default search engines keyed by server method." |
111245
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
203 :type '(alist) |
95610 | 204 :group 'nnir) |
205 | |
111789
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
206 (defcustom nnir-ignored-newsgroups "" |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
207 "*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
|
208 be skipped when searching." |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
209 :type '(regexp) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
210 :group 'nnir) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
211 |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
212 (defcustom nnir-summary-line-format nil |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
213 "*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
|
214 |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
215 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
|
216 with three items unique to nnir summary buffers: |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
217 |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
218 %Z Search retrieval score value (integer) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
219 %G Article original full group name (string) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
220 %g Article original short group name (string) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
221 |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
222 If nil this will use `gnus-summary-line-format'." |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
223 :type '(regexp) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
224 :group 'nnir) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
225 |
111245
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
226 (defcustom nnir-imap-default-search-key "Whole message" |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
227 "*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
|
228 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
|
229 by default set this to \"Imap\"." |
111245
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
230 :type '(string) |
95610 | 231 :group 'nnir) |
232 | |
233 (defcustom nnir-swish++-configuration-file | |
234 (expand-file-name "~/Mail/swish++.conf") | |
235 "*Configuration file for swish++." | |
236 :type '(file) | |
237 :group 'nnir) | |
238 | |
239 (defcustom nnir-swish++-program "search" | |
240 "*Name of swish++ search executable." | |
241 :type '(string) | |
242 :group 'nnir) | |
243 | |
244 (defcustom nnir-swish++-additional-switches '() | |
245 "*A list of strings, to be given as additional arguments to swish++. | |
246 | |
247 Note that this should be a list. Ie, do NOT use the following: | |
248 (setq nnir-swish++-additional-switches \"-i -w\") ; wrong | |
249 Instead, use this: | |
250 (setq nnir-swish++-additional-switches '(\"-i\" \"-w\"))" | |
251 :type '(repeat (string)) | |
252 :group 'nnir) | |
253 | |
254 (defcustom nnir-swish++-remove-prefix (concat (getenv "HOME") "/Mail/") | |
255 "*The prefix to remove from each file name returned by swish++ | |
256 in order to get a group name (albeit with / instead of .). This is a | |
257 regular expression. | |
258 | |
111245
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
259 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
|
260 that it is for swish++, not Namazu." |
95610 | 261 :type '(regexp) |
262 :group 'nnir) | |
263 | |
264 ;; Swish-E. | |
110790
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110777
diff
changeset
|
265 ;; URL: http://swish-e.org/ |
95610 | 266 ;; Variables `nnir-swish-e-index-file', `nnir-swish-e-program' and |
267 ;; `nnir-swish-e-additional-switches' | |
268 | |
269 (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
|
270 'nnir-swish-e-index-files "Emacs 23.1") |
95610 | 271 (defcustom nnir-swish-e-index-file |
272 (expand-file-name "~/Mail/index.swish-e") | |
273 "*Index file for swish-e. | |
274 This could be a server parameter. | |
275 It is never consulted once `nnir-swish-e-index-files', which should be | |
276 used instead, has been customized." | |
277 :type '(file) | |
278 :group 'nnir) | |
279 | |
280 (defcustom nnir-swish-e-index-files | |
281 (list nnir-swish-e-index-file) | |
282 "*List of index files for swish-e. | |
283 This could be a server parameter." | |
284 :type '(repeat (file)) | |
285 :group 'nnir) | |
286 | |
287 (defcustom nnir-swish-e-program "swish-e" | |
288 "*Name of swish-e search executable. | |
289 This cannot be a server parameter." | |
290 :type '(string) | |
291 :group 'nnir) | |
292 | |
293 (defcustom nnir-swish-e-additional-switches '() | |
294 "*A list of strings, to be given as additional arguments to swish-e. | |
295 | |
296 Note that this should be a list. Ie, do NOT use the following: | |
297 (setq nnir-swish-e-additional-switches \"-i -w\") ; wrong | |
298 Instead, use this: | |
299 (setq nnir-swish-e-additional-switches '(\"-i\" \"-w\")) | |
300 | |
301 This could be a server parameter." | |
302 :type '(repeat (string)) | |
303 :group 'nnir) | |
304 | |
305 (defcustom nnir-swish-e-remove-prefix (concat (getenv "HOME") "/Mail/") | |
306 "*The prefix to remove from each file name returned by swish-e | |
307 in order to get a group name (albeit with / instead of .). This is a | |
308 regular expression. | |
309 | |
111245
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
310 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
|
311 that it is for swish-e, not Namazu. |
95610 | 312 |
313 This could be a server parameter." | |
314 :type '(regexp) | |
315 :group 'nnir) | |
316 | |
111245
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
317 ;; 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
|
318 |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
319 (defcustom nnir-hyrex-program "nnir-search" |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
320 "*Name of the nnir-search executable." |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
321 :type '(string) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
322 :group 'nnir) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
323 |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
324 (defcustom nnir-hyrex-additional-switches '() |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
325 "*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
|
326 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
|
327 (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
|
328 Instead, use this: |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
329 (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
|
330 :type '(repeat (string)) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
331 :group 'nnir) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
332 |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
333 (defcustom nnir-hyrex-index-directory (getenv "HOME") |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
334 "*Index directory for HyREX." |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
335 :type '(directory) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
336 :group 'nnir) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
337 |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
338 (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
|
339 "*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
|
340 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
|
341 |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
342 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
|
343 \"/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
|
344 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
|
345 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
|
346 `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
|
347 arrive at the correct group name, \"mail.misc\"." |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
348 :type '(directory) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
349 :group 'nnir) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
350 |
110790
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110777
diff
changeset
|
351 ;; Namazu engine, see <URL:http://www.namazu.org/> |
95610 | 352 |
353 (defcustom nnir-namazu-program "namazu" | |
354 "*Name of Namazu search executable." | |
355 :type '(string) | |
356 :group 'nnir) | |
357 | |
358 (defcustom nnir-namazu-index-directory (expand-file-name "~/Mail/namazu/") | |
359 "*Index directory for Namazu." | |
360 :type '(directory) | |
361 :group 'nnir) | |
362 | |
363 (defcustom nnir-namazu-additional-switches '() | |
364 "*A list of strings, to be given as additional arguments to namazu. | |
365 The switches `-q', `-a', and `-s' are always used, very few other switches | |
366 make any sense in this context. | |
367 | |
368 Note that this should be a list. Ie, do NOT use the following: | |
369 (setq nnir-namazu-additional-switches \"-i -w\") ; wrong | |
370 Instead, use this: | |
371 (setq nnir-namazu-additional-switches '(\"-i\" \"-w\"))" | |
372 :type '(repeat (string)) | |
373 :group 'nnir) | |
374 | |
375 (defcustom nnir-namazu-remove-prefix (concat (getenv "HOME") "/Mail/") | |
376 "*The prefix to remove from each file name returned by Namazu | |
377 in order to get a group name (albeit with / instead of .). | |
378 | |
111245
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
379 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
|
380 \"/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
|
381 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
|
382 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
|
383 `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
|
384 arrive at the correct group name, \"mail.misc\"." |
95610 | 385 :type '(directory) |
386 :group 'nnir) | |
387 | |
111245
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
388 ;; Imap variables |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
389 |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
390 (defvar nnir-imap-search-arguments |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
391 '(("Whole message" . "TEXT") |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
392 ("Subject" . "SUBJECT") |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
393 ("To" . "TO") |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
394 ("From" . "FROM") |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
395 ("Imap" . "")) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
396 "Mapping from user readable keys to IMAP search items for use in nnir") |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
397 |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
398 (defvar nnir-imap-search-other "HEADER %S" |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
399 "The IMAP search item to use for anything other than |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
400 `nnir-imap-search-arguments'. By default this is the name of an |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
401 email header field") |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
402 |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
403 (defvar nnir-imap-search-argument-history () |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
404 "The history for querying search options in nnir") |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
405 |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
406 ;;; Developer Extension Variable: |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
407 |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
408 (defvar nnir-engines |
111321
f4305de1a430
nnir: remove wais support
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111314
diff
changeset
|
409 `((imap nnir-run-imap |
111245
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
410 ((criteria |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
411 "Imap Search in" ; Prompt |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
412 ,(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
|
413 nil ; allow any user input |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
414 nil ; initial value |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
415 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
|
416 ,nnir-imap-default-search-key ; default |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
417 ))) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
418 (gmane nnir-run-gmane |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
419 ((author . "Gmane Author: "))) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
420 (swish++ nnir-run-swish++ |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
421 ((group . "Swish++ Group spec: "))) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
422 (swish-e nnir-run-swish-e |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
423 ((group . "Swish-e Group spec: "))) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
424 (namazu nnir-run-namazu |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
425 ()) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
426 (hyrex nnir-run-hyrex |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
427 ((group . "Hyrex Group spec: "))) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
428 (find-grep nnir-run-find-grep |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
429 ((grep-options . "Grep options: ")))) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
430 "Alist of supported search engines. |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
431 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
|
432 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
|
433 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
|
434 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
|
435 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
|
436 |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
437 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
|
438 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
|
439 (nnir-search-engine namazu) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
440 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
|
441 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
|
442 needs the variables `nnir-namazu-program', |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
443 `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
|
444 |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
445 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
|
446 |
111789
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
447 (defvar nnir-retrieve-headers-override-function nil |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
448 "If non-nil, a function that accepts an article list and group |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
449 and populates the `nntp-server-buffer' with the retrieved |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
450 headers. Must return either 'nov or 'headers indicating the |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
451 retrieved header format. |
111245
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
452 |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
453 If this variable is nil, or if the provided function returns nil for a search |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
454 result, `gnus-retrieve-headers' will be called instead.") |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
455 |
95610 | 456 ;;; Internal Variables: |
457 | |
458 (defvar nnir-current-query nil | |
459 "Internal: stores current query (= group name).") | |
460 | |
461 (defvar nnir-current-server nil | |
462 "Internal: stores current server (does it ever change?).") | |
463 | |
464 (defvar nnir-current-group-marked nil | |
465 "Internal: stores current list of process-marked groups.") | |
466 | |
467 (defvar nnir-artlist nil | |
468 "Internal: stores search result.") | |
469 | |
470 (defvar nnir-tmp-buffer " *nnir*" | |
471 "Internal: temporary buffer.") | |
472 | |
111245
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
473 (defvar nnir-search-history () |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
474 "Internal: the history for querying search options in nnir") |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
475 |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
476 (defvar nnir-extra-parms nil |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
477 "Internal: stores request for extra search parms") |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
478 |
95610 | 479 ;;; Code: |
480 | |
111789
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
481 ;;; Helper macros |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
482 |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
483 ;; Data type article list. |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
484 |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
485 (defmacro nnir-artlist-length (artlist) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
486 "Returns number of articles in artlist." |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
487 `(length ,artlist)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
488 |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
489 (defmacro nnir-artlist-article (artlist n) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
490 "Returns from ARTLIST the Nth artitem (counting starting at 1)." |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
491 `(when (> ,n 0) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
492 (elt ,artlist (1- ,n)))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
493 |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
494 (defmacro nnir-artitem-group (artitem) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
495 "Returns the group from the ARTITEM." |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
496 `(elt ,artitem 0)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
497 |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
498 (defmacro nnir-artitem-number (artitem) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
499 "Returns the number from the ARTITEM." |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
500 `(elt ,artitem 1)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
501 |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
502 (defmacro nnir-artitem-rsv (artitem) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
503 "Returns the Retrieval Status Value (RSV, score) from the ARTITEM." |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
504 `(elt ,artitem 2)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
505 |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
506 (defmacro nnir-article-group (article) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
507 "Returns the group for ARTICLE" |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
508 `(nnir-artitem-group (nnir-artlist-article nnir-artlist ,article))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
509 |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
510 (defmacro nnir-article-number (article) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
511 "Returns the number for ARTICLE" |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
512 `(nnir-artitem-number (nnir-artlist-article nnir-artlist ,article))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
513 |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
514 (defmacro nnir-article-rsv (article) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
515 "Returns the rsv for ARTICLE" |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
516 `(nnir-artitem-rsv (nnir-artlist-article nnir-artlist ,article))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
517 |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
518 (defsubst nnir-article-ids (article) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
519 "Returns the pair `(nnir id . real id)' of ARTICLE" |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
520 (cons article (nnir-article-number article))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
521 |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
522 (defmacro nnir-categorize (sequence keyfunc &optional valuefunc) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
523 "Sorts a sequence into categories and returns a list of the form |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
524 `((key1 (element11 element12)) (key2 (element21 element22))'. |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
525 The category key for a member of the sequence is obtained |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
526 as `(keyfunc member)' and the corresponding element is just |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
527 `member'. If `valuefunc' is non-nil, the element of the list |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
528 is `(valuefunc member)'." |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
529 `(unless (null ,sequence) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
530 (let (value) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
531 (mapcar |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
532 (lambda (member) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
533 (let ((y (,keyfunc member)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
534 (x ,(if valuefunc |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
535 `(,valuefunc member) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
536 'member))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
537 (if (assoc y value) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
538 (push x (cadr (assoc y value))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
539 (push (list y (list x)) value)))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
540 ,sequence) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
541 value))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
542 |
95610 | 543 ;; Gnus glue. |
544 | |
111245
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
545 (defun gnus-group-make-nnir-group (nnir-extra-parms) |
95610 | 546 "Create an nnir group. Asks for query." |
111245
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
547 (interactive "P") |
95610 | 548 (setq nnir-current-query nil |
549 nnir-current-server nil | |
550 nnir-current-group-marked nil | |
551 nnir-artlist nil) | |
111245
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
552 (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
|
553 (parms (list (cons 'query query))) |
3d7a1caabf14
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111245
diff
changeset
|
554 (srv (if (gnus-server-server-name) |
3d7a1caabf14
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111245
diff
changeset
|
555 "all" ""))) |
95610 | 556 (add-to-list 'parms (cons 'unique-id (message-unique-id)) t) |
557 (gnus-group-read-ephemeral-group | |
111269
3d7a1caabf14
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111245
diff
changeset
|
558 (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
|
559 (cons (current-buffer) gnus-current-window-configuration) |
95610 | 560 nil))) |
561 | |
562 | |
563 ;; Gnus backend interface functions. | |
564 | |
565 (deffoo nnir-open-server (server &optional definitions) | |
566 ;; Just set the server variables appropriately. | |
111789
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
567 (add-hook 'gnus-summary-mode-hook 'nnir-mode) |
95610 | 568 (nnoo-change-server 'nnir server definitions)) |
569 | |
110422
93e093c035a0
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110410
diff
changeset
|
570 (deffoo nnir-request-group (group &optional server fast info) |
95610 | 571 "GROUP is the query string." |
572 (nnir-possibly-change-server server) | |
573 ;; Check for cache and return that if appropriate. | |
574 (if (and (equal group nnir-current-query) | |
575 (equal gnus-group-marked nnir-current-group-marked) | |
576 (or (null server) | |
577 (equal server nnir-current-server))) | |
578 nnir-artlist | |
579 ;; Cache miss. | |
111269
3d7a1caabf14
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111245
diff
changeset
|
580 (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
|
581 (with-current-buffer nntp-server-buffer |
111245
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
582 (setq nnir-current-query group) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
583 (when server (setq nnir-current-server server)) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
584 (setq nnir-current-group-marked gnus-group-marked) |
95610 | 585 (if (zerop (length nnir-artlist)) |
111245
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
586 (nnheader-report 'nnir "Search produced empty results.") |
95610 | 587 ;; Remember data for cache. |
588 (nnheader-insert "211 %d %d %d %s\n" | |
589 (nnir-artlist-length nnir-artlist) ; total # | |
590 1 ; first # | |
591 (nnir-artlist-length nnir-artlist) ; last # | |
111245
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
592 group)))) ; group name |
95610 | 593 |
594 (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
|
595 (with-current-buffer nntp-server-buffer |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
596 (let ((gnus-inhibit-demon t) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
597 (articles-by-group (nnir-categorize |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
598 articles nnir-article-group nnir-article-ids)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
599 headers) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
600 (while (not (null articles-by-group)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
601 (let* ((group-articles (pop articles-by-group)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
602 (artgroup (car group-articles)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
603 (articleids (cadr group-articles)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
604 (artlist (sort (mapcar 'cdr articleids) '<)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
605 (server (gnus-group-server artgroup)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
606 (gnus-override-method (gnus-server-to-method server)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
607 parsefunc) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
608 ;; (or (numberp art) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
609 ;; (nnheader-report |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
610 ;; 'nnir |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
611 ;; "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
|
612 ;; art)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
613 (nnir-possibly-change-server server) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
614 ;; is this needed? |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
615 (erase-buffer) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
616 (case (setq gnus-headers-retrieved-by |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
617 (or |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
618 (and |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
619 nnir-retrieve-headers-override-function |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
620 (funcall nnir-retrieve-headers-override-function |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
621 artlist artgroup)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
622 (gnus-retrieve-headers artlist artgroup nil))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
623 (nov |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
624 (setq parsefunc 'nnheader-parse-nov)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
625 (headers |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
626 (setq parsefunc 'nnheader-parse-head)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
627 (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
|
628 of group %s" gnus-headers-retrieved-by artgroup))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
629 (goto-char (point-min)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
630 (while (not (eobp)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
631 (let* ((novitem (funcall parsefunc)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
632 (artno (mail-header-number novitem)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
633 (art (car (rassoc artno articleids)))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
634 (when art |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
635 (mail-header-set-number novitem art) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
636 ;; (mail-header-set-subject |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
637 ;; novitem |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
638 ;; (format "[%d: %s/%d] %s" |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
639 ;; (nnir-article-rsv art) artgroup artno |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
640 ;; (mail-header-subject novitem))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
641 (push novitem headers)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
642 (forward-line 1))))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
643 (setq headers |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
644 (sort headers |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
645 (lambda (x y) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
646 (< (mail-header-number x) (mail-header-number y))))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
647 (erase-buffer) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
648 (mapc 'nnheader-insert-nov headers) |
95610 | 649 'nov))) |
650 | |
111789
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
651 (deffoo nnir-request-article (article &optional group server to-buffer) |
95610 | 652 (if (stringp article) |
653 (nnheader-report | |
654 'nnir | |
655 "nnir-retrieve-headers doesn't grok message ids: %s" | |
656 article) | |
657 (save-excursion | |
111789
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
658 (let ((artfullgroup (nnir-article-group article)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
659 (artno (nnir-article-number article)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
660 ;; Bug? |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
661 ;; Why must we bind nntp-server-buffer here? It won't |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
662 ;; work if `buf' is used, say. (Of course, the set-buffer |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
663 ;; line below must then be updated, too.) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
664 (nntp-server-buffer (or to-buffer nntp-server-buffer))) |
95610 | 665 (set-buffer nntp-server-buffer) |
666 (erase-buffer) | |
667 (message "Requesting article %d from group %s" | |
668 artno artfullgroup) | |
669 (gnus-request-article artno artfullgroup nntp-server-buffer) | |
670 (cons artfullgroup artno))))) | |
671 | |
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
|
672 (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
|
673 &optional last internal-move-group) |
111789
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
674 (let* ((artfullgroup (nnir-article-group article)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
675 (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
|
676 (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
|
677 (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
|
678 (from-method (gnus-find-method-for-group artfullgroup)) |
111482
0aa164743cb3
nnir.el (nnir-request-move-article): fix to provide original group and subject.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111430
diff
changeset
|
679 (move-is-internal (gnus-server-equal from-method to-method)) |
0aa164743cb3
nnir.el (nnir-request-move-article): fix to provide original group and subject.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111430
diff
changeset
|
680 (artsubject (mail-header-subject |
0aa164743cb3
nnir.el (nnir-request-move-article): fix to provide original group and subject.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111430
diff
changeset
|
681 (gnus-data-header |
0aa164743cb3
nnir.el (nnir-request-move-article): fix to provide original group and subject.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111430
diff
changeset
|
682 (assoc article (gnus-data-list nil)))))) |
111789
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
683 (unless (gnus-check-backend-function |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
684 'request-move-article artfullgroup) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
685 (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
|
686 (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
|
687 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
|
688 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
|
689 (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
|
690 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
|
691 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
|
692 (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
|
693 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
|
694 (gnus-group-real-name to-newsgroup))))) |
95610 | 695 |
111430
b75e6634a171
gnus-int.el, nnimap.el, nnir.el: More improvements to thread-referral.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111401
diff
changeset
|
696 (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
|
697 (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
|
698 (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
|
699 (error "This is not a real article."))) |
111789
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
700 (gnus-newsgroup-name (nnir-article-group cur)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
701 (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
|
702 (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
|
703 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
|
704 |
95610 | 705 (nnoo-define-skeleton nnir) |
706 | |
707 | |
708 (defmacro nnir-add-result (dirnam artno score prefix server artlist) | |
95616 | 709 "Ask `nnir-compose-result' to construct a result vector, |
95610 | 710 and if it is non-nil, add it to artlist." |
711 `(let ((result (nnir-compose-result ,dirnam ,artno ,score ,prefix ,server))) | |
712 (when (not (null result)) | |
713 (push result ,artlist)))) | |
714 | |
715 (autoload 'nnmaildir-base-name-to-article-number "nnmaildir") | |
716 | |
717 ;; Helper function currently used by the Swish++ and Namazu backends; | |
718 ;; perhaps useful for other backends as well | |
719 (defun nnir-compose-result (dirnam article score prefix server) | |
720 "Extract the group from dirnam, and create a result vector | |
721 ready to be added to the list of search results." | |
722 | |
723 ;; remove nnir-*-remove-prefix from beginning of dirnam filename | |
724 (when (string-match (concat "^" prefix) dirnam) | |
725 (setq dirnam (replace-match "" t t dirnam))) | |
726 | |
727 (when (file-readable-p (concat prefix dirnam article)) | |
728 ;; remove trailing slash and, for nnmaildir, cur/new/tmp | |
729 (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
|
730 (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
|
731 (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
|
732 -5 -1))) |
95610 | 733 |
734 ;; Set group to dirnam without any leading dots or slashes, | |
735 ;; and with all subsequent slashes replaced by dots | |
736 (let ((group (gnus-replace-in-string | |
737 (gnus-replace-in-string dirnam "^[./\\]" "" t) | |
738 "[/\\]" "." t))) | |
739 | |
111789
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
740 (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
|
741 (if (string= (gnus-group-server server) "nnmaildir") |
95610 | 742 (nnmaildir-base-name-to-article-number |
743 (substring article 0 (string-match ":" article)) | |
744 group nil) | |
745 (string-to-number article)) | |
746 (string-to-number score))))) | |
747 | |
748 ;;; Search Engine Interfaces: | |
749 | |
111245
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
750 ;; imap interface |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
751 (defun nnir-run-imap (query srv &optional groups) |
95610 | 752 "Run a search against an IMAP back-end server. |
753 This uses a custom query language parser; see `nnir-imap-make-query' for | |
754 details on the language and supported extensions" | |
755 (save-excursion | |
756 (let ((qstring (cdr (assq 'query query))) | |
111245
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
757 (server (cadr (gnus-server-to-method srv))) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
758 (defs (caddr (gnus-server-to-method srv))) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
759 (criteria (or (cdr (assq 'criteria query)) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
760 (cdr (assoc nnir-imap-default-search-key |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
761 nnir-imap-search-arguments)))) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
762 (gnus-inhibit-demon t) |
111584
4273d2312244
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111491
diff
changeset
|
763 (groups (or groups (nnir-get-active srv)))) |
95610 | 764 (message "Opening server %s" server) |
111245
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
765 (apply |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
766 'vconcat |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
767 (mapcar |
111669
ed117caa918e
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111584
diff
changeset
|
768 (lambda (group) |
ed117caa918e
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111584
diff
changeset
|
769 (let (artlist) |
111245
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
770 (condition-case () |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
771 (when (nnimap-possibly-change-group |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
772 (gnus-group-short-name group) server) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
773 (with-current-buffer (nnimap-buffer) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
774 (message "Searching %s..." group) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
775 (let ((arts 0) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
776 (result (nnimap-command "UID SEARCH %s" |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
777 (if (string= criteria "") |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
778 qstring |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
779 (nnir-imap-make-query |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
780 criteria qstring))))) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
781 (mapc |
111789
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
782 (lambda (artnum) (push (vector group artnum 100) artlist) |
111245
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
783 (setq arts (1+ arts))) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
784 (and (car result) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
785 (delete 0 (mapcar #'string-to-number |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
786 (cdr (assoc "SEARCH" |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
787 (cdr result))))))) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
788 (message "Searching %s... %d matches" group arts))) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
789 (message "Searching %s...done" group)) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
790 (quit nil)) |
111669
ed117caa918e
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111584
diff
changeset
|
791 artlist)) |
111245
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
792 groups))))) |
95610 | 793 |
794 (defun nnir-imap-make-query (criteria qstring) | |
795 "Parse the query string and criteria into an appropriate IMAP search | |
796 expression, returning the string query to make. | |
797 | |
798 This implements a little language designed to return the expected results | |
799 to an arbitrary query string to the end user. | |
800 | |
801 The search is always case-insensitive, as defined by RFC2060, and supports | |
95616 | 802 the following features (inspired by the Google search input language): |
95610 | 803 |
804 Automatic \"and\" queries | |
805 If you specify multiple words then they will be treated as an \"and\" | |
806 expression intended to match all components. | |
807 | |
808 Phrase searches | |
809 If you wrap your query in double-quotes then it will be treated as a | |
810 literal string. | |
811 | |
812 Negative terms | |
813 If you precede a term with \"-\" then it will negate that. | |
814 | |
815 \"OR\" queries | |
816 If you include an upper-case \"OR\" in your search it will cause the | |
817 term before it and the term after it to be treated as alternatives. | |
818 | |
819 In future the following will be added to the language: | |
820 * support for date matches | |
821 * support for location of text matching within the query | |
822 * from/to/etc headers | |
823 * additional search terms | |
824 * flag based searching | |
825 * anything else that the RFC supports, basically." | |
826 ;; Walk through the query and turn it into an IMAP query string. | |
827 (nnir-imap-query-to-imap criteria (nnir-imap-parse-query qstring))) | |
828 | |
829 | |
830 (defun nnir-imap-query-to-imap (criteria query) | |
831 "Turn a s-expression format query into IMAP." | |
832 (mapconcat | |
833 ;; Turn the expressions into IMAP text | |
834 (lambda (item) | |
835 (nnir-imap-expr-to-imap criteria item)) | |
836 ;; The query, already in s-expr format. | |
837 query | |
838 ;; Append a space between each expression | |
839 " ")) | |
840 | |
841 | |
842 (defun nnir-imap-expr-to-imap (criteria expr) | |
843 "Convert EXPR into an IMAP search expression on CRITERIA" | |
844 ;; What sort of expression is this, eh? | |
845 (cond | |
846 ;; Simple string term | |
847 ((stringp expr) | |
110908
2a4bfc24abf0
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110898
diff
changeset
|
848 (format "%s %S" criteria expr)) |
95610 | 849 ;; Trivial term: and |
850 ((eq expr 'and) nil) | |
851 ;; Composite term: or expression | |
852 ((eq (car-safe expr) 'or) | |
853 (format "OR %s %s" | |
854 (nnir-imap-expr-to-imap criteria (second expr)) | |
855 (nnir-imap-expr-to-imap criteria (third expr)))) | |
856 ;; Composite term: just the fax, mam | |
857 ((eq (car-safe expr) 'not) | |
858 (format "NOT (%s)" (nnir-imap-query-to-imap criteria (rest expr)))) | |
859 ;; Composite term: just expand it all. | |
860 ((and (not (null expr)) (listp expr)) | |
861 (format "(%s)" (nnir-imap-query-to-imap criteria expr))) | |
862 ;; Complex value, give up for now. | |
863 (t (error "Unhandled input: %S" expr)))) | |
864 | |
865 | |
866 (defun nnir-imap-parse-query (string) | |
867 "Turn STRING into an s-expression based query based on the IMAP | |
868 query language as defined in `nnir-imap-make-query'. | |
869 | |
870 This involves turning individual tokens into higher level terms | |
871 that the search language can then understand and use." | |
872 (with-temp-buffer | |
873 ;; Set up the parsing environment. | |
874 (insert string) | |
875 (goto-char (point-min)) | |
876 ;; Now, collect the output terms and return them. | |
877 (let (out) | |
878 (while (not (nnir-imap-end-of-input)) | |
879 (push (nnir-imap-next-expr) out)) | |
880 (reverse out)))) | |
881 | |
882 | |
883 (defun nnir-imap-next-expr (&optional count) | |
884 "Return the next expression from the current buffer." | |
885 (let ((term (nnir-imap-next-term count)) | |
886 (next (nnir-imap-peek-symbol))) | |
887 ;; Are we looking at an 'or' expression? | |
888 (cond | |
889 ;; Handle 'expr or expr' | |
890 ((eq next 'or) | |
891 (list 'or term (nnir-imap-next-expr 2))) | |
892 ;; Anything else | |
893 (t term)))) | |
894 | |
895 | |
896 (defun nnir-imap-next-term (&optional count) | |
897 "Return the next TERM from the current buffer." | |
898 (let ((term (nnir-imap-next-symbol count))) | |
899 ;; What sort of term is this? | |
900 (cond | |
901 ;; and -- just ignore it | |
902 ((eq term 'and) 'and) | |
903 ;; negated term | |
904 ((eq term 'not) (list 'not (nnir-imap-next-expr))) | |
905 ;; generic term | |
906 (t term)))) | |
907 | |
908 | |
909 (defun nnir-imap-peek-symbol () | |
910 "Return the next symbol from the current buffer, but don't consume it." | |
911 (save-excursion | |
912 (nnir-imap-next-symbol))) | |
913 | |
914 (defun nnir-imap-next-symbol (&optional count) | |
915 "Return the next symbol from the current buffer, or nil if we are | |
916 at the end of the buffer. If supplied COUNT skips some symbols before | |
917 returning the one at the supplied position." | |
918 (when (and (numberp count) (> count 1)) | |
919 (nnir-imap-next-symbol (1- count))) | |
920 (let ((case-fold-search t)) | |
921 ;; end of input stream? | |
922 (unless (nnir-imap-end-of-input) | |
923 ;; No, return the next symbol from the stream. | |
924 (cond | |
925 ;; negated expression -- return it and advance one char. | |
926 ((looking-at "-") (forward-char 1) 'not) | |
927 ;; quoted string | |
928 ((looking-at "\"") (nnir-imap-delimited-string "\"")) | |
929 ;; list expression -- we parse the content and return this as a list. | |
930 ((looking-at "(") | |
931 (nnir-imap-parse-query (nnir-imap-delimited-string ")"))) | |
932 ;; keyword input -- return a symbol version | |
933 ((looking-at "\\band\\b") (forward-char 3) 'and) | |
934 ((looking-at "\\bor\\b") (forward-char 2) 'or) | |
935 ((looking-at "\\bnot\\b") (forward-char 3) 'not) | |
936 ;; Simple, boring keyword | |
937 (t (let ((start (point)) | |
938 (end (if (search-forward-regexp "[[:blank:]]" nil t) | |
939 (prog1 | |
940 (match-beginning 0) | |
941 ;; unskip if we hit a non-blank terminal character. | |
942 (when (string-match "[^[:blank:]]" (match-string 0)) | |
943 (backward-char 1))) | |
944 (goto-char (point-max))))) | |
945 (buffer-substring start end))))))) | |
946 | |
947 (defun nnir-imap-delimited-string (delimiter) | |
948 "Return a delimited string from the current buffer." | |
949 (let ((start (point)) end) | |
950 (forward-char 1) ; skip the first delimiter. | |
951 (while (not end) | |
952 (unless (search-forward delimiter nil t) | |
953 (error "Unmatched delimited input with %s in query" delimiter)) | |
954 (let ((here (point))) | |
955 (unless (equal (buffer-substring (- here 2) (- here 1)) "\\") | |
956 (setq end (point))))) | |
957 (buffer-substring (1+ start) (1- end)))) | |
958 | |
959 (defun nnir-imap-end-of-input () | |
960 "Are we at the end of input?" | |
961 (skip-chars-forward "[[:blank:]]") | |
962 (looking-at "$")) | |
95616 | 963 |
95610 | 964 |
965 ;; Swish++ interface. | |
966 ;; -cc- Todo | |
967 ;; Search by | |
968 ;; - group | |
969 ;; Sort by | |
970 ;; - rank (default) | |
971 ;; - article number | |
972 ;; - file size | |
973 ;; - group | |
974 (defun nnir-run-swish++ (query server &optional group) | |
975 "Run QUERY against swish++. | |
976 Returns a vector of (group name, file name) pairs (also vectors, | |
977 actually). | |
978 | |
979 Tested with swish++ 4.7 on GNU/Linux and with swish++ 5.0b2 on | |
980 Windows NT 4.0." | |
981 | |
111245
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
982 ;; (when group |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
983 ;; (error "The swish++ backend cannot search specific groups")) |
95610 | 984 |
985 (save-excursion | |
986 (let ( (qstring (cdr (assq 'query query))) | |
987 (groupspec (cdr (assq 'group query))) | |
988 (prefix (nnir-read-server-parm 'nnir-swish++-remove-prefix server)) | |
989 artlist | |
990 ;; nnml-use-compressed-files might be any string, but probably this | |
991 ;; is sufficient. Note that we can't only use the value of | |
992 ;; nnml-use-compressed-files because old articles might have been | |
993 ;; 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
|
994 (article-pattern (if (string= (gnus-group-server server) "nnmaildir") |
95610 | 995 ":[0-9]+" |
996 "^[0-9]+\\(\\.[a-z0-9]+\\)?$")) | |
997 score artno dirnam filenam) | |
998 | |
999 (when (equal "" qstring) | |
105167
e14dfafc8256
* gnus-art.el (gnus-article-encrypt-body):
Juanma Barranquero <lekktu@gmail.com>
parents:
104700
diff
changeset
|
1000 (error "swish++: You didn't enter anything")) |
95610 | 1001 |
1002 (set-buffer (get-buffer-create nnir-tmp-buffer)) | |
1003 (erase-buffer) | |
1004 | |
1005 (if groupspec | |
1006 (message "Doing swish++ query %s on %s..." qstring groupspec) | |
1007 (message "Doing swish++ query %s..." qstring)) | |
1008 | |
1009 (let* ((cp-list `( ,nnir-swish++-program | |
1010 nil ; input from /dev/null | |
1011 t ; output | |
1012 nil ; don't redisplay | |
1013 "--config-file" ,(nnir-read-server-parm 'nnir-swish++-configuration-file server) | |
1014 ,@(nnir-read-server-parm 'nnir-swish++-additional-switches server) | |
1015 ,qstring ; the query, in swish++ format | |
1016 )) | |
1017 (exitstatus | |
1018 (progn | |
1019 (message "%s args: %s" nnir-swish++-program | |
1020 (mapconcat 'identity (cddddr cp-list) " ")) ;; ??? | |
1021 (apply 'call-process cp-list)))) | |
1022 (unless (or (null exitstatus) | |
1023 (zerop exitstatus)) | |
1024 (nnheader-report 'nnir "Couldn't run swish++: %s" exitstatus) | |
1025 ;; swish++ failure reason is in this buffer, show it if | |
1026 ;; the user wants it. | |
1027 (when (> gnus-verbose 6) | |
1028 (display-buffer nnir-tmp-buffer)))) | |
1029 | |
1030 ;; The results are output in the format of: | |
1031 ;; V 4.7 Linux | |
1032 ;; rank relative-path-name file-size file-title | |
1033 ;; V 5.0b2: | |
1034 ;; rank relative-path-name file-size topic?? | |
1035 ;; where rank is an integer from 1 to 100. | |
1036 (goto-char (point-min)) | |
1037 (while (re-search-forward | |
1038 "\\(^[0-9]+\\) \\([^ ]+\\) [0-9]+ \\(.*\\)$" nil t) | |
1039 (setq score (match-string 1) | |
1040 filenam (match-string 2) | |
1041 artno (file-name-nondirectory filenam) | |
1042 dirnam (file-name-directory filenam)) | |
1043 | |
1044 ;; don't match directories | |
1045 (when (string-match article-pattern artno) | |
1046 (when (not (null dirnam)) | |
1047 | |
1048 ;; maybe limit results to matching groups. | |
1049 (when (or (not groupspec) | |
1050 (string-match groupspec dirnam)) | |
1051 (nnir-add-result dirnam artno score prefix server artlist))))) | |
1052 | |
1053 (message "Massaging swish++ output...done") | |
1054 | |
1055 ;; Sort by score | |
1056 (apply 'vector | |
104584
f540e84a920d
(top-level): Don't require cl at run-time.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
1057 (sort artlist |
f540e84a920d
(top-level): Don't require cl at run-time.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
1058 (function (lambda (x y) |
f540e84a920d
(top-level): Don't require cl at run-time.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
1059 (> (nnir-artitem-rsv x) |
f540e84a920d
(top-level): Don't require cl at run-time.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
1060 (nnir-artitem-rsv y))))))))) |
95610 | 1061 |
1062 ;; Swish-E interface. | |
1063 (defun nnir-run-swish-e (query server &optional group) | |
1064 "Run given query against swish-e. | |
1065 Returns a vector of (group name, file name) pairs (also vectors, | |
1066 actually). | |
1067 | |
1068 Tested with swish-e-2.0.1 on Windows NT 4.0." | |
1069 | |
1070 ;; 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
|
1071 ;; (when group |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1072 ;; (error "The swish-e backend cannot search specific groups")) |
95610 | 1073 |
1074 (save-excursion | |
1075 (let ((qstring (cdr (assq 'query query))) | |
1076 (prefix | |
1077 (or (nnir-read-server-parm 'nnir-swish-e-remove-prefix server) | |
1078 (error "Missing parameter `nnir-swish-e-remove-prefix'"))) | |
1079 artlist score artno dirnam group ) | |
1080 | |
1081 (when (equal "" qstring) | |
105167
e14dfafc8256
* gnus-art.el (gnus-article-encrypt-body):
Juanma Barranquero <lekktu@gmail.com>
parents:
104700
diff
changeset
|
1082 (error "swish-e: You didn't enter anything")) |
95610 | 1083 |
1084 (set-buffer (get-buffer-create nnir-tmp-buffer)) | |
1085 (erase-buffer) | |
1086 | |
1087 (message "Doing swish-e query %s..." query) | |
1088 (let* ((index-files | |
1089 (or (nnir-read-server-parm | |
1090 'nnir-swish-e-index-files server) | |
1091 (error "Missing parameter `nnir-swish-e-index-files'"))) | |
1092 (additional-switches | |
1093 (nnir-read-server-parm | |
1094 'nnir-swish-e-additional-switches server)) | |
1095 (cp-list `(,nnir-swish-e-program | |
1096 nil ; input from /dev/null | |
1097 t ; output | |
1098 nil ; don't redisplay | |
1099 "-f" ,@index-files | |
1100 ,@additional-switches | |
1101 "-w" | |
1102 ,qstring ; the query, in swish-e format | |
1103 )) | |
1104 (exitstatus | |
1105 (progn | |
1106 (message "%s args: %s" nnir-swish-e-program | |
1107 (mapconcat 'identity (cddddr cp-list) " ")) | |
1108 (apply 'call-process cp-list)))) | |
1109 (unless (or (null exitstatus) | |
1110 (zerop exitstatus)) | |
1111 (nnheader-report 'nnir "Couldn't run swish-e: %s" exitstatus) | |
1112 ;; swish-e failure reason is in this buffer, show it if | |
1113 ;; the user wants it. | |
1114 (when (> gnus-verbose 6) | |
1115 (display-buffer nnir-tmp-buffer)))) | |
1116 | |
1117 ;; The results are output in the format of: | |
1118 ;; rank path-name file-title file-size | |
1119 (goto-char (point-min)) | |
1120 (while (re-search-forward | |
1121 "\\(^[0-9]+\\) \\([^ ]+\\) \"\\([^\"]+\\)\" [0-9]+$" nil t) | |
1122 (setq score (match-string 1) | |
1123 artno (match-string 3) | |
1124 dirnam (file-name-directory (match-string 2))) | |
1125 | |
1126 ;; don't match directories | |
1127 (when (string-match "^[0-9]+$" artno) | |
1128 (when (not (null dirnam)) | |
1129 | |
1130 ;; remove nnir-swish-e-remove-prefix from beginning of dirname | |
1131 (when (string-match (concat "^" prefix) dirnam) | |
1132 (setq dirnam (replace-match "" t t dirnam))) | |
1133 | |
1134 (setq dirnam (substring dirnam 0 -1)) | |
1135 ;; eliminate all ".", "/", "\" from beginning. Always matches. | |
1136 (string-match "^[./\\]*\\(.*\\)$" dirnam) | |
1137 ;; "/" -> "." | |
104584
f540e84a920d
(top-level): Don't require cl at run-time.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
1138 (setq group (gnus-replace-in-string (match-string 1 dirnam) "/" ".")) |
95610 | 1139 ;; Windows "\\" -> "." |
104584
f540e84a920d
(top-level): Don't require cl at run-time.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
1140 (setq group (gnus-replace-in-string group "\\\\" ".")) |
95610 | 1141 |
111789
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1142 (push (vector (gnus-group-full-name group server) |
95610 | 1143 (string-to-number artno) |
1144 (string-to-number score)) | |
1145 artlist)))) | |
1146 | |
1147 (message "Massaging swish-e output...done") | |
1148 | |
1149 ;; Sort by score | |
1150 (apply 'vector | |
104584
f540e84a920d
(top-level): Don't require cl at run-time.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
1151 (sort artlist |
f540e84a920d
(top-level): Don't require cl at run-time.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
1152 (function (lambda (x y) |
f540e84a920d
(top-level): Don't require cl at run-time.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
1153 (> (nnir-artitem-rsv x) |
f540e84a920d
(top-level): Don't require cl at run-time.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
1154 (nnir-artitem-rsv y))))))))) |
95610 | 1155 |
111245
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1156 ;; HyREX interface |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1157 (defun nnir-run-hyrex (query server &optional group) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1158 (save-excursion |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1159 (let ((artlist nil) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1160 (groupspec (cdr (assq 'group query))) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1161 (qstring (cdr (assq 'query query))) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1162 (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
|
1163 score artno dirnam) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1164 (when (and (not groupspec) group) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1165 (setq groupspec |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1166 (regexp-opt |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1167 (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
|
1168 (set-buffer (get-buffer-create nnir-tmp-buffer)) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1169 (erase-buffer) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1170 (message "Doing hyrex-search query %s..." query) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1171 (let* ((cp-list |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1172 `( ,nnir-hyrex-program |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1173 nil ; input from /dev/null |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1174 t ; output |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1175 nil ; don't redisplay |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1176 "-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
|
1177 ,@(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
|
1178 ,qstring ; the query, in hyrex-search format |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1179 )) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1180 (exitstatus |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1181 (progn |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1182 (message "%s args: %s" nnir-hyrex-program |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1183 (mapconcat 'identity (cddddr cp-list) " ")) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1184 (apply 'call-process cp-list)))) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1185 (unless (or (null exitstatus) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1186 (zerop exitstatus)) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1187 (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
|
1188 ;; 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
|
1189 ;; the user wants it. |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1190 (when (> gnus-verbose 6) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1191 (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
|
1192 (message "Doing hyrex-search query \"%s\"...done" qstring) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1193 (sit-for 0) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1194 ;; nnir-search returns: |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1195 ;; for nnml/nnfolder: "filename mailid weigth" |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1196 ;; for nnimap: "group mailid weigth" |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1197 (goto-char (point-min)) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1198 (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
|
1199 ;; 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
|
1200 (when groupspec |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1201 (keep-lines groupspec)) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1202 ;; extract data from result lines |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1203 (goto-char (point-min)) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1204 (while (re-search-forward |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1205 "\\(\\S +\\) \\([0-9]+\\) \\([0-9]+\\)" nil t) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1206 (setq dirnam (match-string 1) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1207 artno (match-string 2) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1208 score (match-string 3)) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1209 (when (string-match prefix dirnam) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1210 (setq dirnam (replace-match "" t t dirnam))) |
111789
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1211 (push (vector (gnus-group-full-name |
111245
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1212 (gnus-replace-in-string dirnam "/" ".") server) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1213 (string-to-number artno) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1214 (string-to-number score)) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1215 artlist)) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1216 (message "Massaging hyrex-search output...done.") |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1217 (apply 'vector |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1218 (sort artlist |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1219 (function (lambda (x y) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1220 (if (string-lessp (nnir-artitem-group x) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1221 (nnir-artitem-group y)) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1222 t |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1223 (< (nnir-artitem-number x) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1224 (nnir-artitem-number y))))))) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1225 ))) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1226 |
95610 | 1227 ;; Namazu interface |
1228 (defun nnir-run-namazu (query server &optional group) | |
1229 "Run given query against Namazu. Returns a vector of (group name, file name) | |
1230 pairs (also vectors, actually). | |
1231 | |
1232 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
|
1233 ;; (when group |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1234 ;; (error "The Namazu backend cannot search specific groups")) |
95610 | 1235 (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
|
1236 (let ((article-pattern (if (string= (gnus-group-server server) "nnmaildir") |
95610 | 1237 ":[0-9]+" |
1238 "^[0-9]+$")) | |
1239 artlist | |
1240 (qstring (cdr (assq 'query query))) | |
1241 (prefix (nnir-read-server-parm 'nnir-namazu-remove-prefix server)) | |
1242 score group article | |
1243 (process-environment (copy-sequence process-environment))) | |
1244 (setenv "LC_MESSAGES" "C") | |
1245 (set-buffer (get-buffer-create nnir-tmp-buffer)) | |
1246 (erase-buffer) | |
1247 (let* ((cp-list | |
1248 `( ,nnir-namazu-program | |
1249 nil ; input from /dev/null | |
1250 t ; output | |
1251 nil ; don't redisplay | |
1252 "-q" ; don't be verbose | |
1253 "-a" ; show all matches | |
1254 "-s" ; use short format | |
1255 ,@(nnir-read-server-parm 'nnir-namazu-additional-switches server) | |
1256 ,qstring ; the query, in namazu format | |
1257 ,(nnir-read-server-parm 'nnir-namazu-index-directory server) ; index directory | |
1258 )) | |
1259 (exitstatus | |
1260 (progn | |
1261 (message "%s args: %s" nnir-namazu-program | |
1262 (mapconcat 'identity (cddddr cp-list) " ")) | |
1263 (apply 'call-process cp-list)))) | |
1264 (unless (or (null exitstatus) | |
1265 (zerop exitstatus)) | |
1266 (nnheader-report 'nnir "Couldn't run namazu: %s" exitstatus) | |
1267 ;; Namazu failure reason is in this buffer, show it if | |
1268 ;; the user wants it. | |
1269 (when (> gnus-verbose 6) | |
1270 (display-buffer nnir-tmp-buffer)))) | |
1271 | |
1272 ;; Namazu output looks something like this: | |
1273 ;; 2. Re: Gnus agent expire broken (score: 55) | |
1274 ;; /home/henrik/Mail/mail/sent/1310 (4,138 bytes) | |
1275 | |
1276 (goto-char (point-min)) | |
1277 (while (re-search-forward | |
1278 "^\\([0-9]+\\.\\).*\\((score: \\([0-9]+\\)\\))\n\\([^ ]+\\)" | |
1279 nil t) | |
1280 (setq score (match-string 3) | |
1281 group (file-name-directory (match-string 4)) | |
1282 article (file-name-nondirectory (match-string 4))) | |
1283 | |
1284 ;; make sure article and group is sane | |
1285 (when (and (string-match article-pattern article) | |
1286 (not (null group))) | |
1287 (nnir-add-result group article score prefix server artlist))) | |
1288 | |
1289 ;; sort artlist by score | |
1290 (apply 'vector | |
104584
f540e84a920d
(top-level): Don't require cl at run-time.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
1291 (sort artlist |
f540e84a920d
(top-level): Don't require cl at run-time.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
1292 (function (lambda (x y) |
f540e84a920d
(top-level): Don't require cl at run-time.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
1293 (> (nnir-artitem-rsv x) |
f540e84a920d
(top-level): Don't require cl at run-time.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
1294 (nnir-artitem-rsv y))))))))) |
95610 | 1295 |
111245
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1296 (defun nnir-run-find-grep (query server &optional grouplist) |
95610 | 1297 "Run find and grep to obtain matching articles." |
1298 (let* ((method (gnus-server-to-method server)) | |
1299 (sym (intern | |
1300 (concat (symbol-name (car method)) "-directory"))) | |
1301 (directory (cadr (assoc sym (cddr method)))) | |
1302 (regexp (cdr (assoc 'query query))) | |
1303 (grep-options (cdr (assoc 'grep-options query))) | |
111789
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1304 (grouplist (or grouplist (nnir-get-active server))) |
95610 | 1305 artlist) |
1306 (unless directory | |
1307 (error "No directory found in method specification of server %s" | |
1308 server)) | |
111245
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1309 (apply |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1310 'vconcat |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1311 (mapcar (lambda (x) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1312 (let ((group x)) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1313 (message "Searching %s using find-grep..." |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1314 (or group server)) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1315 (save-window-excursion |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1316 (set-buffer (get-buffer-create nnir-tmp-buffer)) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1317 (erase-buffer) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1318 (if (> gnus-verbose 6) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1319 (pop-to-buffer (current-buffer))) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1320 (cd directory) ; Using relative paths simplifies |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1321 ; postprocessing. |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1322 (let ((group |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1323 (if (not group) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1324 "." |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1325 ;; Try accessing the group literally as |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1326 ;; well as interpreting dots as directory |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1327 ;; separators so the engine works with |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1328 ;; plain nnml as well as the Gnus Cache. |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1329 (let ((group (gnus-group-real-name group))) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1330 ;; Replace cl-func find-if. |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1331 (if (file-directory-p group) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1332 group |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1333 (if (file-directory-p |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1334 (setq group |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1335 (gnus-replace-in-string |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1336 group |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1337 "\\." "/" t))) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1338 group)))))) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1339 (unless group |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1340 (error "Cannot locate directory for group")) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1341 (save-excursion |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1342 (apply |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1343 'call-process "find" nil t |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1344 "find" group "-type" "f" "-name" "[0-9]*" "-exec" |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1345 "grep" |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1346 `("-l" ,@(and grep-options |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1347 (split-string grep-options "\\s-" t)) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1348 "-e" ,regexp "{}" "+")))) |
95610 | 1349 |
111245
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1350 ;; Translate relative paths to group names. |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1351 (while (not (eobp)) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1352 (let* ((path (split-string |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1353 (buffer-substring |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1354 (point) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1355 (line-end-position)) "/" t)) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1356 (art (string-to-number (car (last path))))) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1357 (while (string= "." (car path)) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1358 (setq path (cdr path))) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1359 (let ((group (mapconcat 'identity |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1360 ;; Replace cl-func: |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1361 ;; (subseq path 0 -1) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1362 (let ((end (1- (length path))) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1363 res) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1364 (while |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1365 (>= (setq end (1- end)) 0) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1366 (push (pop path) res)) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1367 (nreverse res)) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1368 "."))) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1369 (push |
111789
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1370 (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
|
1371 artlist)) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1372 (forward-line 1))) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1373 (message "Searching %s using find-grep...done" |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1374 (or group server)) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1375 artlist))) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1376 grouplist)))) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1377 |
111288 | 1378 (declare-function mm-url-insert "mm-url" (url &optional follow-refresh)) |
1379 (declare-function mm-url-encode-www-form-urlencoded "mm-url" (pairs)) | |
1380 | |
111245
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1381 ;; gmane interface |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1382 (defun nnir-run-gmane (query srv &optional groups) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1383 "Run a search against a gmane back-end server." |
111789
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1384 (if (gnus-string-match-p "gmane.org$" srv) |
111245
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1385 (let* ((case-fold-search t) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1386 (qstring (cdr (assq 'query query))) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1387 (server (cadr (gnus-server-to-method srv))) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1388 (groupspec (if groups |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1389 (mapconcat |
111789
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1390 (lambda (x) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1391 (format "group:%s" (gnus-group-short-name x))) |
111245
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1392 groups " ") "")) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1393 (authorspec |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1394 (if (assq 'author query) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1395 (format "author:%s" (cdr (assq 'author query))) "")) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1396 (search (format "%s %s %s" |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1397 qstring groupspec authorspec)) |
111314
1431aee91437
nnir.el: Fix various bugs.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111294
diff
changeset
|
1398 (gnus-inhibit-demon t) |
111245
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1399 artlist) |
111288 | 1400 (require 'mm-url) |
111669
ed117caa918e
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111584
diff
changeset
|
1401 (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
|
1402 (erase-buffer) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1403 (mm-url-insert |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1404 (concat |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1405 "http://search.gmane.org/nov.php" |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1406 "?" |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1407 (mm-url-encode-www-form-urlencoded |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1408 `(("query" . ,search) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1409 ("HITSPERPAGE" . "999"))))) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1410 (unless (featurep 'xemacs) (set-buffer-multibyte t)) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1411 (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
|
1412 (goto-char (point-min)) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1413 (forward-line 1) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1414 (while (not (eobp)) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1415 (unless (or (eolp) (looking-at "\x0d")) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1416 (let ((header (nnheader-parse-nov))) |
111269
3d7a1caabf14
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111245
diff
changeset
|
1417 (let ((xref (mail-header-xref header)) |
3d7a1caabf14
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111245
diff
changeset
|
1418 (xscore (string-to-number (cdr (assoc 'X-Score |
3d7a1caabf14
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111245
diff
changeset
|
1419 (mail-header-extra header)))))) |
111245
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1420 (when (string-match " \\([^:]+\\)[:/]\\([0-9]+\\)" xref) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1421 (push |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1422 (vector |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1423 (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
|
1424 (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
|
1425 artlist))))) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1426 (forward-line 1))) |
111789
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1427 (apply 'vector (nreverse (mm-delete-duplicates artlist)))) |
111314
1431aee91437
nnir.el: Fix various bugs.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111294
diff
changeset
|
1428 (message "Can't search non-gmane nntp groups") |
1431aee91437
nnir.el: Fix various bugs.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111294
diff
changeset
|
1429 nil)) |
95610 | 1430 |
1431 ;;; Util Code: | |
1432 | |
111245
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1433 (defun nnir-read-parms (query nnir-search-engine) |
95610 | 1434 "Reads additional search parameters according to `nnir-engines'." |
1435 (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
|
1436 (append query |
111245
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1437 (mapcar 'nnir-read-parm parmspec)))) |
95610 | 1438 |
1439 (defun nnir-read-parm (parmspec) | |
1440 "Reads a single search parameter. | |
1441 `parmspec' is a cons cell, the car is a symbol, the cdr is a prompt." | |
1442 (let ((sym (car parmspec)) | |
1443 (prompt (cdr parmspec))) | |
1444 (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
|
1445 (let* ((result (apply 'gnus-completing-read prompt)) |
95610 | 1446 (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
|
1447 (cons nil nnir-imap-search-other)))) |
95610 | 1448 (cons sym (format (cdr mapping) result))) |
1449 (cons sym (read-string prompt))))) | |
1450 | |
111491
ea2c0f22a4ad
* lisp/gnus/nnir.el (gnus-group-topic-name): Autoload.
Glenn Morris <rgm@gnu.org>
parents:
111482
diff
changeset
|
1451 (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
|
1452 |
111269
3d7a1caabf14
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111245
diff
changeset
|
1453 (defun nnir-run-query (query nserver) |
95610 | 1454 "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
|
1455 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
|
1456 and concat the results." |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1457 (let ((q (car (read-from-string query))) |
111269
3d7a1caabf14
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111245
diff
changeset
|
1458 (groups (if (string= "all-ephemeral" nserver) |
3d7a1caabf14
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111245
diff
changeset
|
1459 (with-current-buffer gnus-server-buffer |
3d7a1caabf14
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111245
diff
changeset
|
1460 (list (list (gnus-server-server-name)))) |
111789
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1461 (nnir-categorize |
111314
1431aee91437
nnir.el: Fix various bugs.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111294
diff
changeset
|
1462 (or gnus-group-marked |
1431aee91437
nnir.el: Fix various bugs.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111294
diff
changeset
|
1463 (if (gnus-group-group-name) |
1431aee91437
nnir.el: Fix various bugs.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111294
diff
changeset
|
1464 (list (gnus-group-group-name)) |
1431aee91437
nnir.el: Fix various bugs.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111294
diff
changeset
|
1465 (cdr (assoc (gnus-group-topic-name) |
111789
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1466 gnus-topic-alist)))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1467 gnus-group-server)))) |
111245
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1468 (apply 'vconcat |
111789
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1469 (mapcar |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1470 (lambda (x) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1471 (let* ((server (car x)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1472 (nnir-search-engine |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1473 (or (nnir-read-server-parm 'nnir-search-engine |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1474 server) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1475 (cdr (assoc (car |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1476 (gnus-server-to-method server)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1477 nnir-method-default-engines)))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1478 search-func) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1479 (setq search-func (cadr (assoc nnir-search-engine |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1480 nnir-engines))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1481 (if search-func |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1482 (funcall search-func |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1483 (if nnir-extra-parms |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1484 (nnir-read-parms q nnir-search-engine) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1485 q) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1486 server (cadr x)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1487 nil))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1488 groups)))) |
95610 | 1489 |
1490 (defun nnir-read-server-parm (key server) | |
111245
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1491 "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
|
1492 server is of form 'backend:name'." |
95610 | 1493 (let ((method (gnus-server-to-method server))) |
1494 (cond ((and method (assq key (cddr method))) | |
111245
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1495 (nth 1 (assq key (cddr method)))) |
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111217
diff
changeset
|
1496 (t nil)))) |
95610 | 1497 |
1498 (defun nnir-possibly-change-server (server) | |
1499 (unless (and server (nnir-server-opened server)) | |
1500 (nnir-open-server server))) | |
1501 | |
1502 | |
1503 | |
1504 ;; unused? | |
1505 (defun nnir-artlist-groups (artlist) | |
1506 "Returns a list of all groups in the given ARTLIST." | |
1507 (let ((res nil) | |
1508 (with-dups nil)) | |
1509 ;; from each artitem, extract group component | |
1510 (setq with-dups (mapcar 'nnir-artitem-group artlist)) | |
1511 ;; remove duplicates from above | |
1512 (mapc (function (lambda (x) (add-to-list 'res x))) | |
1513 with-dups) | |
1514 res)) | |
1515 | |
111269
3d7a1caabf14
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111245
diff
changeset
|
1516 (defun nnir-get-active (srv) |
3d7a1caabf14
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111245
diff
changeset
|
1517 (let ((method (gnus-server-to-method srv)) |
3d7a1caabf14
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111245
diff
changeset
|
1518 groups) |
3d7a1caabf14
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111245
diff
changeset
|
1519 (gnus-request-list method) |
3d7a1caabf14
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111245
diff
changeset
|
1520 (with-current-buffer nntp-server-buffer |
3d7a1caabf14
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111245
diff
changeset
|
1521 (let ((cur (current-buffer)) |
3d7a1caabf14
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111245
diff
changeset
|
1522 name) |
3d7a1caabf14
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111245
diff
changeset
|
1523 (goto-char (point-min)) |
111789
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1524 (unless (string= nnir-ignored-newsgroups "") |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1525 (delete-matching-lines nnir-ignored-newsgroups)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1526 (if (eq (car method) 'nntp) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1527 (while (not (eobp)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1528 (ignore-errors |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1529 (push (mm-string-as-unibyte |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1530 (gnus-group-full-name |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1531 (buffer-substring |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1532 (point) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1533 (progn |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1534 (skip-chars-forward "^ \t") |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1535 (point))) method)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1536 groups)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1537 (forward-line)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1538 (while (not (eobp)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1539 (ignore-errors |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1540 (push (mm-string-as-unibyte |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1541 (if (eq (char-after) ?\") |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1542 (gnus-group-full-name (read cur) method) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1543 (let ((p (point)) (name "")) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1544 (skip-chars-forward "^ \t\\\\") |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1545 (setq name (buffer-substring p (point))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1546 (while (eq (char-after) ?\\) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1547 (setq p (1+ (point))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1548 (forward-char 2) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1549 (skip-chars-forward "^ \t\\\\") |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1550 (setq name (concat name (buffer-substring |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1551 p (point))))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1552 (gnus-group-full-name name method)))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1553 groups)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1554 (forward-line))))) |
111269
3d7a1caabf14
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111245
diff
changeset
|
1555 groups)) |
3d7a1caabf14
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111245
diff
changeset
|
1556 |
111789
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1557 (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
|
1558 "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
|
1559 (gnus-registry-action |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1560 action |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1561 data-header |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1562 (nnir-article-group (mail-header-number data-header)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1563 to |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1564 method)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1565 |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1566 (defun nnir-mode () |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1567 (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
|
1568 (setq gnus-summary-line-format |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1569 (or nnir-summary-line-format gnus-summary-line-format)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1570 (remove-hook 'gnus-summary-article-delete-hook 'gnus-registry-action t) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1571 (remove-hook 'gnus-summary-article-move-hook 'gnus-registry-action t) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1572 (add-hook 'gnus-summary-article-delete-hook 'nnir-registry-action t t) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1573 (add-hook 'gnus-summary-article-move-hook 'nnir-registry-action t t))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1574 |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1575 |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111669
diff
changeset
|
1576 |
95610 | 1577 ;; The end. |
1578 (provide 'nnir) | |
1579 | |
95616 | 1580 ;;; nnir.el ends here |