* gnus-clfns.el (coerce, copy-list, merge, string, subseq): Comment out those
[elisp/gnus.git-] / lisp / nnir.el
index acbf13b..846db89 100644 (file)
@@ -1,8 +1,6 @@
 ;;; nnir.el --- search mail with various search engines
 ;; Copyright (C) 1998 Kai Großjohann
 
-;; $Id: nnir.el,v 1.72 2001/08/17 11:15:13 grossjoh Exp $
-
 ;; Author: Kai Großjohann <grossjohann@ls6.cs.uni-dortmund.de>
 ;; Keywords: news, mail, searching, ir, glimpse, wais
 
 
 ;;; Setup Code:
 
-(defconst nnir-version "$Id: nnir.el,v 1.72 2001/08/17 11:15:13 grossjoh Exp $"
+(defconst nnir-version "1.72"
   "Version of NNIR.")
 
 (require 'cl)
@@ -461,6 +459,11 @@ that it is for EWS, not Glimpse."
   :type '(regexp)
   :group 'nnir)
 
+(defcustom nnir-imap-default-charset nil
+  "*Name of the charset of the strings that appear in the search criteria."
+  :type '(choice (const nil) symbol)
+  :group 'nnir)
+
 ;; Swish++.  Next three variables Copyright (C) 2000, 2001 Christoph
 ;; Conrad <christoph.conrad@gmx.de>.
 ;; Swish++ home page: http://homepage.mac.com/pauljlucas/software/swish/
@@ -608,7 +611,10 @@ that it is for Namazu, not Glimpse."
         (kbd "G G")
       "GG")                             ; XEmacs 19 compat
     'gnus-group-make-nnir-group))
-(add-hook 'gnus-group-mode-hook 'nnir-group-mode-hook)
+(add-hook 'gnus-group-mode-hook
+         (lambda ()
+           (unless (string-match "T-gnus" gnus-version)
+             (nnir-group-mode-hook))))
 
 
 
@@ -959,9 +965,13 @@ pairs (also vectors, actually)."
 ;; send queries as literals
 ;; handle errors
 
+(eval-when-compile
+  (defvar nnimap-server-buffer))
+
 (defun nnir-run-imap (query &optional group)
   (require 'imap)
   (require 'nnimap)
+  (require 'mm-util)
   (unless group
     (error "Must specify groups for IMAP searching."))
   (save-excursion
@@ -975,13 +985,30 @@ pairs (also vectors, actually)."
            (setq buf nnimap-server-buffer) ;; xxx
            (message "Searching %s..." group)
             (let ((arts 0)
-                  (mbx (gnus-group-real-name group)))
+                  (mbx (gnus-group-real-name group))
+                 (multibyte-p (mm-multibyte-p))
+                 charset coding-system)
               (when (imap-mailbox-select mbx nil buf)
+               (with-temp-buffer
+                 (if multibyte-p
+                     (mm-enable-multibyte))
+                 (insert qstring)
+                 (setq charset (car (mm-find-mime-charset-region
+                                     (point-min)(point-max)))))
+               (unless charset
+                 (setq charset nnir-imap-default-charset))
                 (mapcar
                  (lambda (artnum)
                    (push (vector mbx artnum 1) artlist)
                    (setq arts (1+ arts)))
-                 (imap-search (concat "TEXT \"" qstring "\"") buf))
+                (if (and (not (eq charset 'us-ascii))
+                         (setq coding-system (mm-charset-to-coding-system
+                                              charset)))
+                    (imap-search
+                     (concat "CHARSET " (symbol-name charset) " TEXT \""
+                             (mm-encode-coding-string qstring coding-system)
+                             "\"") buf)
+                  (imap-search (concat "TEXT \"" qstring "\"") buf)))
                 (message "Searching %s... %d matches" mbx arts)))
             (message "Searching %s...done" group))
         (quit nil))
@@ -1211,11 +1238,13 @@ Tested with Namazu 2.0.6 on a GNU/Linux system."
                  ,nnir-namazu-index-directory ; index directory
                  ))
              (exitstatus
-              (progn
+             (let ((process-environment (copy-sequence process-environment)))
+               ;; Disable locale.
+               (setenv "LC_ALL" "C")
                 (message "%s args: %s" nnir-namazu-program
                          (mapconcat 'identity (cddddr cp-list) " "))
-                (apply 'call-process cp-list))))
-        (unless (or (null exitstatus)
+               (apply 'call-process cp-list))))
+       (unless (or (null exitstatus)
                     (zerop exitstatus))
           (nnheader-report 'nnir "Couldn't run namazu: %s" exitstatus)
           ;; Namazu failure reason is in this buffer, show it if