Output alists with dotted pair notation in .dir-locals.el
[emacs.git] / lisp / gnus / nnir.el
blob7e5f56e4dd001f2804382aaca1255e8d67dfecbf
1 ;;; nnir.el --- Search mail with various search engines -*- lexical-binding:t -*-
3 ;; Copyright (C) 1998-2018 Free Software Foundation, Inc.
5 ;; Author: Kai Großjohann <grossjohann@ls6.cs.uni-dortmund.de>
6 ;; Swish-e and Swish++ backends by:
7 ;; Christoph Conrad <christoph.conrad@gmx.de>.
8 ;; IMAP backend by: Simon Josefsson <jas@pdc.kth.se>.
9 ;; IMAP search by: Torsten Hilbrich <torsten.hilbrich <at> gmx.net>
10 ;; IMAP search improved by Daniel Pittman <daniel@rimspace.net>.
11 ;; nnmaildir support for Swish++ and Namazu backends by:
12 ;; Justus Piater <Justus <at> Piater.name>
13 ;; Keywords: news mail searching ir
15 ;; This file is part of GNU Emacs.
17 ;; GNU Emacs is free software: you can redistribute it and/or modify
18 ;; it under the terms of the GNU General Public License as published by
19 ;; the Free Software Foundation, either version 3 of the License, or
20 ;; (at your option) any later version.
22 ;; GNU Emacs is distributed in the hope that it will be useful,
23 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
24 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 ;; GNU General Public License for more details.
27 ;; You should have received a copy of the GNU General Public License
28 ;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
30 ;;; Commentary:
32 ;; What does it do? Well, it allows you to search your mail using
33 ;; some search engine (imap, namazu, swish-e and others -- see
34 ;; later) by typing `G G' in the Group buffer. You will then get a
35 ;; buffer which shows all articles matching the query, sorted by
36 ;; Retrieval Status Value (score).
38 ;; When looking at the retrieval result (in the Summary buffer) you
39 ;; can type `A W' (aka M-x gnus-warp-to-article RET) on an article. You
40 ;; will be warped into the group this article came from. Typing `A T'
41 ;; (aka M-x gnus-summary-refer-thread RET) will warp to the group and
42 ;; also show the thread this article is part of.
44 ;; The Lisp setup may involve setting a few variables and setting up the
45 ;; search engine. You can define the variables in the server definition
46 ;; like this :
47 ;; (setq gnus-secondary-select-methods '(
48 ;; (nnimap "" (nnimap-address "localhost")
49 ;; (nnir-search-engine namazu)
50 ;; )))
51 ;; The main variable to set is `nnir-search-engine'. Choose one of
52 ;; the engines listed in `nnir-engines'. (Actually `nnir-engines' is
53 ;; an alist, type `C-h v nnir-engines RET' for more information; this
54 ;; includes examples for setting `nnir-search-engine', too.)
56 ;; If you use one of the local indices (namazu, find-grep, swish) you
57 ;; must also set up a search engine backend.
59 ;; 1. Namazu
61 ;; The Namazu backend requires you to have one directory containing all
62 ;; index files, this is controlled by the `nnir-namazu-index-directory'
63 ;; variable. To function the `nnir-namazu-remove-prefix' variable must
64 ;; also be correct, see the documentation for `nnir-namazu-remove-prefix'
65 ;; above.
67 ;; It is particularly important not to pass any switches to namazu
68 ;; that will change the output format. Good switches to use include
69 ;; `--sort', `--ascending', `--early' and `--late'. Refer to the Namazu
70 ;; documentation for further information on valid switches.
72 ;; To index my mail with the `mknmz' program I use the following
73 ;; configuration file:
75 ;; ,----
76 ;; | package conf; # Don't remove this line!
77 ;; |
78 ;; | # Paths which will not be indexed. Don't use `^' or `$' anchors.
79 ;; | $EXCLUDE_PATH = "spam|sent";
80 ;; |
81 ;; | # Header fields which should be searchable. case-insensitive
82 ;; | $REMAIN_HEADER = "from|date|message-id|subject";
83 ;; |
84 ;; | # Searchable fields. case-insensitive
85 ;; | $SEARCH_FIELD = "from|date|message-id|subject";
86 ;; |
87 ;; | # The max length of a word.
88 ;; | $WORD_LENG_MAX = 128;
89 ;; |
90 ;; | # The max length of a field.
91 ;; | $MAX_FIELD_LENGTH = 256;
92 ;; `----
94 ;; My mail is stored in the directories ~/Mail/mail/, ~/Mail/lists/ and
95 ;; ~/Mail/archive/, so to index them I go to the directory set in
96 ;; `nnir-namazu-index-directory' and issue the following command.
98 ;; mknmz --mailnews ~/Mail/archive/ ~/Mail/mail/ ~/Mail/lists/
100 ;; For maximum searching efficiency I have a cron job set to run this
101 ;; command every four hours.
103 ;; 2. find-grep
105 ;; The find-grep engine simply runs find(1) to locate eligible
106 ;; articles and searches them with grep(1). This, of course, is much
107 ;; slower than using a proper search engine but OTOH doesn't require
108 ;; maintenance of an index and is still faster than using any built-in
109 ;; means for searching. The method specification of the server to
110 ;; search must include a directory for this engine to work (E.g.,
111 ;; `nnml-directory'). The tools must be POSIX compliant. GNU Find
112 ;; prior to version 4.2.12 (4.2.26 on Linux due to incorrect ARG_MAX
113 ;; handling) does not work.
114 ;; ,----
115 ;; | ;; find-grep configuration for searching the Gnus Cache
116 ;; |
117 ;; | (nnml "cache"
118 ;; | (nnml-get-new-mail nil)
119 ;; | (nnir-search-engine find-grep)
120 ;; | (nnml-directory "~/News/cache/")
121 ;; | (nnml-active-file "~/News/cache/active"))
122 ;; `----
124 ;; Developer information:
126 ;; I have tried to make the code expandable. Basically, it is divided
127 ;; into two layers. The upper layer is somewhat like the `nnvirtual'
128 ;; backend: given a specification of what articles to show from
129 ;; another backend, it creates a group containing exactly those
130 ;; articles. The lower layer issues a query to a search engine and
131 ;; produces such a specification of what articles to show from the
132 ;; other backend.
134 ;; The interface between the two layers consists of the single
135 ;; function `nnir-run-query', which dispatches the search to the
136 ;; proper search function. The argument of `nnir-run-query' is an
137 ;; alist with two keys: 'nnir-query-spec and 'nnir-group-spec. The
138 ;; value for 'nnir-query-spec is an alist. The only required key/value
139 ;; pair is (query . "query") specifying the search string to pass to
140 ;; the query engine. Individual engines may have other elements. The
141 ;; value of 'nnir-group-spec is a list with the specification of the
142 ;; groups/servers to search. The format of the 'nnir-group-spec is
143 ;; (("server1" ("group11" "group12")) ("server2" ("group21"
144 ;; "group22"))). If any of the group lists is absent then all groups
145 ;; on that server are searched.
147 ;; The output of `nnir-run-query' is supposed to be a vector, each
148 ;; element of which should in turn be a three-element vector. The
149 ;; first element should be full group name of the article, the second
150 ;; element should be the article number, and the third element should
151 ;; be the Retrieval Status Value (RSV) as returned from the search
152 ;; engine. An RSV is the score assigned to the document by the search
153 ;; engine. For Boolean search engines, the RSV is always 1000 (or 1
154 ;; or 100, or whatever you like).
156 ;; The sorting order of the articles in the summary buffer created by
157 ;; nnir is based on the order of the articles in the above mentioned
158 ;; vector, so that's where you can do the sorting you'd like. Maybe
159 ;; it would be nice to have a way of displaying the search result
160 ;; sorted differently?
162 ;; So what do you need to do when you want to add another search
163 ;; engine? You write a function that executes the query. Temporary
164 ;; data from the search engine can be put in `nnir-tmp-buffer'. This
165 ;; function should return the list of articles as a vector, as
166 ;; described above. Then, you need to register this backend in
167 ;; `nnir-engines'. Then, users can choose the backend by setting
168 ;; `nnir-search-engine' as a server variable.
170 ;;; Code:
172 ;;; Setup:
174 (require 'nnoo)
175 (require 'gnus-group)
176 (require 'message)
177 (require 'gnus-util)
178 (eval-when-compile (require 'cl-lib))
180 ;;; Internal Variables:
182 (defvar nnir-memo-query nil
183 "Internal: stores current query.")
185 (defvar nnir-memo-server nil
186 "Internal: stores current server.")
188 (defvar nnir-artlist nil
189 "Internal: stores search result.")
191 (defvar nnir-search-history ()
192 "Internal: the history for querying search options in nnir")
194 (defconst nnir-tmp-buffer " *nnir*"
195 "Internal: temporary buffer.")
198 ;; Imap variables
200 (defvar nnir-imap-search-arguments
201 '(("whole message" . "TEXT")
202 ("subject" . "SUBJECT")
203 ("to" . "TO")
204 ("from" . "FROM")
205 ("body" . "BODY")
206 ("imap" . ""))
207 "Mapping from user readable keys to IMAP search items for use in nnir")
209 (defvar nnir-imap-search-other "HEADER %S"
210 "The IMAP search item to use for anything other than
211 `nnir-imap-search-arguments'. By default this is the name of an
212 email header field")
214 (defvar nnir-imap-search-argument-history ()
215 "The history for querying search options in nnir")
217 ;;; Helper macros
219 ;; Data type article list.
221 (defmacro nnir-artlist-length (artlist)
222 "Returns number of articles in artlist."
223 `(length ,artlist))
225 (defmacro nnir-artlist-article (artlist n)
226 "Returns from ARTLIST the Nth artitem (counting starting at 1)."
227 `(when (> ,n 0)
228 (elt ,artlist (1- ,n))))
230 (defmacro nnir-artitem-group (artitem)
231 "Returns the group from the ARTITEM."
232 `(elt ,artitem 0))
234 (defmacro nnir-artitem-number (artitem)
235 "Returns the number from the ARTITEM."
236 `(elt ,artitem 1))
238 (defmacro nnir-artitem-rsv (artitem)
239 "Returns the Retrieval Status Value (RSV, score) from the ARTITEM."
240 `(elt ,artitem 2))
242 (defmacro nnir-article-group (article)
243 "Returns the group for ARTICLE"
244 `(nnir-artitem-group (nnir-artlist-article nnir-artlist ,article)))
246 (defmacro nnir-article-number (article)
247 "Returns the number for ARTICLE"
248 `(nnir-artitem-number (nnir-artlist-article nnir-artlist ,article)))
250 (defmacro nnir-article-rsv (article)
251 "Returns the rsv for ARTICLE"
252 `(nnir-artitem-rsv (nnir-artlist-article nnir-artlist ,article)))
254 (defsubst nnir-article-ids (article)
255 "Returns the pair `(nnir id . real id)' of ARTICLE"
256 (cons article (nnir-article-number article)))
258 (defmacro nnir-categorize (sequence keyfunc &optional valuefunc)
259 "Sorts a sequence into categories and returns a list of the form
260 `((key1 (element11 element12)) (key2 (element21 element22))'.
261 The category key for a member of the sequence is obtained
262 as `(keyfunc member)' and the corresponding element is just
263 `member'. If `valuefunc' is non-nil, the element of the list
264 is `(valuefunc member)'."
265 `(unless (null ,sequence)
266 (let (value)
267 (mapc
268 (lambda (member)
269 (let ((y (,keyfunc member))
270 (x ,(if valuefunc
271 `(,valuefunc member)
272 'member)))
273 (if (assoc y value)
274 (push x (cadr (assoc y value)))
275 (push (list y (list x)) value))))
276 ,sequence)
277 value)))
279 ;;; Finish setup:
281 (require 'gnus-sum)
283 (nnoo-declare nnir)
284 (nnoo-define-basics nnir)
286 (gnus-declare-backend "nnir" 'mail 'virtual)
289 ;;; User Customizable Variables:
291 (defgroup nnir nil
292 "Search groups in Gnus with assorted search engines."
293 :group 'gnus)
295 (defcustom nnir-ignored-newsgroups ""
296 "A regexp to match newsgroups in the active file that should
297 be skipped when searching."
298 :version "24.1"
299 :type '(regexp)
300 :group 'nnir)
302 (defcustom nnir-summary-line-format nil
303 "The format specification of the lines in an nnir summary buffer.
305 All the items from `gnus-summary-line-format' are available, along
306 with three items unique to nnir summary buffers:
308 %Z Search retrieval score value (integer)
309 %G Article original full group name (string)
310 %g Article original short group name (string)
312 If nil this will use `gnus-summary-line-format'."
313 :version "24.1"
314 :type '(choice (const :tag "gnus-summary-line-format" nil) string)
315 :group 'nnir)
317 (defcustom nnir-retrieve-headers-override-function nil
318 "If non-nil, a function that accepts an article list and group
319 and populates the `nntp-server-buffer' with the retrieved
320 headers. Must return either 'nov or 'headers indicating the
321 retrieved header format.
323 If this variable is nil, or if the provided function returns nil for a search
324 result, `gnus-retrieve-headers' will be called instead."
325 :version "24.1"
326 :type '(choice (const :tag "gnus-retrieve-headers" nil) function)
327 :group 'nnir)
329 (defcustom nnir-imap-default-search-key "whole message"
330 "The default IMAP search key for an nnir search. Must be one of
331 the keys in `nnir-imap-search-arguments'. To use raw imap queries
332 by default set this to \"imap\"."
333 :version "24.1"
334 :type `(choice ,@(mapcar (lambda (elem) (list 'const (car elem)))
335 nnir-imap-search-arguments))
336 :group 'nnir)
338 (defcustom nnir-swish++-configuration-file
339 (expand-file-name "~/Mail/swish++.conf")
340 "Configuration file for swish++."
341 :type '(file)
342 :group 'nnir)
344 (defcustom nnir-swish++-program "search"
345 "Name of swish++ search executable."
346 :type '(string)
347 :group 'nnir)
349 (defcustom nnir-swish++-additional-switches '()
350 "A list of strings, to be given as additional arguments to swish++.
352 Note that this should be a list. I.e., do NOT use the following:
353 (setq nnir-swish++-additional-switches \"-i -w\") ; wrong
354 Instead, use this:
355 (setq nnir-swish++-additional-switches \\='(\"-i\" \"-w\"))"
356 :type '(repeat (string))
357 :group 'nnir)
359 (defcustom nnir-swish++-remove-prefix (concat (getenv "HOME") "/Mail/")
360 "The prefix to remove from each file name returned by swish++
361 in order to get a group name (albeit with / instead of .). This is a
362 regular expression.
364 This variable is very similar to `nnir-namazu-remove-prefix', except
365 that it is for swish++, not Namazu."
366 :type '(regexp)
367 :group 'nnir)
369 ;; Swish-E.
370 ;; URL: http://swish-e.org/
371 ;; Variables `nnir-swish-e-index-file', `nnir-swish-e-program' and
372 ;; `nnir-swish-e-additional-switches'
374 (make-obsolete-variable 'nnir-swish-e-index-file
375 'nnir-swish-e-index-files "Emacs 23.1")
376 (defcustom nnir-swish-e-index-file
377 (expand-file-name "~/Mail/index.swish-e")
378 "Index file for swish-e.
379 This could be a server parameter.
380 It is never consulted once `nnir-swish-e-index-files', which should be
381 used instead, has been customized."
382 :type '(file)
383 :group 'nnir)
385 (defcustom nnir-swish-e-index-files
386 (list nnir-swish-e-index-file)
387 "List of index files for swish-e.
388 This could be a server parameter."
389 :type '(repeat (file))
390 :group 'nnir)
392 (defcustom nnir-swish-e-program "swish-e"
393 "Name of swish-e search executable.
394 This cannot be a server parameter."
395 :type '(string)
396 :group 'nnir)
398 (defcustom nnir-swish-e-additional-switches '()
399 "A list of strings, to be given as additional arguments to swish-e.
401 Note that this should be a list. I.e., do NOT use the following:
402 (setq nnir-swish-e-additional-switches \"-i -w\") ; wrong
403 Instead, use this:
404 (setq nnir-swish-e-additional-switches \\='(\"-i\" \"-w\"))
406 This could be a server parameter."
407 :type '(repeat (string))
408 :group 'nnir)
410 (defcustom nnir-swish-e-remove-prefix (concat (getenv "HOME") "/Mail/")
411 "The prefix to remove from each file name returned by swish-e
412 in order to get a group name (albeit with / instead of .). This is a
413 regular expression.
415 This variable is very similar to `nnir-namazu-remove-prefix', except
416 that it is for swish-e, not Namazu.
418 This could be a server parameter."
419 :type '(regexp)
420 :group 'nnir)
422 ;; HyREX engine, see <URL:http://ls6-www.cs.uni-dortmund.de/>
424 (defcustom nnir-hyrex-program "nnir-search"
425 "Name of the nnir-search executable."
426 :type '(string)
427 :group 'nnir)
429 (defcustom nnir-hyrex-additional-switches '()
430 "A list of strings, to be given as additional arguments for nnir-search.
431 Note that this should be a list. I.e., do NOT use the following:
432 (setq nnir-hyrex-additional-switches \"-ddl ddl.xml -c nnir\") ; wrong !
433 Instead, use this:
434 (setq nnir-hyrex-additional-switches \\='(\"-ddl\" \"ddl.xml\" \"-c\" \"nnir\"))"
435 :type '(repeat (string))
436 :group 'nnir)
438 (defcustom nnir-hyrex-index-directory (getenv "HOME")
439 "Index directory for HyREX."
440 :type '(directory)
441 :group 'nnir)
443 (defcustom nnir-hyrex-remove-prefix (concat (getenv "HOME") "/Mail/")
444 "The prefix to remove from each file name returned by HyREX
445 in order to get a group name (albeit with / instead of .).
447 For example, suppose that HyREX returns file names such as
448 \"/home/john/Mail/mail/misc/42\". For this example, use the following
449 setting: (setq nnir-hyrex-remove-prefix \"/home/john/Mail/\")
450 Note the trailing slash. Removing this prefix gives \"mail/misc/42\".
451 `nnir' knows to remove the \"/42\" and to replace \"/\" with \".\" to
452 arrive at the correct group name, \"mail.misc\"."
453 :type '(directory)
454 :group 'nnir)
456 ;; Namazu engine, see <URL:http://www.namazu.org/>
458 (defcustom nnir-namazu-program "namazu"
459 "Name of Namazu search executable."
460 :type '(string)
461 :group 'nnir)
463 (defcustom nnir-namazu-index-directory (expand-file-name "~/Mail/namazu/")
464 "Index directory for Namazu."
465 :type '(directory)
466 :group 'nnir)
468 (defcustom nnir-namazu-additional-switches '()
469 "A list of strings, to be given as additional arguments to namazu.
470 The switches `-q', `-a', and `-s' are always used, very few other switches
471 make any sense in this context.
473 Note that this should be a list. I.e., do NOT use the following:
474 (setq nnir-namazu-additional-switches \"-i -w\") ; wrong
475 Instead, use this:
476 (setq nnir-namazu-additional-switches \\='(\"-i\" \"-w\"))"
477 :type '(repeat (string))
478 :group 'nnir)
480 (defcustom nnir-namazu-remove-prefix (concat (getenv "HOME") "/Mail/")
481 "The prefix to remove from each file name returned by Namazu
482 in order to get a group name (albeit with / instead of .).
484 For example, suppose that Namazu returns file names such as
485 \"/home/john/Mail/mail/misc/42\". For this example, use the following
486 setting: (setq nnir-namazu-remove-prefix \"/home/john/Mail/\")
487 Note the trailing slash. Removing this prefix gives \"mail/misc/42\".
488 `nnir' knows to remove the \"/42\" and to replace \"/\" with \".\" to
489 arrive at the correct group name, \"mail.misc\"."
490 :type '(directory)
491 :group 'nnir)
493 (defcustom nnir-notmuch-program "notmuch"
494 "Name of notmuch search executable."
495 :version "24.1"
496 :type '(string)
497 :group 'nnir)
499 (defcustom nnir-notmuch-additional-switches '()
500 "A list of strings, to be given as additional arguments to notmuch.
502 Note that this should be a list. I.e., do NOT use the following:
503 (setq nnir-notmuch-additional-switches \"-i -w\") ; wrong
504 Instead, use this:
505 (setq nnir-notmuch-additional-switches \\='(\"-i\" \"-w\"))"
506 :version "24.1"
507 :type '(repeat (string))
508 :group 'nnir)
510 (defcustom nnir-notmuch-remove-prefix (concat (getenv "HOME") "/Mail/")
511 "The prefix to remove from each file name returned by notmuch
512 in order to get a group name (albeit with / instead of .). This is a
513 regular expression.
515 This variable is very similar to `nnir-namazu-remove-prefix', except
516 that it is for notmuch, not Namazu."
517 :version "24.1"
518 :type '(regexp)
519 :group 'nnir)
521 ;;; Developer Extension Variable:
523 (defvar nnir-engines
524 `((imap nnir-run-imap
525 ((criteria
526 "Imap Search in" ; Prompt
527 ,(mapcar 'car nnir-imap-search-arguments) ; alist for completing
528 nil ; allow any user input
529 nil ; initial value
530 nnir-imap-search-argument-history ; the history to use
531 ,nnir-imap-default-search-key ; default
533 (swish++ nnir-run-swish++
534 ((swish++-group . "Swish++ Group spec (regexp): ")))
535 (swish-e nnir-run-swish-e
536 ((swish-e-group . "Swish-e Group spec (regexp): ")))
537 (namazu nnir-run-namazu
539 (notmuch nnir-run-notmuch
541 (hyrex nnir-run-hyrex
542 ((hyrex-group . "Hyrex Group spec (regexp): ")))
543 (find-grep nnir-run-find-grep
544 ((grep-options . "Grep options: "))))
545 "Alist of supported search engines.
546 Each element in the alist is a three-element list (ENGINE FUNCTION ARGS).
547 ENGINE is a symbol designating the searching engine. FUNCTION is also
548 a symbol, giving the function that does the search. The third element
549 ARGS is a list of cons pairs (PARAM . PROMPT). When issuing a query,
550 the FUNCTION will issue a query for each of the PARAMs, using PROMPT.
552 The value of `nnir-search-engine' must be one of the ENGINE symbols.
553 For example, for searching a server using namazu include
554 (nnir-search-engine namazu)
555 in the server definition. Note that you have to set additional
556 variables for most backends. For example, the `namazu' backend
557 needs the variables `nnir-namazu-program',
558 `nnir-namazu-index-directory' and `nnir-namazu-remove-prefix'.
560 Add an entry here when adding a new search engine.")
562 (defcustom nnir-method-default-engines '((nnimap . imap))
563 "Alist of default search engines keyed by server method."
564 :version "24.1"
565 :group 'nnir
566 :type `(repeat (cons (choice (const nnimap) (const nntp) (const nnspool)
567 (const nneething) (const nndir) (const nnmbox)
568 (const nnml) (const nnmh) (const nndraft)
569 (const nnfolder) (const nnmaildir))
570 (choice
571 ,@(mapcar (lambda (elem) (list 'const (car elem)))
572 nnir-engines)))))
574 ;; Gnus glue.
576 (declare-function gnus-group-topic-name "gnus-topic" ())
578 (defun gnus-group-make-nnir-group (nnir-extra-parms &optional specs)
579 "Create an nnir group. Prompt for a search query and determine
580 the groups to search as follows: if called from the *Server*
581 buffer search all groups belonging to the server on the current
582 line; if called from the *Group* buffer search any marked groups,
583 or the group on the current line, or all the groups under the
584 current topic. Calling with a prefix-arg prompts for additional
585 search-engine specific constraints. A non-nil `specs' arg must be
586 an alist with `nnir-query-spec' and `nnir-group-spec' keys, and
587 skips all prompting."
588 (interactive "P")
589 (let* ((group-spec
590 (or (cdr (assq 'nnir-group-spec specs))
591 (if (gnus-server-server-name)
592 (list (list (gnus-server-server-name)))
593 (nnir-categorize
594 (or gnus-group-marked
595 (if (gnus-group-group-name)
596 (list (gnus-group-group-name))
597 (cdr (assoc (gnus-group-topic-name) gnus-topic-alist))))
598 gnus-group-server))))
599 (query-spec
600 (or (cdr (assq 'nnir-query-spec specs))
601 (apply
602 'append
603 (list (cons 'query
604 (read-string "Query: " nil 'nnir-search-history)))
605 (when nnir-extra-parms
606 (mapcar
607 (lambda (x)
608 (nnir-read-parms (nnir-server-to-search-engine (car x))))
609 group-spec))))))
610 (gnus-group-read-ephemeral-group
611 (concat "nnir-" (message-unique-id))
612 (list 'nnir "nnir")
614 ; (cons (current-buffer) gnus-current-window-configuration)
616 nil nil
617 (list
618 (cons 'nnir-specs (list (cons 'nnir-query-spec query-spec)
619 (cons 'nnir-group-spec group-spec)))
620 (cons 'nnir-artlist nil)))))
622 (defun gnus-summary-make-nnir-group (nnir-extra-parms)
623 "Search a group from the summary buffer."
624 (interactive "P")
625 (gnus-warp-to-article)
626 (let ((spec
627 (list
628 (cons 'nnir-group-spec
629 (list (list
630 (gnus-group-server gnus-newsgroup-name)
631 (list gnus-newsgroup-name)))))))
632 (gnus-group-make-nnir-group nnir-extra-parms spec)))
635 ;; Gnus backend interface functions.
637 (deffoo nnir-open-server (server &optional definitions)
638 ;; Just set the server variables appropriately.
639 (let ((backend (car (gnus-server-to-method server))))
640 (if backend
641 (nnoo-change-server backend server definitions)
642 (add-hook 'gnus-summary-mode-hook 'nnir-mode)
643 (nnoo-change-server 'nnir server definitions))))
645 (deffoo nnir-request-group (group &optional server dont-check _info)
646 (nnir-possibly-change-group group server)
647 (let ((pgroup (gnus-group-guess-full-name-from-command-method group))
648 length)
649 ;; Check for cached search result or run the query and cache the
650 ;; result.
651 (unless (and nnir-artlist dont-check)
652 (gnus-group-set-parameter
653 pgroup 'nnir-artlist
654 (setq nnir-artlist
655 (nnir-run-query
656 (gnus-group-get-parameter pgroup 'nnir-specs t))))
657 (nnir-request-update-info pgroup (gnus-get-info pgroup)))
658 (with-current-buffer nntp-server-buffer
659 (if (zerop (setq length (nnir-artlist-length nnir-artlist)))
660 (progn
661 (nnir-close-group group)
662 (nnheader-report 'nnir "Search produced empty results."))
663 (nnheader-insert "211 %d %d %d %s\n"
664 length ; total #
665 1 ; first #
666 length ; last #
667 group)))) ; group name
668 nnir-artlist)
670 (defvar gnus-inhibit-demon)
672 (deffoo nnir-retrieve-headers (articles &optional _group _server _fetch-old)
673 (with-current-buffer nntp-server-buffer
674 (let ((gnus-inhibit-demon t)
675 (articles-by-group (nnir-categorize
676 articles nnir-article-group nnir-article-ids))
677 headers)
678 (while (not (null articles-by-group))
679 (let* ((group-articles (pop articles-by-group))
680 (artgroup (car group-articles))
681 (articleids (cadr group-articles))
682 (artlist (sort (mapcar 'cdr articleids) '<))
683 (server (gnus-group-server artgroup))
684 (gnus-override-method (gnus-server-to-method server))
685 parsefunc)
686 ;; (nnir-possibly-change-group nil server)
687 (erase-buffer)
688 (pcase (setq gnus-headers-retrieved-by
690 (and
691 nnir-retrieve-headers-override-function
692 (funcall nnir-retrieve-headers-override-function
693 artlist artgroup))
694 (gnus-retrieve-headers artlist artgroup nil)))
695 ('nov
696 (setq parsefunc 'nnheader-parse-nov))
697 ('headers
698 (setq parsefunc 'nnheader-parse-head))
699 (_ (error "Unknown header type %s while requesting articles \
700 of group %s" gnus-headers-retrieved-by artgroup)))
701 (goto-char (point-min))
702 (while (not (eobp))
703 (let* ((novitem (funcall parsefunc))
704 (artno (and novitem
705 (mail-header-number novitem)))
706 (art (car (rassq artno articleids))))
707 (when art
708 (mail-header-set-number novitem art)
709 (push novitem headers))
710 (forward-line 1)))))
711 (setq headers
712 (sort headers
713 (lambda (x y)
714 (< (mail-header-number x) (mail-header-number y)))))
715 (erase-buffer)
716 (mapc 'nnheader-insert-nov headers)
717 'nov)))
719 (defvar gnus-article-decode-hook)
721 (deffoo nnir-request-article (article &optional group server to-buffer)
722 (nnir-possibly-change-group group server)
723 (if (and (stringp article)
724 (not (eq 'nnimap (car (gnus-server-to-method server)))))
725 (nnheader-report
726 'nnir
727 "nnir-request-article only groks message ids for nnimap servers: %s"
728 server)
729 (save-excursion
730 (let ((article article)
731 query)
732 (when (stringp article)
733 (setq gnus-override-method (gnus-server-to-method server))
734 (setq query
735 (list
736 (cons 'query (format "HEADER Message-ID %s" article))
737 (cons 'criteria "")
738 (cons 'shortcut t)))
739 (unless (and nnir-artlist (equal query nnir-memo-query)
740 (equal server nnir-memo-server))
741 (setq nnir-artlist (nnir-run-imap query server)
742 nnir-memo-query query
743 nnir-memo-server server))
744 (setq article 1))
745 (unless (zerop (nnir-artlist-length nnir-artlist))
746 (let ((artfullgroup (nnir-article-group article))
747 (artno (nnir-article-number article)))
748 (message "Requesting article %d from group %s"
749 artno artfullgroup)
750 (if to-buffer
751 (with-current-buffer to-buffer
752 (let ((gnus-article-decode-hook nil))
753 (gnus-request-article-this-buffer artno artfullgroup)))
754 (gnus-request-article artno artfullgroup))
755 (cons artfullgroup artno)))))))
757 (deffoo nnir-request-move-article (article group server accept-form
758 &optional last _internal-move-group)
759 (nnir-possibly-change-group group server)
760 (let* ((artfullgroup (nnir-article-group article))
761 (artno (nnir-article-number article))
762 (to-newsgroup (nth 1 accept-form))
763 (to-method (gnus-find-method-for-group to-newsgroup))
764 (from-method (gnus-find-method-for-group artfullgroup))
765 (move-is-internal (gnus-server-equal from-method to-method)))
766 (unless (gnus-check-backend-function
767 'request-move-article artfullgroup)
768 (error "The group %s does not support article moving" artfullgroup))
769 (gnus-request-move-article
770 artno
771 artfullgroup
772 (nth 1 from-method)
773 accept-form
774 last
775 (and move-is-internal
776 to-newsgroup ; Not respooling
777 (gnus-group-real-name to-newsgroup)))))
779 (deffoo nnir-request-expire-articles (articles group &optional server force)
780 (nnir-possibly-change-group group server)
781 (if force
782 (let ((articles-by-group (nnir-categorize
783 articles nnir-article-group nnir-article-ids))
784 not-deleted)
785 (while (not (null articles-by-group))
786 (let* ((group-articles (pop articles-by-group))
787 (artgroup (car group-articles))
788 (articleids (cadr group-articles))
789 (artlist (sort (mapcar 'cdr articleids) '<)))
790 (unless (gnus-check-backend-function 'request-expire-articles
791 artgroup)
792 (error "The group %s does not support article deletion" artgroup))
793 (unless (gnus-check-server (gnus-find-method-for-group artgroup))
794 (error "Couldn't open server for group %s" artgroup))
795 (push (gnus-request-expire-articles
796 artlist artgroup force)
797 not-deleted)))
798 (sort (delq nil not-deleted) '<))
799 articles))
801 (deffoo nnir-warp-to-article ()
802 (nnir-possibly-change-group gnus-newsgroup-name)
803 (let* ((cur (if (> (gnus-summary-article-number) 0)
804 (gnus-summary-article-number)
805 (error "Can't warp to a pseudo-article")))
806 (backend-article-group (nnir-article-group cur))
807 (backend-article-number (nnir-article-number cur))
808 ; (quit-config (gnus-ephemeral-group-p gnus-newsgroup-name))
811 ;; what should we do here? we could leave all the buffers around
812 ;; and assume that we have to exit from them one by one. or we can
813 ;; try to clean up directly
815 ;;first exit from the nnir summary buffer.
816 ; (gnus-summary-exit)
817 ;; and if the nnir summary buffer in turn came from another
818 ;; summary buffer we have to clean that summary up too.
819 ; (when (not (eq (cdr quit-config) 'group))
820 ; (gnus-summary-exit))
821 (gnus-summary-read-group-1 backend-article-group t t nil
822 nil (list backend-article-number))))
824 (deffoo nnir-request-update-mark (_group article mark)
825 (let ((artgroup (nnir-article-group article))
826 (artnumber (nnir-article-number article)))
827 (or (and artgroup
828 artnumber
829 (gnus-request-update-mark artgroup artnumber mark))
830 mark)))
832 (deffoo nnir-request-set-mark (group actions &optional server)
833 (nnir-possibly-change-group group server)
834 (let (mlist)
835 (dolist (action actions)
836 (cl-destructuring-bind (range action marks) action
837 (let ((articles-by-group (nnir-categorize
838 (gnus-uncompress-range range)
839 nnir-article-group nnir-article-number)))
840 (dolist (artgroup articles-by-group)
841 (push (list
842 (car artgroup)
843 (list (gnus-compress-sequence
844 (sort (cadr artgroup) '<))
845 action marks))
846 mlist)))))
847 (dolist (request (nnir-categorize mlist car cadr))
848 (gnus-request-set-mark (car request) (cadr request)))))
851 (deffoo nnir-request-update-info (group info &optional server)
852 (nnir-possibly-change-group group server)
853 ;; clear out all existing marks.
854 (gnus-info-set-marks info nil)
855 (gnus-info-set-read info nil)
856 (let ((group (gnus-group-guess-full-name-from-command-method group))
857 (articles-by-group
858 (nnir-categorize
859 (gnus-uncompress-range (cons 1 (nnir-artlist-length nnir-artlist)))
860 nnir-article-group nnir-article-ids)))
861 (gnus-set-active group
862 (cons 1 (nnir-artlist-length nnir-artlist)))
863 (while (not (null articles-by-group))
864 (let* ((group-articles (pop articles-by-group))
865 (articleids (reverse (cadr group-articles)))
866 (group-info (gnus-get-info (car group-articles)))
867 (marks (gnus-info-marks group-info))
868 (read (gnus-info-read group-info)))
869 (gnus-info-set-read
870 info
871 (gnus-add-to-range
872 (gnus-info-read info)
873 (delq nil
874 (mapcar
875 #'(lambda (art)
876 (when (gnus-member-of-range (cdr art) read) (car art)))
877 articleids))))
878 (dolist (mark marks)
879 (cl-destructuring-bind (type . range) mark
880 (gnus-add-marked-articles
881 group type
882 (delq nil
883 (mapcar
884 #'(lambda (art)
885 (when (gnus-member-of-range (cdr art) range) (car art)))
886 articleids)))))))))
889 (deffoo nnir-close-group (group &optional server)
890 (nnir-possibly-change-group group server)
891 (let ((pgroup (gnus-group-guess-full-name-from-command-method group)))
892 (when (and nnir-artlist (not (gnus-ephemeral-group-p pgroup)))
893 (gnus-group-set-parameter pgroup 'nnir-artlist nnir-artlist))
894 (setq nnir-artlist nil)
895 (when (gnus-ephemeral-group-p pgroup)
896 (gnus-kill-ephemeral-group pgroup)
897 (setq gnus-ephemeral-servers
898 (delq (assq 'nnir gnus-ephemeral-servers)
899 gnus-ephemeral-servers)))))
900 ;; (gnus-opened-servers-remove
901 ;; (car (assoc '(nnir "nnir-ephemeral" (nnir-address "nnir"))
902 ;; gnus-opened-servers))))
907 (defmacro nnir-add-result (dirnam artno score prefix server artlist)
908 "Ask `nnir-compose-result' to construct a result vector,
909 and if it is non-nil, add it to artlist."
910 `(let ((result (nnir-compose-result ,dirnam ,artno ,score ,prefix ,server)))
911 (when (not (null result))
912 (push result ,artlist))))
914 (autoload 'nnmaildir-base-name-to-article-number "nnmaildir")
916 ;; Helper function currently used by the Swish++ and Namazu backends;
917 ;; perhaps useful for other backends as well
918 (defun nnir-compose-result (dirnam article score prefix server)
919 "Extract the group from dirnam, and create a result vector
920 ready to be added to the list of search results."
922 ;; remove nnir-*-remove-prefix from beginning of dirnam filename
923 (when (string-match (concat "^" prefix) dirnam)
924 (setq dirnam (replace-match "" t t dirnam)))
926 (when (file-readable-p (concat prefix dirnam article))
927 ;; remove trailing slash and, for nnmaildir, cur/new/tmp
928 (setq dirnam
929 (substring dirnam 0
930 (if (string-match "\\`nnmaildir:" (gnus-group-server server))
931 -5 -1)))
933 ;; Set group to dirnam without any leading dots or slashes,
934 ;; and with all subsequent slashes replaced by dots
935 (let ((group (replace-regexp-in-string
936 "[/\\]" "."
937 (replace-regexp-in-string "^[./\\]" "" dirnam nil t)
938 nil t)))
940 (vector (gnus-group-full-name group server)
941 (if (string-match "\\`nnmaildir:" (gnus-group-server server))
942 (nnmaildir-base-name-to-article-number
943 (substring article 0 (string-match ":" article))
944 group nil)
945 (string-to-number article))
946 (string-to-number score)))))
948 ;;; Search Engine Interfaces:
950 (autoload 'nnimap-change-group "nnimap")
951 (declare-function nnimap-buffer "nnimap" ())
952 (declare-function nnimap-command "nnimap" (&rest args))
954 ;; imap interface
955 (defun nnir-run-imap (query srv &optional groups)
956 "Run a search against an IMAP back-end server.
957 This uses a custom query language parser; see `nnir-imap-make-query' for
958 details on the language and supported extensions."
959 (save-excursion
960 (let ((qstring (cdr (assq 'query query)))
961 (server (cadr (gnus-server-to-method srv)))
962 ;; (defs (nth 2 (gnus-server-to-method srv)))
963 (criteria (or (cdr (assq 'criteria query))
964 (cdr (assoc nnir-imap-default-search-key
965 nnir-imap-search-arguments))))
966 (gnus-inhibit-demon t)
967 (groups (or groups (nnir-get-active srv))))
968 (message "Opening server %s" server)
969 (apply
970 'vconcat
971 (catch 'found
972 (mapcar
973 #'(lambda (group)
974 (let (artlist)
975 (condition-case ()
976 (when (nnimap-change-group
977 (gnus-group-short-name group) server)
978 (with-current-buffer (nnimap-buffer)
979 (message "Searching %s..." group)
980 (let ((arts 0)
981 (result (nnimap-command "UID SEARCH %s"
982 (if (string= criteria "")
983 qstring
984 (nnir-imap-make-query
985 criteria qstring)))))
986 (mapc
987 (lambda (artnum)
988 (let ((artn (string-to-number artnum)))
989 (when (> artn 0)
990 (push (vector group artn 100)
991 artlist)
992 (when (assq 'shortcut query)
993 (throw 'found (list artlist)))
994 (setq arts (1+ arts)))))
995 (and (car result)
996 (cdr (assoc "SEARCH" (cdr result)))))
997 (message "Searching %s... %d matches" group arts)))
998 (message "Searching %s...done" group))
999 (quit nil))
1000 (nreverse artlist)))
1001 groups))))))
1003 (defun nnir-imap-make-query (criteria qstring)
1004 "Parse the query string and criteria into an appropriate IMAP search
1005 expression, returning the string query to make.
1007 This implements a little language designed to return the expected results
1008 to an arbitrary query string to the end user.
1010 The search is always case-insensitive, as defined by RFC2060, and supports
1011 the following features (inspired by the Google search input language):
1013 Automatic \"and\" queries
1014 If you specify multiple words then they will be treated as an \"and\"
1015 expression intended to match all components.
1017 Phrase searches
1018 If you wrap your query in double-quotes then it will be treated as a
1019 literal string.
1021 Negative terms
1022 If you precede a term with \"-\" then it will negate that.
1024 \"OR\" queries
1025 If you include an upper-case \"OR\" in your search it will cause the
1026 term before it and the term after it to be treated as alternatives.
1028 In future the following will be added to the language:
1029 * support for date matches
1030 * support for location of text matching within the query
1031 * from/to/etc headers
1032 * additional search terms
1033 * flag based searching
1034 * anything else that the RFC supports, basically."
1035 ;; Walk through the query and turn it into an IMAP query string.
1036 (nnir-imap-query-to-imap criteria (nnir-imap-parse-query qstring)))
1039 (defun nnir-imap-query-to-imap (criteria query)
1040 "Turn a s-expression format query into IMAP."
1041 (mapconcat
1042 ;; Turn the expressions into IMAP text
1043 (lambda (item)
1044 (nnir-imap-expr-to-imap criteria item))
1045 ;; The query, already in s-expr format.
1046 query
1047 ;; Append a space between each expression
1048 " "))
1051 (defun nnir-imap-expr-to-imap (criteria expr)
1052 "Convert EXPR into an IMAP search expression on CRITERIA"
1053 ;; What sort of expression is this, eh?
1054 (cond
1055 ;; Simple string term
1056 ((stringp expr)
1057 (format "%s %S" criteria expr))
1058 ;; Trivial term: and
1059 ((eq expr 'and) nil)
1060 ;; Composite term: or expression
1061 ((eq (car-safe expr) 'or)
1062 (format "OR %s %s"
1063 (nnir-imap-expr-to-imap criteria (nth 1 expr))
1064 (nnir-imap-expr-to-imap criteria (nth 2 expr))))
1065 ;; Composite term: just the fax, mam
1066 ((eq (car-safe expr) 'not)
1067 (format "NOT (%s)" (nnir-imap-query-to-imap criteria (cdr expr))))
1068 ;; Composite term: just expand it all.
1069 ((consp expr)
1070 (format "(%s)" (nnir-imap-query-to-imap criteria expr)))
1071 ;; Complex value, give up for now.
1072 (t (error "Unhandled input: %S" expr))))
1075 (defun nnir-imap-parse-query (string)
1076 "Turn STRING into an s-expression based query based on the IMAP
1077 query language as defined in `nnir-imap-make-query'.
1079 This involves turning individual tokens into higher level terms
1080 that the search language can then understand and use."
1081 (with-temp-buffer
1082 ;; Set up the parsing environment.
1083 (insert string)
1084 (goto-char (point-min))
1085 ;; Now, collect the output terms and return them.
1086 (let (out)
1087 (while (not (nnir-imap-end-of-input))
1088 (push (nnir-imap-next-expr) out))
1089 (reverse out))))
1092 (defun nnir-imap-next-expr (&optional count)
1093 "Return the next expression from the current buffer."
1094 (let ((term (nnir-imap-next-term count))
1095 (next (nnir-imap-peek-symbol)))
1096 ;; Are we looking at an 'or' expression?
1097 (cond
1098 ;; Handle 'expr or expr'
1099 ((eq next 'or)
1100 (list 'or term (nnir-imap-next-expr 2)))
1101 ;; Anything else
1102 (t term))))
1105 (defun nnir-imap-next-term (&optional count)
1106 "Return the next TERM from the current buffer."
1107 (let ((term (nnir-imap-next-symbol count)))
1108 ;; What sort of term is this?
1109 (cond
1110 ;; and -- just ignore it
1111 ((eq term 'and) 'and)
1112 ;; negated term
1113 ((eq term 'not) (list 'not (nnir-imap-next-expr)))
1114 ;; generic term
1115 (t term))))
1118 (defun nnir-imap-peek-symbol ()
1119 "Return the next symbol from the current buffer, but don't consume it."
1120 (save-excursion
1121 (nnir-imap-next-symbol)))
1123 (defun nnir-imap-next-symbol (&optional count)
1124 "Return the next symbol from the current buffer, or nil if we are
1125 at the end of the buffer. If supplied COUNT skips some symbols before
1126 returning the one at the supplied position."
1127 (when (and (numberp count) (> count 1))
1128 (nnir-imap-next-symbol (1- count)))
1129 (let ((case-fold-search t))
1130 ;; end of input stream?
1131 (unless (nnir-imap-end-of-input)
1132 ;; No, return the next symbol from the stream.
1133 (cond
1134 ;; negated expression -- return it and advance one char.
1135 ((looking-at "-") (forward-char 1) 'not)
1136 ;; quoted string
1137 ((looking-at "\"") (nnir-imap-delimited-string "\""))
1138 ;; list expression -- we parse the content and return this as a list.
1139 ((looking-at "(")
1140 (nnir-imap-parse-query (nnir-imap-delimited-string ")")))
1141 ;; keyword input -- return a symbol version
1142 ((looking-at "\\band\\b") (forward-char 3) 'and)
1143 ((looking-at "\\bor\\b") (forward-char 2) 'or)
1144 ((looking-at "\\bnot\\b") (forward-char 3) 'not)
1145 ;; Simple, boring keyword
1146 (t (let ((start (point))
1147 (end (if (search-forward-regexp "[[:blank:]]" nil t)
1148 (prog1
1149 (match-beginning 0)
1150 ;; unskip if we hit a non-blank terminal character.
1151 (when (string-match "[^[:blank:]]" (match-string 0))
1152 (backward-char 1)))
1153 (goto-char (point-max)))))
1154 (buffer-substring start end)))))))
1156 (defun nnir-imap-delimited-string (delimiter)
1157 "Return a delimited string from the current buffer."
1158 (let ((start (point)) end)
1159 (forward-char 1) ; skip the first delimiter.
1160 (while (not end)
1161 (unless (search-forward delimiter nil t)
1162 (error "Unmatched delimited input with %s in query" delimiter))
1163 (let ((here (point)))
1164 (unless (equal (buffer-substring (- here 2) (- here 1)) "\\")
1165 (setq end (point)))))
1166 (buffer-substring (1+ start) (1- end))))
1168 (defun nnir-imap-end-of-input ()
1169 "Are we at the end of input?"
1170 (skip-chars-forward "[[:blank:]]")
1171 (looking-at "$"))
1174 ;; Swish++ interface.
1175 ;; -cc- Todo
1176 ;; Search by
1177 ;; - group
1178 ;; Sort by
1179 ;; - rank (default)
1180 ;; - article number
1181 ;; - file size
1182 ;; - group
1183 (defun nnir-run-swish++ (query server &optional _group)
1184 "Run QUERY against swish++.
1185 Returns a vector of (group name, file name) pairs (also vectors,
1186 actually).
1188 Tested with swish++ 4.7 on GNU/Linux and with swish++ 5.0b2 on
1189 Windows NT 4.0."
1191 ;; (when group
1192 ;; (error "The swish++ backend cannot search specific groups"))
1194 (save-excursion
1195 (let ( (qstring (cdr (assq 'query query)))
1196 (groupspec (cdr (assq 'swish++-group query)))
1197 (prefix (nnir-read-server-parm 'nnir-swish++-remove-prefix server))
1198 artlist
1199 ;; nnml-use-compressed-files might be any string, but probably this
1200 ;; is sufficient. Note that we can't only use the value of
1201 ;; nnml-use-compressed-files because old articles might have been
1202 ;; saved with a different value.
1203 (article-pattern (if (string-match "\\`nnmaildir:"
1204 (gnus-group-server server))
1205 ":[0-9]+"
1206 "^[0-9]+\\(\\.[a-z0-9]+\\)?$"))
1207 score artno dirnam filenam)
1209 (when (equal "" qstring)
1210 (error "swish++: You didn't enter anything"))
1212 (set-buffer (get-buffer-create nnir-tmp-buffer))
1213 (erase-buffer)
1215 (if groupspec
1216 (message "Doing swish++ query %s on %s..." qstring groupspec)
1217 (message "Doing swish++ query %s..." qstring))
1219 (let* ((cp-list `( ,nnir-swish++-program
1220 nil ; input from /dev/null
1221 t ; output
1222 nil ; don't redisplay
1223 "--config-file" ,(nnir-read-server-parm 'nnir-swish++-configuration-file server)
1224 ,@(nnir-read-server-parm 'nnir-swish++-additional-switches server)
1225 ,qstring ; the query, in swish++ format
1227 (exitstatus
1228 (progn
1229 (message "%s args: %s" nnir-swish++-program
1230 (mapconcat #'identity (nthcdr 4 cp-list) " ")) ;; ???
1231 (apply #'call-process cp-list))))
1232 (unless (or (null exitstatus)
1233 (zerop exitstatus))
1234 (nnheader-report 'nnir "Couldn't run swish++: %s" exitstatus)
1235 ;; swish++ failure reason is in this buffer, show it if
1236 ;; the user wants it.
1237 (when (> gnus-verbose 6)
1238 (display-buffer nnir-tmp-buffer))))
1240 ;; The results are output in the format of:
1241 ;; V 4.7 Linux
1242 ;; rank relative-path-name file-size file-title
1243 ;; V 5.0b2:
1244 ;; rank relative-path-name file-size topic??
1245 ;; where rank is an integer from 1 to 100.
1246 (goto-char (point-min))
1247 (while (re-search-forward
1248 "\\(^[0-9]+\\) \\([^ ]+\\) [0-9]+ \\(.*\\)$" nil t)
1249 (setq score (match-string 1)
1250 filenam (match-string 2)
1251 artno (file-name-nondirectory filenam)
1252 dirnam (file-name-directory filenam))
1254 ;; don't match directories
1255 (when (string-match article-pattern artno)
1256 (when (not (null dirnam))
1258 ;; maybe limit results to matching groups.
1259 (when (or (not groupspec)
1260 (string-match groupspec dirnam))
1261 (nnir-add-result dirnam artno score prefix server artlist)))))
1263 (message "Massaging swish++ output...done")
1265 ;; Sort by score
1266 (apply #'vector
1267 (sort artlist
1268 (function (lambda (x y)
1269 (> (nnir-artitem-rsv x)
1270 (nnir-artitem-rsv y)))))))))
1272 ;; Swish-E interface.
1273 (defun nnir-run-swish-e (query server &optional _group)
1274 "Run given query against swish-e.
1275 Returns a vector of (group name, file name) pairs (also vectors,
1276 actually).
1278 Tested with swish-e-2.0.1 on Windows NT 4.0."
1280 ;; swish-e crashes with empty parameter to "-w" on commandline...
1281 ;; (when group
1282 ;; (error "The swish-e backend cannot search specific groups"))
1284 (save-excursion
1285 (let ((qstring (cdr (assq 'query query)))
1286 (prefix
1287 (or (nnir-read-server-parm 'nnir-swish-e-remove-prefix server)
1288 (error "Missing parameter `nnir-swish-e-remove-prefix'")))
1289 artlist score artno dirnam group )
1291 (when (equal "" qstring)
1292 (error "swish-e: You didn't enter anything"))
1294 (set-buffer (get-buffer-create nnir-tmp-buffer))
1295 (erase-buffer)
1297 (message "Doing swish-e query %s..." query)
1298 (let* ((index-files
1299 (or (nnir-read-server-parm
1300 'nnir-swish-e-index-files server)
1301 (error "Missing parameter `nnir-swish-e-index-files'")))
1302 (additional-switches
1303 (nnir-read-server-parm
1304 'nnir-swish-e-additional-switches server))
1305 (cp-list `(,nnir-swish-e-program
1306 nil ; input from /dev/null
1307 t ; output
1308 nil ; don't redisplay
1309 "-f" ,@index-files
1310 ,@additional-switches
1311 "-w"
1312 ,qstring ; the query, in swish-e format
1314 (exitstatus
1315 (progn
1316 (message "%s args: %s" nnir-swish-e-program
1317 (mapconcat #'identity (nthcdr 4 cp-list) " "))
1318 (apply #'call-process cp-list))))
1319 (unless (or (null exitstatus)
1320 (zerop exitstatus))
1321 (nnheader-report 'nnir "Couldn't run swish-e: %s" exitstatus)
1322 ;; swish-e failure reason is in this buffer, show it if
1323 ;; the user wants it.
1324 (when (> gnus-verbose 6)
1325 (display-buffer nnir-tmp-buffer))))
1327 ;; The results are output in the format of:
1328 ;; rank path-name file-title file-size
1329 (goto-char (point-min))
1330 (while (re-search-forward
1331 "\\(^[0-9]+\\) \\([^ ]+\\) \"\\([^\"]+\\)\" [0-9]+$" nil t)
1332 (setq score (match-string 1)
1333 artno (match-string 3)
1334 dirnam (file-name-directory (match-string 2)))
1336 ;; don't match directories
1337 (when (string-match "^[0-9]+$" artno)
1338 (when (not (null dirnam))
1340 ;; remove nnir-swish-e-remove-prefix from beginning of dirname
1341 (when (string-match (concat "^" prefix) dirnam)
1342 (setq dirnam (replace-match "" t t dirnam)))
1344 (setq dirnam (substring dirnam 0 -1))
1345 ;; eliminate all ".", "/", "\" from beginning. Always matches.
1346 (string-match "^[./\\]*\\(.*\\)$" dirnam)
1347 ;; "/" -> "."
1348 (setq group (replace-regexp-in-string
1349 "/" "." (match-string 1 dirnam)))
1350 ;; Windows "\\" -> "."
1351 (setq group (replace-regexp-in-string "\\\\" "." group))
1353 (push (vector (gnus-group-full-name group server)
1354 (string-to-number artno)
1355 (string-to-number score))
1356 artlist))))
1358 (message "Massaging swish-e output...done")
1360 ;; Sort by score
1361 (apply #'vector
1362 (sort artlist
1363 (function (lambda (x y)
1364 (> (nnir-artitem-rsv x)
1365 (nnir-artitem-rsv y)))))))))
1367 ;; HyREX interface
1368 (defun nnir-run-hyrex (query server &optional group)
1369 (save-excursion
1370 (let ((artlist nil)
1371 (groupspec (cdr (assq 'hyrex-group query)))
1372 (qstring (cdr (assq 'query query)))
1373 (prefix (nnir-read-server-parm 'nnir-hyrex-remove-prefix server))
1374 score artno dirnam)
1375 (when (and (not groupspec) group)
1376 (setq groupspec
1377 (regexp-opt
1378 (mapcar (lambda (x) (gnus-group-real-name x)) group))))
1379 (set-buffer (get-buffer-create nnir-tmp-buffer))
1380 (erase-buffer)
1381 (message "Doing hyrex-search query %s..." query)
1382 (let* ((cp-list
1383 `( ,nnir-hyrex-program
1384 nil ; input from /dev/null
1385 t ; output
1386 nil ; don't redisplay
1387 "-i",(nnir-read-server-parm 'nnir-hyrex-index-directory server) ; index directory
1388 ,@(nnir-read-server-parm 'nnir-hyrex-additional-switches server)
1389 ,qstring ; the query, in hyrex-search format
1391 (exitstatus
1392 (progn
1393 (message "%s args: %s" nnir-hyrex-program
1394 (mapconcat #'identity (nthcdr 4 cp-list) " "))
1395 (apply #'call-process cp-list))))
1396 (unless (or (null exitstatus)
1397 (zerop exitstatus))
1398 (nnheader-report 'nnir "Couldn't run hyrex-search: %s" exitstatus)
1399 ;; nnir-search failure reason is in this buffer, show it if
1400 ;; the user wants it.
1401 (when (> gnus-verbose 6)
1402 (display-buffer nnir-tmp-buffer)))) ;; FIXME: Don't clear buffer !
1403 (message "Doing hyrex-search query \"%s\"...done" qstring)
1404 (sit-for 0)
1405 ;; nnir-search returns:
1406 ;; for nnml/nnfolder: "filename mailid weight"
1407 ;; for nnimap: "group mailid weight"
1408 (goto-char (point-min))
1409 (delete-non-matching-lines "^\\S + [0-9]+ [0-9]+$")
1410 ;; HyREX doesn't search directly in groups -- so filter out here.
1411 (when groupspec
1412 (keep-lines groupspec))
1413 ;; extract data from result lines
1414 (goto-char (point-min))
1415 (while (re-search-forward
1416 "\\(\\S +\\) \\([0-9]+\\) \\([0-9]+\\)" nil t)
1417 (setq dirnam (match-string 1)
1418 artno (match-string 2)
1419 score (match-string 3))
1420 (when (string-match prefix dirnam)
1421 (setq dirnam (replace-match "" t t dirnam)))
1422 (push (vector (gnus-group-full-name
1423 (replace-regexp-in-string "/" "." dirnam) server)
1424 (string-to-number artno)
1425 (string-to-number score))
1426 artlist))
1427 (message "Massaging hyrex-search output...done.")
1428 (apply #'vector
1429 (sort artlist
1430 (function (lambda (x y)
1431 (if (string-lessp (nnir-artitem-group x)
1432 (nnir-artitem-group y))
1434 (< (nnir-artitem-number x)
1435 (nnir-artitem-number y)))))))
1438 ;; Namazu interface
1439 (defun nnir-run-namazu (query server &optional _group)
1440 "Run given query against Namazu. Returns a vector of (group name, file name)
1441 pairs (also vectors, actually).
1443 Tested with Namazu 2.0.6 on a GNU/Linux system."
1444 ;; (when group
1445 ;; (error "The Namazu backend cannot search specific groups"))
1446 (save-excursion
1447 (let ((article-pattern (if (string-match "\\`nnmaildir:"
1448 (gnus-group-server server))
1449 ":[0-9]+"
1450 "^[0-9]+$"))
1451 artlist
1452 (qstring (cdr (assq 'query query)))
1453 (prefix (nnir-read-server-parm 'nnir-namazu-remove-prefix server))
1454 score group article
1455 (process-environment (copy-sequence process-environment)))
1456 (setenv "LC_MESSAGES" "C")
1457 (set-buffer (get-buffer-create nnir-tmp-buffer))
1458 (erase-buffer)
1459 (let* ((cp-list
1460 `( ,nnir-namazu-program
1461 nil ; input from /dev/null
1462 t ; output
1463 nil ; don't redisplay
1464 "-q" ; don't be verbose
1465 "-a" ; show all matches
1466 "-s" ; use short format
1467 ,@(nnir-read-server-parm 'nnir-namazu-additional-switches server)
1468 ,qstring ; the query, in namazu format
1469 ,(nnir-read-server-parm 'nnir-namazu-index-directory server) ; index directory
1471 (exitstatus
1472 (progn
1473 (message "%s args: %s" nnir-namazu-program
1474 (mapconcat #'identity (nthcdr 4 cp-list) " "))
1475 (apply #'call-process cp-list))))
1476 (unless (or (null exitstatus)
1477 (zerop exitstatus))
1478 (nnheader-report 'nnir "Couldn't run namazu: %s" exitstatus)
1479 ;; Namazu failure reason is in this buffer, show it if
1480 ;; the user wants it.
1481 (when (> gnus-verbose 6)
1482 (display-buffer nnir-tmp-buffer))))
1484 ;; Namazu output looks something like this:
1485 ;; 2. Re: Gnus agent expire broken (score: 55)
1486 ;; /home/henrik/Mail/mail/sent/1310 (4,138 bytes)
1488 (goto-char (point-min))
1489 (while (re-search-forward
1490 "^\\([0-9,]+\\.\\).*\\((score: \\([0-9]+\\)\\))\n\\([^ ]+\\)"
1491 nil t)
1492 (setq score (match-string 3)
1493 group (file-name-directory (match-string 4))
1494 article (file-name-nondirectory (match-string 4)))
1496 ;; make sure article and group is sane
1497 (when (and (string-match article-pattern article)
1498 (not (null group)))
1499 (nnir-add-result group article score prefix server artlist)))
1501 ;; sort artlist by score
1502 (apply #'vector
1503 (sort artlist
1504 (function (lambda (x y)
1505 (> (nnir-artitem-rsv x)
1506 (nnir-artitem-rsv y)))))))))
1508 (defun nnir-run-notmuch (query server &optional _group)
1509 "Run QUERY against notmuch.
1510 Returns a vector of (group name, file name) pairs (also vectors,
1511 actually)."
1513 ;; (when group
1514 ;; (error "The notmuch backend cannot search specific groups"))
1516 (save-excursion
1517 (let ( (qstring (cdr (assq 'query query)))
1518 (groupspec (cdr (assq 'notmuch-group query)))
1519 (prefix (nnir-read-server-parm 'nnir-notmuch-remove-prefix server))
1520 artlist
1521 (article-pattern (if (string-match "\\`nnmaildir:"
1522 (gnus-group-server server))
1523 ":[0-9]+"
1524 "^[0-9]+$"))
1525 artno dirnam filenam)
1527 (when (equal "" qstring)
1528 (error "notmuch: You didn't enter anything"))
1530 (set-buffer (get-buffer-create nnir-tmp-buffer))
1531 (erase-buffer)
1533 (if groupspec
1534 (message "Doing notmuch query %s on %s..." qstring groupspec)
1535 (message "Doing notmuch query %s..." qstring))
1537 (let* ((cp-list `( ,nnir-notmuch-program
1538 nil ; input from /dev/null
1539 t ; output
1540 nil ; don't redisplay
1541 "search"
1542 "--format=text"
1543 "--output=files"
1544 ,@(nnir-read-server-parm 'nnir-notmuch-additional-switches server)
1545 ,qstring ; the query, in notmuch format
1547 (exitstatus
1548 (progn
1549 (message "%s args: %s" nnir-notmuch-program
1550 (mapconcat #'identity (nthcdr 4 cp-list) " ")) ;; ???
1551 (apply #'call-process cp-list))))
1552 (unless (or (null exitstatus)
1553 (zerop exitstatus))
1554 (nnheader-report 'nnir "Couldn't run notmuch: %s" exitstatus)
1555 ;; notmuch failure reason is in this buffer, show it if
1556 ;; the user wants it.
1557 (when (> gnus-verbose 6)
1558 (display-buffer nnir-tmp-buffer))))
1560 ;; The results are output in the format of:
1561 ;; absolute-path-name
1562 (goto-char (point-min))
1563 (while (not (eobp))
1564 (setq filenam (buffer-substring-no-properties (line-beginning-position)
1565 (line-end-position))
1566 artno (file-name-nondirectory filenam)
1567 dirnam (file-name-directory filenam))
1568 (forward-line 1)
1570 ;; don't match directories
1571 (when (string-match article-pattern artno)
1572 (when (not (null dirnam))
1574 ;; maybe limit results to matching groups.
1575 (when (or (not groupspec)
1576 (string-match groupspec dirnam))
1577 (nnir-add-result dirnam artno "" prefix server artlist)))))
1579 (message "Massaging notmuch output...done")
1581 artlist)))
1583 (defun nnir-run-find-grep (query server &optional grouplist)
1584 "Run find and grep to obtain matching articles."
1585 (let* ((method (gnus-server-to-method server))
1586 (sym (intern
1587 (concat (symbol-name (car method)) "-directory")))
1588 (directory (cadr (assoc sym (cddr method))))
1589 (regexp (cdr (assoc 'query query)))
1590 (grep-options (cdr (assoc 'grep-options query)))
1591 (grouplist (or grouplist (nnir-get-active server))))
1592 (unless directory
1593 (error "No directory found in method specification of server %s"
1594 server))
1595 (apply
1596 'vconcat
1597 (mapcar (lambda (x)
1598 (let ((group x)
1599 artlist)
1600 (message "Searching %s using find-grep..."
1601 (or group server))
1602 (save-window-excursion
1603 (set-buffer (get-buffer-create nnir-tmp-buffer))
1604 (if (> gnus-verbose 6)
1605 (pop-to-buffer (current-buffer)))
1606 (cd directory) ; Using relative paths simplifies
1607 ; postprocessing.
1608 (let ((group
1609 (if (not group)
1611 ;; Try accessing the group literally as
1612 ;; well as interpreting dots as directory
1613 ;; separators so the engine works with
1614 ;; plain nnml as well as the Gnus Cache.
1615 (let ((group (gnus-group-real-name group)))
1616 ;; Replace cl-func find-if.
1617 (if (file-directory-p group)
1618 group
1619 (if (file-directory-p
1620 (setq group
1621 (replace-regexp-in-string
1622 "\\." "/"
1623 group nil t)))
1624 group))))))
1625 (unless group
1626 (error "Cannot locate directory for group"))
1627 (save-excursion
1628 (apply
1629 'call-process "find" nil t
1630 "find" group "-maxdepth" "1" "-type" "f"
1631 "-name" "[0-9]*" "-exec"
1632 "grep"
1633 `("-l" ,@(and grep-options
1634 (split-string grep-options "\\s-" t))
1635 "-e" ,regexp "{}" "+"))))
1637 ;; Translate relative paths to group names.
1638 (while (not (eobp))
1639 (let* ((path (split-string
1640 (buffer-substring
1641 (point)
1642 (line-end-position)) "/" t))
1643 (art (string-to-number (car (last path)))))
1644 (while (string= "." (car path))
1645 (setq path (cdr path)))
1646 (let ((group (mapconcat #'identity
1647 ;; Replace cl-func:
1648 ;; (subseq path 0 -1)
1649 (let ((end (1- (length path)))
1650 res)
1651 (while
1652 (>= (setq end (1- end)) 0)
1653 (push (pop path) res))
1654 (nreverse res))
1655 ".")))
1656 (push
1657 (vector (gnus-group-full-name group server) art 0)
1658 artlist))
1659 (forward-line 1)))
1660 (message "Searching %s using find-grep...done"
1661 (or group server))
1662 artlist)))
1663 grouplist))))
1665 (declare-function mm-url-insert "mm-url" (url &optional follow-refresh))
1666 (declare-function mm-url-encode-www-form-urlencoded "mm-url" (pairs))
1668 ;;; Util Code:
1670 (defun gnus-nnir-group-p (group)
1671 "Say whether GROUP is nnir or not."
1672 (if (gnus-group-prefixed-p group)
1673 (eq 'nnir (car (gnus-find-method-for-group group)))
1674 (and group (string-match "^nnir" group))))
1676 (defun nnir-read-parms (nnir-search-engine)
1677 "Reads additional search parameters according to `nnir-engines'."
1678 (let ((parmspec (nth 2 (assoc nnir-search-engine nnir-engines))))
1679 (mapcar #'nnir-read-parm parmspec)))
1681 (defun nnir-read-parm (parmspec)
1682 "Reads a single search parameter.
1683 `parmspec' is a cons cell, the car is a symbol, the cdr is a prompt."
1684 (let ((sym (car parmspec))
1685 (prompt (cdr parmspec)))
1686 (if (listp prompt)
1687 (let* ((result (apply #'gnus-completing-read prompt))
1688 (mapping (or (assoc result nnir-imap-search-arguments)
1689 (cons nil nnir-imap-search-other))))
1690 (cons sym (format (cdr mapping) result)))
1691 (cons sym (read-string prompt)))))
1693 (defun nnir-run-query (specs)
1694 "Invoke appropriate search engine function (see `nnir-engines')."
1695 (apply #'vconcat
1696 (mapcar
1697 (lambda (x)
1698 (let* ((server (car x))
1699 (search-engine (nnir-server-to-search-engine server))
1700 (search-func (cadr (assoc search-engine nnir-engines))))
1701 (and search-func
1702 (funcall search-func (cdr (assq 'nnir-query-spec specs))
1703 server (cadr x)))))
1704 (cdr (assq 'nnir-group-spec specs)))))
1706 (defun nnir-server-to-search-engine (server)
1707 (or (nnir-read-server-parm 'nnir-search-engine server t)
1708 (cdr (assoc (car (gnus-server-to-method server))
1709 nnir-method-default-engines))))
1711 (defun nnir-read-server-parm (key server &optional not-global)
1712 "Returns the parameter value corresponding to `key' for
1713 `server'. If no server-specific value is found consult the global
1714 environment unless `not-global' is non-nil."
1715 (let ((method (gnus-server-to-method server)))
1716 (cond ((and method (assq key (cddr method)))
1717 (nth 1 (assq key (cddr method))))
1718 ((and (not not-global) (boundp key)) (symbol-value key))
1719 (t nil))))
1721 (defun nnir-possibly-change-group (group &optional server)
1722 (or (not server) (nnir-server-opened server) (nnir-open-server server))
1723 (when (gnus-nnir-group-p group)
1724 (setq nnir-artlist (gnus-group-get-parameter
1725 (gnus-group-prefixed-name
1726 (gnus-group-short-name group) '(nnir "nnir"))
1727 'nnir-artlist t))))
1729 (defun nnir-server-opened (&optional server)
1730 (let ((backend (car (gnus-server-to-method server))))
1731 (nnoo-current-server-p (or backend 'nnir) server)))
1733 (autoload 'nnimap-make-thread-query "nnimap")
1734 (declare-function gnus-registry-get-id-key "gnus-registry" (id key))
1736 (defun nnir-search-thread (header)
1737 "Make an nnir group based on the thread containing the article
1738 header. The current server will be searched. If the registry is
1739 installed, the server that the registry reports the current
1740 article came from is also searched."
1741 (let* ((query
1742 (list (cons 'query (nnimap-make-thread-query header))
1743 (cons 'criteria "")))
1744 (server
1745 (list (list (gnus-method-to-server
1746 (gnus-find-method-for-group gnus-newsgroup-name)))))
1747 (registry-group (and
1748 (bound-and-true-p gnus-registry-enabled)
1749 (car (gnus-registry-get-id-key
1750 (mail-header-id header) 'group))))
1751 (registry-server
1752 (and registry-group
1753 (gnus-method-to-server
1754 (gnus-find-method-for-group registry-group)))))
1755 (when registry-server
1756 (cl-pushnew (list registry-server) server :test #'equal))
1757 (gnus-group-make-nnir-group nil (list
1758 (cons 'nnir-query-spec query)
1759 (cons 'nnir-group-spec server)))
1760 (gnus-summary-goto-subject (gnus-id-to-article (mail-header-id header)))))
1762 (defun nnir-get-active (srv)
1763 (let ((method (gnus-server-to-method srv))
1764 groups)
1765 (gnus-request-list method)
1766 (with-current-buffer nntp-server-buffer
1767 (let ((cur (current-buffer)))
1768 (goto-char (point-min))
1769 (unless (or (null nnir-ignored-newsgroups)
1770 (string= nnir-ignored-newsgroups ""))
1771 (delete-matching-lines nnir-ignored-newsgroups))
1772 (if (eq (car method) 'nntp)
1773 (while (not (eobp))
1774 (ignore-errors
1775 (push (gnus-group-full-name
1776 (buffer-substring
1777 (point)
1778 (progn
1779 (skip-chars-forward "^ \t")
1780 (point)))
1781 method)
1782 groups))
1783 (forward-line))
1784 (while (not (eobp))
1785 (ignore-errors
1786 (push (if (eq (char-after) ?\")
1787 (gnus-group-full-name (read cur) method)
1788 (let ((p (point)) (name ""))
1789 (skip-chars-forward "^ \t\\\\")
1790 (setq name (buffer-substring p (point)))
1791 (while (eq (char-after) ?\\)
1792 (setq p (1+ (point)))
1793 (forward-char 2)
1794 (skip-chars-forward "^ \t\\\\")
1795 (setq name (concat name (buffer-substring
1796 p (point)))))
1797 (gnus-group-full-name name method)))
1798 groups))
1799 (forward-line)))))
1800 groups))
1802 ;; Behind gnus-registry-enabled test.
1803 (declare-function gnus-registry-action "gnus-registry"
1804 (action data-header from &optional to method))
1806 (defun nnir-registry-action (action data-header _from &optional to method)
1807 "Call `gnus-registry-action' with the original article group."
1808 (gnus-registry-action
1809 action
1810 data-header
1811 (nnir-article-group (mail-header-number data-header))
1813 method))
1815 (defun nnir-mode ()
1816 (when (eq (car (gnus-find-method-for-group gnus-newsgroup-name)) 'nnir)
1817 (setq gnus-summary-line-format
1818 (or nnir-summary-line-format gnus-summary-line-format))
1819 (when (bound-and-true-p gnus-registry-enabled)
1820 (remove-hook 'gnus-summary-article-delete-hook 'gnus-registry-action t)
1821 (remove-hook 'gnus-summary-article-move-hook 'gnus-registry-action t)
1822 (remove-hook 'gnus-summary-article-expire-hook 'gnus-registry-action t)
1823 (add-hook 'gnus-summary-article-delete-hook 'nnir-registry-action t t)
1824 (add-hook 'gnus-summary-article-move-hook 'nnir-registry-action t t)
1825 (add-hook 'gnus-summary-article-expire-hook 'nnir-registry-action t t))))
1828 (defun gnus-summary-create-nnir-group ()
1829 (interactive)
1830 (or (nnir-server-opened "") (nnir-open-server "nnir"))
1831 (let ((name (gnus-read-group "Group name: "))
1832 (method '(nnir ""))
1833 (pgroup
1834 (gnus-group-guess-full-name-from-command-method gnus-newsgroup-name)))
1835 (with-current-buffer gnus-group-buffer
1836 (gnus-group-make-group
1837 name method nil
1838 (gnus-group-find-parameter pgroup)))))
1841 (deffoo nnir-request-create-group (group &optional _server args)
1842 (message "Creating nnir group %s" group)
1843 (let* ((group (gnus-group-prefixed-name group '(nnir "nnir")))
1844 (specs (assq 'nnir-specs args))
1845 (query-spec
1846 (or (cdr (assq 'nnir-query-spec specs))
1847 (list (cons 'query
1848 (read-string "Query: " nil 'nnir-search-history)))))
1849 (group-spec
1850 (or (cdr (assq 'nnir-group-spec specs))
1851 (list (list (read-string "Server: " nil nil)))))
1852 (nnir-specs (list (cons 'nnir-query-spec query-spec)
1853 (cons 'nnir-group-spec group-spec))))
1854 (gnus-group-set-parameter group 'nnir-specs nnir-specs)
1855 (gnus-group-set-parameter
1856 group 'nnir-artlist
1857 (or (cdr (assq 'nnir-artlist args))
1858 (nnir-run-query nnir-specs)))
1859 (nnir-request-update-info group (gnus-get-info group)))
1862 (deffoo nnir-request-delete-group (_group &optional _force _server)
1865 (deffoo nnir-request-list (&optional _server)
1868 (deffoo nnir-request-scan (_group _method)
1871 (deffoo nnir-request-close ()
1874 (nnoo-define-skeleton nnir)
1876 ;; The end.
1877 (provide 'nnir)
1879 ;;; nnir.el ends here