gnus-registry-enabled fixes to give default value.
[gnus] / lisp / nnir.el
index 5f0a2c6..13ad497 100644 (file)
@@ -290,9 +290,7 @@ is `(valuefunc member)'."
   (autoload 'nnimap-command "nnimap")
   (autoload 'nnimap-possibly-change-group "nnimap")
   (autoload 'nnimap-make-thread-query "nnimap")
-  (autoload 'gnus-registry-action "gnus-registry")
-  (defvar gnus-registry-install))
-
+  (autoload 'gnus-registry-action "gnus-registry"))
 
 (nnoo-declare nnir)
 (nnoo-define-basics nnir)
@@ -767,11 +765,18 @@ Add an entry here when adding a new search engine.")
 (deffoo nnir-warp-to-article ()
   (let* ((cur (if (> (gnus-summary-article-number) 0)
                  (gnus-summary-article-number)
-               (error "This is not a real article.")))
-        (gnus-newsgroup-name (nnir-article-group cur))
-         (backend-number (nnir-article-number cur)))
-    (gnus-summary-read-group-1 gnus-newsgroup-name t t gnus-summary-buffer
-                              nil (list backend-number))))
+               (error "This is not a real article")))
+        (backend-article-group (nnir-article-group cur))
+         (backend-article-number (nnir-article-number cur))
+        (quit-config (gnus-ephemeral-group-p gnus-newsgroup-name)))
+    ;; first exit from the nnir summary buffer.
+    (gnus-summary-exit)
+    ;; and if the nnir summary buffer in turn came from another
+    ;; summary buffer we have to clean that summary up too.
+    (when (eq (cdr quit-config) 'summary)
+      (gnus-summary-exit))
+    (gnus-summary-read-group-1 backend-article-group t t  nil
+                              nil (list backend-article-number))))
 
 (nnoo-define-skeleton nnir)
 
@@ -799,7 +804,7 @@ ready to be added to the list of search results."
     ;; remove trailing slash and, for nnmaildir, cur/new/tmp
     (setq dirnam
          (substring dirnam 0
-                    (if (string= (gnus-group-server server) "nnmaildir")
+                    (if (string-match "^nnmaildir:" (gnus-group-server server))
                         -5 -1)))
 
     ;; Set group to dirnam without any leading dots or slashes,
@@ -809,7 +814,7 @@ ready to be added to the list of search results."
                  "[/\\]" "." t)))
 
     (vector (gnus-group-full-name group server)
-           (if (string= (gnus-group-server server) "nnmaildir")
+           (if (string-match "^nnmaildir:" (gnus-group-server server))
                (nnmaildir-base-name-to-article-number
                 (substring article 0 (string-match ":" article))
                 group nil)
@@ -1066,7 +1071,8 @@ Windows NT 4.0."
           ;; is sufficient.  Note that we can't only use the value of
           ;; nnml-use-compressed-files because old articles might have been
           ;; saved with a different value.
-          (article-pattern (if (string= (gnus-group-server server) "nnmaildir")
+          (article-pattern (if (string-match "^nnmaildir:"
+                                             (gnus-group-server server))
                                ":[0-9]+"
                              "^[0-9]+\\(\\.[a-z0-9]+\\)?$"))
            score artno dirnam filenam)
@@ -1308,7 +1314,8 @@ Tested with Namazu 2.0.6 on a GNU/Linux system."
   ;; (when group
   ;;   (error "The Namazu backend cannot search specific groups"))
   (save-excursion
-    (let ((article-pattern (if (string= (gnus-group-server server) "nnmaildir")
+    (let ((article-pattern (if (string-match "^nnmaildir:"
+                                            (gnus-group-server server))
                               ":[0-9]+"
                             "^[0-9]+$"))
           artlist
@@ -1381,7 +1388,8 @@ actually)."
           (groupspec (cdr (assq 'group query)))
           (prefix (nnir-read-server-parm 'nnir-notmuch-remove-prefix server))
            artlist
-           (article-pattern (if (string= (gnus-group-server server) "nnmaildir")
+          (article-pattern (if (string-match "^nnmaildir:"
+                                             (gnus-group-server server))
                               ":[0-9]+"
                             "^[0-9]+$"))
            artno dirnam filenam)
@@ -1617,7 +1625,7 @@ actually)."
              (let* ((server (car x))
                     (nnir-search-engine
                      (or (nnir-read-server-parm 'nnir-search-engine
-                                                server)
+                                                server t)
                          (cdr (assoc (car
                                       (gnus-server-to-method server))
                                      nnir-method-default-engines))))
@@ -1636,14 +1644,16 @@ actually)."
                  nil)))
            groups))))
 
-(defun nnir-read-server-parm (key server)
-  "Returns the parameter value of key for the given server, where
-server is of form 'backend:name'."
+(defun nnir-read-server-parm (key server &optional not-global)
+  "Returns the parameter value corresponding to `key' for
+`server'. If no server-specific value is found consult the global
+environment unless `not-global' is non-nil."
   (let ((method (gnus-server-to-method server)))
     (cond ((and method (assq key (cddr method)))
-          (nth 1 (assq key (cddr method))))
-         ((boundp key) (symbol-value key))
-         (t nil))))
+           (nth 1 (assq key (cddr method))))
+          ((and (not not-global) (boundp key)) (symbol-value key))
+          (t nil))))
+
 
 (defun nnir-possibly-change-server (server)
   (unless (and server (nnir-server-opened server))
@@ -1729,8 +1739,7 @@ server is of form 'backend:name'."
   (when (eq (car (gnus-find-method-for-group gnus-newsgroup-name)) 'nnir)
     (setq gnus-summary-line-format
          (or nnir-summary-line-format gnus-summary-line-format))
-    (when (and (boundp 'gnus-registry-install)
-                      (eq gnus-registry-install t))
+    (when (gnus-bound-and-true-p gnus-registry-enabled)
       (remove-hook 'gnus-summary-article-delete-hook 'gnus-registry-action t)
       (remove-hook 'gnus-summary-article-move-hook 'gnus-registry-action t)
       (remove-hook 'gnus-summary-article-expire-hook 'gnus-registry-action t)