Gnus development mailing list
 help / color / mirror / Atom feed
From: Andrew Cohen <cohen@andy.bu.edu>
To: ding@gnus.org
Subject: Re: Gnus search
Date: Fri, 22 Oct 2010 10:24:15 -0400	[thread overview]
Message-ID: <87ocam2tm8.fsf@andy.bu.edu> (raw)
In-Reply-To: <87ocan9xrm.fsf@andy.bu.edu>

[-- Attachment #1: Type: text/plain, Size: 372 bytes --]

Attached are patches to make nnir work in nnimap groups without user
configuration. I've set things up so defaults for other backends can be
easily included in the future. I've moved the key binding into
gnus-group.el but left the binding ("G G") unchanged. Finally I've fixed
a bug when searching multiple imap groups. 

Please let me know if this works.

Regards,
Andy


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: nnir search changes --]
[-- Type: text/x-diff, Size: 6014 bytes --]

diff --git a/lisp/gnus-group.el b/lisp/gnus-group.el
index 7152c18..e2864b9 100644
--- a/lisp/gnus-group.el
+++ b/lisp/gnus-group.el
@@ -55,6 +55,8 @@
 (autoload 'gnus-agent-total-fetched-for "gnus-agent")
 (autoload 'gnus-cache-total-fetched-for "gnus-cache")
 
+(autoload 'gnus-group-make-nnir-group "nnir")
+
 (defcustom gnus-no-groups-message "No Gnus is good news"
   "*Message displayed by Gnus when no groups are available."
   :group 'gnus-start
@@ -653,6 +655,7 @@ simple manner.")
   "D" gnus-group-enter-directory
   "f" gnus-group-make-doc-group
   "w" gnus-group-make-web-group
+  "G" gnus-group-make-nnir-group
   "M" gnus-group-read-ephemeral-group
   "r" gnus-group-rename-group
   "R" gnus-group-make-rss-group
@@ -904,6 +907,7 @@ simple manner.")
 	["Add the help group" gnus-group-make-help-group t]
 	["Make a doc group..." gnus-group-make-doc-group t]
 	["Make a web group..." gnus-group-make-web-group t]
+	["Make a search group..." gnus-group-make-nnir-group t]
 	["Make a virtual group..." gnus-group-make-empty-virtual t]
 	["Add a group to a virtual..." gnus-group-add-to-virtual t]
 	["Make an ephemeral group..." gnus-group-read-ephemeral-group t]


diff --git a/lisp/nnir.el b/lisp/nnir.el
index 2a264d1..a32d748 100644
--- a/lisp/nnir.el
+++ b/lisp/nnir.el
@@ -378,6 +378,10 @@ should return a message's headers in NOV format.
 If this variable is nil, or if the provided function returns nil for a search
 result, `gnus-retrieve-headers' will be called instead.")
 
+(defvar nnir-method-default-engines
+  '((nnimap . imap)
+    (nntp . nil))
+  "Alist of default search engines by server method")
 
 ;;; Developer Extension Variable:
 
@@ -401,8 +405,8 @@ result, `gnus-retrieve-headers' will be called instead.")
              ())
     (hyrex   nnir-run-hyrex
 	     ((group . "Group spec: ")))
-  (find-grep nnir-run-find-grep
-	     ((grep-options . "Grep options: "))))
+    (find-grep nnir-run-find-grep
+	       ((grep-options . "Grep options: "))))
   "Alist of supported search engines.
 Each element in the alist is a three-element list (ENGINE FUNCTION ARGS).
 ENGINE is a symbol designating the searching engine.  FUNCTION is also
@@ -677,16 +681,6 @@ that it is for Namazu, not Wais."
            gnus-current-window-configuration)
      nil)))
 
-(eval-when-compile
-  (when (featurep 'xemacs)
-    ;; The `kbd' macro requires that the `read-kbd-macro' macro is available.
-    (require 'edmacro)))
-
-(defun nnir-group-mode-hook ()
-  (define-key gnus-group-mode-map (kbd "G G")
-    'gnus-group-make-nnir-group))
-(add-hook 'gnus-group-mode-hook 'nnir-group-mode-hook)
-
 ;; Why is this needed? Is this for compatibility with old/new gnusae? Using
 ;; gnus-group-server instead works for me.  -- Justus Piater
 (defmacro nnir-group-server (group)
@@ -716,22 +710,22 @@ and show thread that contains this article."
 	 (id (mail-header-id (gnus-summary-article-header)))
 	 (refs (split-string
 		(mail-header-references (gnus-summary-article-header)))))
-    (if (string= (car (gnus-group-method group)) "nnimap")
-	(with-current-buffer (nnimap-buffer)
-	  (let* ((cmd (let ((value
-			     (format
-			      "(OR HEADER REFERENCES %s HEADER Message-Id %s)"
-			      id id)))
-			(dolist (refid refs value)
-			  (setq value (format
-				       "(OR (OR HEADER Message-Id %s HEADER REFERENCES %s) %s)"
-				       refid refid value)))))
-		 (result (nnimap-command
-			  "UID SEARCH %s" cmd)))
-	    (gnus-summary-read-group-1 group t t gnus-summary-buffer nil
-				       (and (car result)
-					    (delete 0 (mapcar #'string-to-number
-							      (cdr (assoc "SEARCH" (cdr result)))))))))
+    (if (eq (car (gnus-group-method group)) 'nnimap)
+	(progn (nnimap-possibly-change-group (gnus-group-short-name group) nil)
+	       (with-current-buffer (nnimap-buffer)
+		 (let* ((cmd (let ((value (format
+					   "(OR HEADER REFERENCES %s HEADER Message-Id %s)"
+					   id id)))
+			       (dolist (refid refs value)
+				 (setq value (format
+					      "(OR (OR HEADER Message-Id %s HEADER REFERENCES %s) %s)"
+					      refid refid value)))))
+			(result (nnimap-command
+				 "UID SEARCH %s" cmd)))
+		   (gnus-summary-read-group-1 group t t gnus-summary-buffer nil
+					      (and (car result)
+						   (delete 0 (mapcar #'string-to-number
+								     (cdr (assoc "SEARCH" (cdr result))))))))))
       (gnus-summary-read-group-1 group t t gnus-summary-buffer
 				 nil (list backend-number))
       (gnus-summary-limit (list backend-number))
@@ -1602,24 +1596,37 @@ and concat the results."
     (if gnus-group-marked
 	(apply 'vconcat
 	       (mapcar (lambda (x)
-			 (let ((server (nnir-group-server x))
-			       search-func)
+			 (let* ((server (nnir-group-server x))
+				(engine
+				 (or (nnir-read-server-parm 'nnir-search-engine
+							    server)
+				     (cdr
+				      (assoc (car (gnus-server-to-method server))
+					     nnir-method-default-engines))))
+				search-func)
 			   (setq search-func (cadr
 					      (assoc
-					       (nnir-read-server-parm 'nnir-search-engine server) nnir-engines)))
+					       engine
+					       nnir-engines)))
 			   (if search-func
 			       (funcall search-func q server x)
 			     nil)))
-		       gnus-group-marked)
-	       )
+		       gnus-group-marked))
       (apply 'vconcat
 	     (mapcar (lambda (x)
 		       (if (and (equal (cadr x) 'ok) (not (equal (cadar x) "-ephemeral")))
-			   (let ((server (format "%s:%s" (caar x) (cadar x)))
-				 search-func)
+			   (let* ((server (format "%s:%s" (caar x) (cadar x)))
+				  (engine
+				   (or (nnir-read-server-parm 'nnir-search-engine
+							      server)
+				       (cdr
+					(assoc (car (gnus-server-to-method server))
+					       nnir-method-default-engines))))
+				  search-func)
 			     (setq search-func (cadr
 						(assoc
-						 (nnir-read-server-parm 'nnir-search-engine server) nnir-engines)))
+						 engine
+						 nnir-engines)))
 			     (if search-func
 				 (funcall search-func q server nil)
 			       nil))

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: changelog --]
[-- Type: text/x-diff, Size: 609 bytes --]

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 9160666..0e18635 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,14 @@
+2010-10-22  Andrew Cohen  <cohen@andy.bu.edu>
+
+	* nnir.el (nnir-method-default-engines): new variable.
+	(nnir-run-query): use it.
+	(nnir-group-mode-hook): remove key binding and move to gnus-group.el.
+	(gnus-summary-nnir-goto-thread): change group if needed.
+
+	* gnus-group.el (gnus-group-group-map): add key binding for
+	gnus-group-make-nnir-group.
+
+
 2010-10-22  Katsumi Yamaoka  <yamaoka@jpl.org>
 
 	* mml.el (mml-preview): Work properly when editing article.

  reply	other threads:[~2010-10-22 14:24 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-21 15:49 Lars Magne Ingebrigtsen
2010-10-21 16:04 ` Julien Danjou
2010-10-21 16:07   ` Lars Magne Ingebrigtsen
2010-10-21 16:24     ` Julien Danjou
2010-10-21 17:09       ` Andrew Cohen
2010-10-21 17:10       ` Tibor Simko
2010-10-21 17:12         ` Lars Magne Ingebrigtsen
2010-10-21 17:56           ` Andrew Cohen
2010-10-21 18:25             ` Andrew Cohen
2010-10-21 18:45               ` Ted Zlatanov
2010-10-21 19:00                 ` Andrew Cohen
2010-10-22 14:24                   ` Andrew Cohen [this message]
2010-10-23  7:01                     ` Steinar Bang
2010-10-23 12:14                       ` Andrew Cohen
2010-10-24  9:15                         ` Steinar Bang
2010-10-25 18:34                         ` Ted Zlatanov
2010-10-24  4:18                     ` Lars Magne Ingebrigtsen
2010-10-21 18:00           ` Ted Zlatanov
2010-10-21 18:35             ` Andreas Seltenreich
2010-10-21 21:27     ` Steinar Bang
2010-10-27 11:36 ` Andrew Cohen
2010-10-27 12:32   ` Steinar Bang
2010-10-27 13:23   ` Dan Christensen
2010-10-27 13:25     ` Andrew Cohen
2010-10-27 17:41   ` Ted Zlatanov
2010-10-27 18:08     ` Andrew Cohen
2010-10-27 18:39       ` Ted Zlatanov
2010-10-28 10:27         ` Julien Danjou
2010-10-28 10:49           ` Andrew Cohen
2010-10-28 10:51             ` Julien Danjou
2010-10-29  6:34       ` nnir: Removing some search engines (was: Gnus search) Reiner Steib
2010-10-29 11:16         ` nnir: Removing some search engines Andrew Cohen
2010-10-29 12:57         ` Jose A. Ortega Ruiz
2010-10-27 20:15   ` Gnus search Jose A. Ortega Ruiz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ocam2tm8.fsf@andy.bu.edu \
    --to=cohen@andy.bu.edu \
    --cc=ding@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).