From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/73468 Path: news.gmane.org!not-for-mail From: Andrew Cohen Newsgroups: gmane.emacs.gnus.general Subject: Re: Gnus search Date: Fri, 22 Oct 2010 10:24:15 -0400 Message-ID: <87ocam2tm8.fsf@andy.bu.edu> References: <87eibjzd2q.fsf@pcuds33.cern.ch> <87eibjbfb8.fsf@andy.bu.edu> <87sjzz9zdo.fsf@andy.bu.edu> <87aam7qtaj.fsf@lifelogs.com> <87ocan9xrm.fsf@andy.bu.edu> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1287757549 25070 80.91.229.12 (22 Oct 2010 14:25:49 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 22 Oct 2010 14:25:49 +0000 (UTC) To: ding@gnus.org Original-X-From: ding-owner+M21837@lists.math.uh.edu Fri Oct 22 16:25:47 2010 Return-path: Envelope-to: ding-account@gmane.org Original-Received: from util0.math.uh.edu ([129.7.128.18]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1P9IZ0-0006Va-Mv for ding-account@gmane.org; Fri, 22 Oct 2010 16:25:47 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by util0.math.uh.edu with smtp (Exim 4.63) (envelope-from ) id 1P9IXm-0003nI-Qo; Fri, 22 Oct 2010 09:24:30 -0500 Original-Received: from mx1.math.uh.edu ([129.7.128.32]) by util0.math.uh.edu with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1P9IXk-0003n3-Rb for ding@lists.math.uh.edu; Fri, 22 Oct 2010 09:24:28 -0500 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx1.math.uh.edu with esmtp (Exim 4.72) (envelope-from ) id 1P9IXi-0003zG-Gr for ding@lists.math.uh.edu; Fri, 22 Oct 2010 09:24:28 -0500 Original-Received: from lo.gmane.org ([80.91.229.12]) by quimby.gnus.org with esmtp (Exim 3.36 #1 (Debian)) id 1P9IXh-00023G-00 for ; Fri, 22 Oct 2010 16:24:25 +0200 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1P9IXg-0006Bv-6s for ding@gnus.org; Fri, 22 Oct 2010 16:24:24 +0200 Original-Received: from andy.bu.edu ([128.197.41.152]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 22 Oct 2010 16:24:24 +0200 Original-Received: from cohen by andy.bu.edu with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 22 Oct 2010 16:24:24 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 206 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: andy.bu.edu User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/24.0.50 (gnu/linux) Cancel-Lock: sha1:QLUe1TbyVePUGh2mAc3SUjw6pOE= X-Spam-Score: -1.9 (-) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:73468 Archived-At: --=-=-= Content-Type: text/plain 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 --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=gnus.diff Content-Description: nnir search changes 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)) --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=changelog.diff Content-Description: changelog 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 + + * 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 * mml.el (mml-preview): Work properly when editing article. --=-=-=--