;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
;;; Commentary:
;;; Setup Code:
-(defconst nnir-version "$Id: nnir.el,v 1.80 2002/12/22 17:38:15 grossjoh Exp $"
- "Version of NNIR.")
-
(require 'cl)
(require 'nnoo)
(require 'gnus-group)
(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
;;; User Customizable Variables:
(defgroup nnir nil
- "Search nnmh and nnml groups in Gnus with Glimpse, freeWAIS-sf, or EWS.")
+ "Search nnmh and nnml groups in Gnus with Glimpse, freeWAIS-sf, or EWS."
+ :group 'gnus)
;; Mail backend.
:type '(regexp)
:group 'nnir)
-;; Swish-E. Next three variables Copyright (C) 2000 Christoph Conrad
-;; <christoph.conrad@gmx.de>.
+;; Swish-E.
;; URL: http://sunsite.berkeley.edu/SWISH-E/
;; New version: http://www.boe.es/swish-e
+;; Variables `nnir-swish-e-index-file', `nnir-swish-e-program' and
+;; `nnir-swish-e-additional-switches'
+;; Copyright (C) 2000 Christoph Conrad <christoph.conrad@gmx.de>.
+(make-obsolete-variable 'nnir-swish-e-index-file
+ 'nnir-swish-e-index-files)
(defcustom nnir-swish-e-index-file
(expand-file-name "~/Mail/index.swish-e")
"*Index file for swish-e.
-This could be a server parameter."
+This could be a server parameter.
+It is never consulted once `nnir-swish-e-index-files', which should be
+used instead, has been customized."
:type '(file)
:group 'nnir)
+(defcustom nnir-swish-e-index-files
+ (list nnir-swish-e-index-file)
+ "*List of index files for swish-e.
+This could be a server parameter."
+ :type '(repeat (file))
+ :group 'nnir)
+
(defcustom nnir-swish-e-program "swish-e"
"*Name of swish-e search executable.
This cannot be a server parameter."
'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.
(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"
;; 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 ()
(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))
dirnam (file-name-directory (match-string 2)))
;; don't match directories
- (when (string-match "^[0-9]+$" artno)
+ (when (string-match "^[0-9]+\\(\\.gz\\)?$" artno)
(when (not (null dirnam))
;; maybe limit results to matching groups.
(erase-buffer)
(message "Doing swish-e query %s..." query)
- (let* ((index-file
+ (let* ((index-files
(or (nnir-read-server-parm
- 'nnir-swish-e-index-file server)
- (error "Missing parameter `nnir-swish-e-index-file'")))
+ 'nnir-swish-e-index-files server)
+ (error "Missing parameter `nnir-swish-e-index-files'")))
(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
nil ; don't redisplay
- "-f" ,index-file
+ "-f" ,@index-files
,@additional-switches
"-w"
,qstring ; the query, in swish-e format
`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').
(cond ((and method (assq key (cddr method)))
(nth 1 (assq key (cddr method))))
((and nnir-mail-backend
- (gnus-method-equal method nnir-mail-backend))
+ (gnus-server-equal method nnir-mail-backend))
(symbol-value key))
((null nnir-mail-backend)
(symbol-value key))
;; (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."
;; The end.
(provide 'nnir)
+
+;;; arch-tag: 9b3fecf8-4397-4bbb-bf3c-6ac3cbbc6664