Mercurial > emacs
comparison lisp/gnus/nnir.el @ 111217:7be484934a7c
nnir.el (nnir-run-swish-e): Remove hyrex support.
author | Katsumi Yamaoka <yamaoka@jpl.org> |
---|---|
date | Thu, 28 Oct 2010 10:41:27 +0000 |
parents | 11259a64bfc0 |
children | dd1304e89176 |
comparison
equal
deleted
inserted
replaced
111216:5d7d30110595 | 111217:7be484934a7c |
---|---|
76 ;; searching your mail. Note that you also need to configure a number | 76 ;; searching your mail. Note that you also need to configure a number |
77 ;; of variables, as described below. | 77 ;; of variables, as described below. |
78 | 78 |
79 ;; Restrictions: | 79 ;; Restrictions: |
80 ;; | 80 ;; |
81 ;; * If you don't use HyREX as your search engine, this expects that | 81 ;; * This expects that you use nnml or another one-file-per-message backend, |
82 ;; you use nnml or another one-file-per-message backend, because the | 82 ;; because the others doesn't support nnfolder. |
83 ;; others doesn't support nnfolder. | |
84 ;; * It can only search the mail backend's which are supported by one | 83 ;; * It can only search the mail backend's which are supported by one |
85 ;; search engine, because of different query languages. | 84 ;; search engine, because of different query languages. |
86 ;; * There are restrictions to the Wais setup. | 85 ;; * There are restrictions to the Wais setup. |
87 ;; * There are restrictions to the imap setup. | 86 ;; * There are restrictions to the imap setup. |
88 ;; * gnus-summary-nnir-goto-thread: Fetches whole group first, before | 87 ;; * gnus-summary-nnir-goto-thread: Fetches whole group first, before |
94 ;; The Lisp setup involves setting a few variables and setting up the | 93 ;; The Lisp setup involves setting a few variables and setting up the |
95 ;; search engine. You can define the variables in the server definition | 94 ;; search engine. You can define the variables in the server definition |
96 ;; like this : | 95 ;; like this : |
97 ;; (setq gnus-secondary-select-methods '( | 96 ;; (setq gnus-secondary-select-methods '( |
98 ;; (nnimap "" (nnimap-address "localhost") | 97 ;; (nnimap "" (nnimap-address "localhost") |
99 ;; (nnir-search-engine hyrex) | 98 ;; (nnir-search-engine namazu) |
100 ;; (nnir-hyrex-additional-switches ("-d" "ddl-nnimap.xml")) | |
101 ;; ))) | 99 ;; ))) |
102 ;; Or you can define the global ones. The variables set in the mailer- | 100 ;; Or you can define the global ones. The variables set in the mailer- |
103 ;; definition will be used first. | 101 ;; definition will be used first. |
104 ;; The variable to set is `nnir-search-engine'. Choose one of the engines | 102 ;; The variable to set is `nnir-search-engine'. Choose one of the engines |
105 ;; listed in `nnir-engines'. (Actually `nnir-engines' is an alist, | 103 ;; listed in `nnir-engines'. (Actually `nnir-engines' is an alist, |
225 ;; mknmz --mailnews ~/Mail/archive/ ~/Mail/mail/ ~/Mail/lists/ | 223 ;; mknmz --mailnews ~/Mail/archive/ ~/Mail/mail/ ~/Mail/lists/ |
226 ;; | 224 ;; |
227 ;; For maximum searching efficiency I have a cron job set to run this | 225 ;; For maximum searching efficiency I have a cron job set to run this |
228 ;; command every four hours. | 226 ;; command every four hours. |
229 | 227 |
230 ;; 3. HyREX | 228 ;; 3. find-grep |
231 ;; | |
232 ;; The HyREX backend requires you to have one directory from where all | |
233 ;; your relative paths are to, if you use them. This directory must be | |
234 ;; set in the `nnir-hyrex-index-directory' variable, which defaults to | |
235 ;; your home directory. You must also pass the base, class and | |
236 ;; directory options or simply your dll to the `nnir-hyrex-programm' by | |
237 ;; setting the `nnir-hyrex-additional-switches' variable accordently. | |
238 ;; To function the `nnir-hyrex-remove-prefix' variable must also be | |
239 ;; correct, see the documentation for `nnir-wais-remove-prefix' above. | |
240 | |
241 ;; 4. find-grep | |
242 ;; | 229 ;; |
243 ;; The find-grep engine simply runs find(1) to locate eligible | 230 ;; The find-grep engine simply runs find(1) to locate eligible |
244 ;; articles and searches them with grep(1). This, of course, is much | 231 ;; articles and searches them with grep(1). This, of course, is much |
245 ;; slower than using a proper search engine but OTOH doesn't require | 232 ;; slower than using a proper search engine but OTOH doesn't require |
246 ;; maintenance of an index and is still faster than using any built-in | 233 ;; maintenance of an index and is still faster than using any built-in |
317 ;; people use nnfolder. How would one go about searching nnfolders | 304 ;; people use nnfolder. How would one go about searching nnfolders |
318 ;; and producing the right data needed? The group name and the RSV | 305 ;; and producing the right data needed? The group name and the RSV |
319 ;; are simple, but what about the article number? | 306 ;; are simple, but what about the article number? |
320 ;; - The article number is encoded in the `X-Gnus-Article-Number' | 307 ;; - The article number is encoded in the `X-Gnus-Article-Number' |
321 ;; header of each mail. | 308 ;; header of each mail. |
322 ;; - The HyREX engine supports nnfolder. | |
323 ;; | 309 ;; |
324 ;; * Support compressed mail files. Probably, just stripping off the | 310 ;; * Support compressed mail files. Probably, just stripping off the |
325 ;; `.gz' or `.Z' file name extension is sufficient. | 311 ;; `.gz' or `.Z' file name extension is sufficient. |
326 ;; | 312 ;; |
327 ;; * At least for imap, the query is performed twice. | 313 ;; * At least for imap, the query is performed twice. |
401 ((group . "Group spec: "))) | 387 ((group . "Group spec: "))) |
402 (swish-e nnir-run-swish-e | 388 (swish-e nnir-run-swish-e |
403 ((group . "Group spec: "))) | 389 ((group . "Group spec: "))) |
404 (namazu nnir-run-namazu | 390 (namazu nnir-run-namazu |
405 ()) | 391 ()) |
406 (hyrex nnir-run-hyrex | |
407 ((group . "Group spec: "))) | |
408 (find-grep nnir-run-find-grep | 392 (find-grep nnir-run-find-grep |
409 ((grep-options . "Grep options: ")))) | 393 ((grep-options . "Grep options: ")))) |
410 "Alist of supported search engines. | 394 "Alist of supported search engines. |
411 Each element in the alist is a three-element list (ENGINE FUNCTION ARGS). | 395 Each element in the alist is a three-element list (ENGINE FUNCTION ARGS). |
412 ENGINE is a symbol designating the searching engine. FUNCTION is also | 396 ENGINE is a symbol designating the searching engine. FUNCTION is also |
571 This variable is very similar to `nnir-wais-remove-prefix', except | 555 This variable is very similar to `nnir-wais-remove-prefix', except |
572 that it is for swish-e, not Wais. | 556 that it is for swish-e, not Wais. |
573 | 557 |
574 This could be a server parameter." | 558 This could be a server parameter." |
575 :type '(regexp) | 559 :type '(regexp) |
576 :group 'nnir) | |
577 | |
578 ;; HyREX engine, see <URL:http://ls6-www.cs.uni-dortmund.de/> | |
579 | |
580 (defcustom nnir-hyrex-program "nnir-search" | |
581 "*Name of the nnir-search executable." | |
582 :type '(string) | |
583 :group 'nnir) | |
584 | |
585 (defcustom nnir-hyrex-additional-switches '() | |
586 "*A list of strings, to be given as additional arguments for nnir-search. | |
587 Note that this should be a list. Ie, do NOT use the following: | |
588 (setq nnir-hyrex-additional-switches \"-ddl ddl.xml -c nnir\") ; wrong ! | |
589 Instead, use this: | |
590 (setq nnir-hyrex-additional-switches '(\"-ddl\" \"ddl.xml\" \"-c\" \"nnir\"))" | |
591 :type '(repeat (string)) | |
592 :group 'nnir) | |
593 | |
594 (defcustom nnir-hyrex-index-directory (getenv "HOME") | |
595 "*Index directory for HyREX." | |
596 :type '(directory) | |
597 :group 'nnir) | |
598 | |
599 (defcustom nnir-hyrex-remove-prefix (concat (getenv "HOME") "/Mail/") | |
600 "*The prefix to remove from each file name returned by HyREX | |
601 in order to get a group name (albeit with / instead of .). | |
602 | |
603 For example, suppose that HyREX returns file names such as | |
604 \"/home/john/Mail/mail/misc/42\". For this example, use the following | |
605 setting: (setq nnir-hyrex-remove-prefix \"/home/john/Mail/\") | |
606 Note the trailing slash. Removing this prefix gives \"mail/misc/42\". | |
607 `nnir' knows to remove the \"/42\" and to replace \"/\" with \".\" to | |
608 arrive at the correct group name, \"mail.misc\"." | |
609 :type '(directory) | |
610 :group 'nnir) | 560 :group 'nnir) |
611 | 561 |
612 ;; Namazu engine, see <URL:http://www.namazu.org/> | 562 ;; Namazu engine, see <URL:http://www.namazu.org/> |
613 | 563 |
614 (defcustom nnir-namazu-program "namazu" | 564 (defcustom nnir-namazu-program "namazu" |
1354 (sort artlist | 1304 (sort artlist |
1355 (function (lambda (x y) | 1305 (function (lambda (x y) |
1356 (> (nnir-artitem-rsv x) | 1306 (> (nnir-artitem-rsv x) |
1357 (nnir-artitem-rsv y))))))))) | 1307 (nnir-artitem-rsv y))))))))) |
1358 | 1308 |
1359 ;; HyREX interface | |
1360 (defun nnir-run-hyrex (query server &optional group) | |
1361 (save-excursion | |
1362 (let ((artlist nil) | |
1363 (groupspec (cdr (assq 'group query))) | |
1364 (qstring (cdr (assq 'query query))) | |
1365 (prefix (nnir-read-server-parm 'nnir-hyrex-remove-prefix server)) | |
1366 score artno dirnam) | |
1367 (when (and group groupspec) | |
1368 (error (concat "It does not make sense to use a group spec" | |
1369 " with process-marked groups."))) | |
1370 (when group | |
1371 (setq groupspec (gnus-group-real-name group))) | |
1372 (when (and group (not (equal group (nnir-group-full-name groupspec server)))) | |
1373 (message "%s vs. %s" group (nnir-group-full-name groupspec server)) | |
1374 (error "Server with groupspec doesn't match group !")) | |
1375 (set-buffer (get-buffer-create nnir-tmp-buffer)) | |
1376 (erase-buffer) | |
1377 (if groupspec | |
1378 (message "Doing hyrex-search query %s on %s..." query groupspec) | |
1379 (message "Doing hyrex-search query %s..." query)) | |
1380 (let* ((cp-list | |
1381 `( ,nnir-hyrex-program | |
1382 nil ; input from /dev/null | |
1383 t ; output | |
1384 nil ; don't redisplay | |
1385 "-i",(nnir-read-server-parm 'nnir-hyrex-index-directory server) ; index directory | |
1386 ,@(nnir-read-server-parm 'nnir-hyrex-additional-switches server) | |
1387 ,qstring ; the query, in hyrex-search format | |
1388 )) | |
1389 (exitstatus | |
1390 (progn | |
1391 (message "%s args: %s" nnir-hyrex-program | |
1392 (mapconcat 'identity (cddddr cp-list) " ")) | |
1393 (apply 'call-process cp-list)))) | |
1394 (unless (or (null exitstatus) | |
1395 (zerop exitstatus)) | |
1396 (nnheader-report 'nnir "Couldn't run hyrex-search: %s" exitstatus) | |
1397 ;; nnir-search failure reason is in this buffer, show it if | |
1398 ;; the user wants it. | |
1399 (when (> gnus-verbose 6) | |
1400 (display-buffer nnir-tmp-buffer)))) ;; FIXME: Dont clear buffer ! | |
1401 (if groupspec | |
1402 (message "Doing hyrex-search query \"%s\" on %s...done" qstring groupspec) | |
1403 (message "Doing hyrex-search query \"%s\"...done" qstring)) | |
1404 (sit-for 0) | |
1405 ;; nnir-search returns: | |
1406 ;; for nnml/nnfolder: "filename mailid weigth" | |
1407 ;; for nnimap: "group mailid weigth" | |
1408 (goto-char (point-min)) | |
1409 (delete-non-matching-lines "^\\S + [0-9]+ [0-9]+$") | |
1410 ;; HyREX couldn'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 (nnir-group-full-name | |
1423 (gnus-replace-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)) | |
1433 t | |
1434 (< (nnir-artitem-number x) | |
1435 (nnir-artitem-number y))))))) | |
1436 ))) | |
1437 | |
1438 ;; Namazu interface | 1309 ;; Namazu interface |
1439 (defun nnir-run-namazu (query server &optional group) | 1310 (defun nnir-run-namazu (query server &optional group) |
1440 "Run given query against Namazu. Returns a vector of (group name, file name) | 1311 "Run given query against Namazu. Returns a vector of (group name, file name) |
1441 pairs (also vectors, actually). | 1312 pairs (also vectors, actually). |
1442 | 1313 |