X-Git-Url: https://cgit.sxemacs.org/?a=blobdiff_plain;f=contrib%2Fnnir.el;h=f282c425822933540286ced79ddd3d1d609eab0b;hb=19f6acebe88b61059a088ee5239ce78bfc160575;hp=9f6d2948dd048efee1cf4a3022645e3a40449838;hpb=cfa12c8a93d4beb94c50e9ba03a2304216f4ce56;p=gnus diff --git a/contrib/nnir.el b/contrib/nnir.el index 9f6d2948d..f282c4258 100644 --- a/contrib/nnir.el +++ b/contrib/nnir.el @@ -298,7 +298,7 @@ ;;; Setup Code: -(defconst nnir-version "$Id: nnir.el,v 1.80 2002/12/22 17:38:15 grossjoh Exp $" +(defconst nnir-version "$Id: nnir.el,v 7.3 2004/03/15 09:43:20 rsteib Exp $" "Version of NNIR.") (require 'cl) @@ -308,24 +308,47 @@ (eval-and-compile (require 'gnus-util)) (eval-when-compile - (require 'nnimap)) + (require 'nnimap) + (autoload 'read-kbd-macro "edmacro" nil t)) (nnoo-declare nnir) (nnoo-define-basics nnir) (gnus-declare-backend "nnir" 'mail) +(defvar nnir-imap-search-field "TEXT" + "The IMAP search item when doing an nnir search") + +(defvar nnir-imap-search-arguments + '(("Whole message" . "TEXT") + ("Subject" . "SUBJECT") + ("To" . "TO") + ("From" . "FROM") + (nil . "HEADER \"%s\"")) + "Mapping from user readable strings to IMAP search items for use in nnir") + +(defvar nnir-imap-search-argument-history () + "The history for querying search options in nnir") + ;;; Developer Extension Variable: (defvar nnir-engines - '((glimpse nnir-run-glimpse + `((glimpse nnir-run-glimpse ((group . "Group spec: "))) (wais nnir-run-waissearch ()) (excite nnir-run-excite-search ()) (imap nnir-run-imap - ()) + ((criteria + "Search in: " ; Prompt + ,nnir-imap-search-arguments ; alist for completing + nil ; no filtering + nil ; allow any user input + nil ; initial value + nnir-imap-search-argument-history ; the history to use + ,nnir-imap-search-field ; default + ))) (swish++ nnir-run-swish++ ((group . "Group spec: "))) (swish-e nnir-run-swish-e @@ -669,7 +692,17 @@ that it is for Namazu, not Glimpse." 'gnus-group-make-nnir-group)) (add-hook 'gnus-group-mode-hook 'nnir-group-mode-hook) - +(defmacro nnir-group-server (group) + "Return the server for a foreign newsgroup GROUP. +The returned format is as `gnus-server-to-method' needs it. See +`gnus-group-real-prefix' and `gnus-group-real-name'." + `(let ((gname ,group)) + (if (string-match "^\\([^:]+\\):" gname) + (setq gname (match-string 1 gname)) + nil) + (if (string-match "^\\([^+]+\\)\\+\\(.+\\)$" gname) + (format "%s:%s" (match-string 1 gname) (match-string 2 gname)) + (concat gname ":")))) ;; Summary mode commands. @@ -842,7 +875,7 @@ pairs (also vectors, actually)." (let ((artlist nil) (groupspec (cdr (assq 'group query))) (qstring (cdr (assq 'query query))) - (prefix (nnir-read-server-parm 'nnir-glimps-remove-prefix server)) + (prefix (nnir-read-server-parm 'nnir-glimpse-remove-prefix server)) artno dirnam) (when (and group groupspec) (error (concat "It does not make sense to use a group spec" @@ -1001,15 +1034,16 @@ pairs (also vectors, actually)." ;; send queries as literals ;; handle errors -(defun nnir-run-imap (query srv &optional group) +(defun nnir-run-imap (query srv &optional group-option) (require 'imap) (require 'nnimap) - (unless group - (error "Must process-mark groups for IMAP searching.")) (save-excursion (let ((qstring (cdr (assq 'query query))) (server (cadr (gnus-server-to-method srv))) + (group (or group-option (gnus-group-group-name))) (defs (caddr (gnus-server-to-method srv))) + (criteria (or (cdr (assq 'criteria query)) + nnir-imap-search-field)) artlist buf) (message "Opening server %s" server) (condition-case () @@ -1023,7 +1057,7 @@ pairs (also vectors, actually)." (lambda (artnum) (push (vector group artnum 1) artlist) (setq arts (1+ arts))) - (imap-search (concat "TEXT \"" qstring "\"") buf)) + (imap-search (concat criteria " \"" qstring "\"") buf)) (message "Searching %s... %d matches" mbx arts))) (message "Searching %s...done" group)) (quit nil)) @@ -1170,7 +1204,7 @@ Tested with swish-e-2.0.1 on Windows NT 4.0." (error "Missing parameter `nnir-swish-e-index-file'"))) (additional-switches (nnir-read-server-parm - 'nnir-swish++-additional-switches server)) + 'nnir-swish-e-additional-switches server)) (cp-list `(,nnir-swish-e-program nil ; input from /dev/null t ; output @@ -1402,7 +1436,12 @@ Tested with Namazu 2.0.6 on a GNU/Linux system." `parmspec' is a cons cell, the car is a symbol, the cdr is a prompt." (let ((sym (car parmspec)) (prompt (cdr parmspec))) - (cons sym (read-string prompt)))) + (if (listp prompt) + (let* ((result (apply 'completing-read prompt)) + (mapping (or (assoc result nnir-imap-search-arguments) + (assoc nil nnir-imap-search-arguments)))) + (cons sym (format (cdr mapping) result))) + (cons sym (read-string prompt))))) (defun nnir-run-query (query) "Invoke appropriate search engine function (see `nnir-engines'). @@ -1457,17 +1496,6 @@ form 'backend:name'." ;; (symbol-value key)) ;; )) -(defmacro nnir-group-server (group) - "Returns the server for a foreign newsgroup in the format as gnus-server-to-method needs it. Compare to gnus-group-real-prefix and gnus-group-real-name." - `(let ((gname ,group)) - (if (string-match "^\\([^:]+\\):" gname) - (setq gname (match-string 1 gname)) - nil) - (if (string-match "^\\([^+]+\\)\\+\\(.+\\)$" gname) - (format "%s:%s" (match-string 1 gname) (match-string 2 gname)) - (concat gname ":")) - )) - (defun nnir-group-full-name (shortname server) "For the given group name, return a full Gnus group name. The Gnus backend/server information is added."