From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/73755 Path: news.gmane.org!not-for-mail From: Andrew Cohen Newsgroups: gmane.emacs.gnus.general Subject: Re: large nnir changes Date: Sun, 31 Oct 2010 17:52:33 -0400 Message-ID: <87bp6avxlq.fsf@andy.bu.edu> References: <87hbg3srl8.fsf@andy.bu.edu> <87mxpvo9r6.fsf@andy.bu.edu> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1288561981 16789 80.91.229.12 (31 Oct 2010 21:53:01 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 31 Oct 2010 21:53:01 +0000 (UTC) To: ding@gnus.org Original-X-From: ding-owner+M22124@lists.math.uh.edu Sun Oct 31 22:52:57 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 1PCfpg-0007HX-Ju for ding-account@gmane.org; Sun, 31 Oct 2010 22:52:57 +0100 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 1PCfpe-0004BM-87; Sun, 31 Oct 2010 16:52:54 -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 1PCfpa-00049U-BZ for ding@lists.math.uh.edu; Sun, 31 Oct 2010 16:52:50 -0500 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx1.math.uh.edu with esmtp (Exim 4.72) (envelope-from ) id 1PCfpW-0001kH-62 for ding@lists.math.uh.edu; Sun, 31 Oct 2010 16:52:49 -0500 Original-Received: from lo.gmane.org ([80.91.229.12]) by quimby.gnus.org with esmtp (Exim 3.36 #1 (Debian)) id 1PCfpV-00081p-00 for ; Sun, 31 Oct 2010 22:52:45 +0100 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1PCfpV-0007Eh-9l for ding@gnus.org; Sun, 31 Oct 2010 22:52:45 +0100 Original-Received: from rain.gmane.org ([80.91.229.7]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 31 Oct 2010 22:52:45 +0100 Original-Received: from cohen by rain.gmane.org with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 31 Oct 2010 22:52:45 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 195 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: rain.gmane.org User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/24.0.50 (gnu/linux) Cancel-Lock: sha1:5XA/F2+0TxaAfaQiwsSY/Nfsu2g= X-Spam-Score: -1.9 (-) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:73755 Archived-At: --=-=-= Content-Type: text/plain I've now added searching entire servers. This works for imap and gmane, and there is some insignificant chance it works for other search engines (I'll take a look at the supported ones soon). To search an entire server go to the server buffer and place the cursor on the line with the server you want. I've added an entirely random key binding of "G" (anyone with a preference feel free to change it). Prefix arg does the same thing it does for searching from the group buffer. And I just noticed that searching on gmane returns an article score, so I threw that in too. Regards, Andy --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=changes.diff Content-Description: nnir changes diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 5f45093..80dde8f 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,15 @@ +2010-10-31 Andrew Cohen + + * nnir.el (gnus-group-make-nnir-group,nnir-run-query): Allow searching + an entire server. + (nnir-get-active): New function. + (nnir-run-imap): Use it. + (nnir-run-gmane): Who knew, gmane search returns an article score! + + * gnus-srvr.el (gnus-server-mode-map): add binding "G" to search the + server on the current line with nnir. + + 2010-10-31 Lars Magne Ingebrigtsen * gnus-sum.el (gnus-summary-show-article): Add `C-u C-u g' for showing diff --git a/lisp/gnus-srvr.el b/lisp/gnus-srvr.el index b532b74..ae77365 100644 --- a/lisp/gnus-srvr.el +++ b/lisp/gnus-srvr.el @@ -34,6 +34,8 @@ (require 'gnus-int) (require 'gnus-range) +(autoload 'gnus-group-make-nnir-group "nnir") + (defcustom gnus-server-mode-hook nil "Hook run in `gnus-server-mode' buffers." :group 'gnus-server @@ -165,6 +167,8 @@ If nil, a faster, but more primitive, buffer is used instead." "g" gnus-server-regenerate-server + "G" gnus-group-make-nnir-group + "z" gnus-server-compact-server "\C-c\C-i" gnus-info-find-node diff --git a/lisp/nnir.el b/lisp/nnir.el index 9e3dd9c..3e00158 100644 --- a/lisp/nnir.el +++ b/lisp/nnir.el @@ -491,10 +491,12 @@ result, `gnus-retrieve-headers' will be called instead.") nnir-current-group-marked nil nnir-artlist nil) (let* ((query (read-string "Query: " nil 'nnir-search-history)) - (parms (list (cons 'query query)))) + (parms (list (cons 'query query))) + (srv (if (gnus-server-server-name) + "all" ""))) (add-to-list 'parms (cons 'unique-id (message-unique-id)) t) (gnus-group-read-ephemeral-group - (concat "nnir:" (prin1-to-string parms)) '(nnir "") t + (concat "nnir:" (prin1-to-string parms)) (list 'nnir srv) t (cons (current-buffer) gnus-current-window-configuration) nil))) @@ -566,7 +568,7 @@ and show thread that contains this article." (equal server nnir-current-server))) nnir-artlist ;; Cache miss. - (setq nnir-artlist (nnir-run-query group))) + (setq nnir-artlist (nnir-run-query group server))) (with-current-buffer nntp-server-buffer (setq nnir-current-query group) (when server (setq nnir-current-server server)) @@ -765,6 +767,7 @@ details on the language and supported extensions" (cdr (assoc nnir-imap-default-search-key nnir-imap-search-arguments)))) (gnus-inhibit-demon t) + (groups (or groups (nnir-get-active srv))) artlist) (message "Opening server %s" server) (apply @@ -1414,15 +1417,22 @@ Tested with Namazu 2.0.6 on a GNU/Linux system." (while (not (eobp)) (unless (or (eolp) (looking-at "\x0d")) (let ((header (nnheader-parse-nov))) - (let ((xref (mail-header-xref header))) + (let ((xref (mail-header-xref header)) + (xscore (string-to-number (cdr (assoc 'X-Score + (mail-header-extra header)))))) (when (string-match " \\([^:]+\\)[:/]\\([0-9]+\\)" xref) (push (vector (gnus-group-prefixed-name (match-string 1 xref) srv) - (string-to-number (match-string 2 xref)) 1) + (string-to-number (match-string 2 xref)) xscore) artlist))))) (forward-line 1))) - (reverse artlist)) + ;; Sort by score + (apply 'vector + (sort artlist + (function (lambda (x y) + (> (nnir-artitem-rsv x) + (nnir-artitem-rsv y))))))) (message "Can't search non-gmane nntp groups"))) ;;; Util Code: @@ -1445,13 +1455,16 @@ Tested with Namazu 2.0.6 on a GNU/Linux system." (cons sym (format (cdr mapping) result))) (cons sym (read-string prompt))))) -(defun nnir-run-query (query) +(defun nnir-run-query (query nserver) "Invoke appropriate search engine function (see `nnir-engines'). If some groups were process-marked, run the query for each of the groups and concat the results." (let ((q (car (read-from-string query))) - (groups (nnir-sort-groups-by-server - (or gnus-group-marked (list (gnus-group-group-name)))))) + (groups (if (string= "all-ephemeral" nserver) + (with-current-buffer gnus-server-buffer + (list (list (gnus-server-server-name)))) + (nnir-sort-groups-by-server + (or gnus-group-marked (list (gnus-group-group-name))))))) (apply 'vconcat (mapcar (lambda (x) (let* ((server (car x)) @@ -1551,6 +1564,44 @@ artitem (counting from 1)." value) nil)) +(defun nnir-get-active (srv) + (let ((method (gnus-server-to-method srv)) + groups) + (gnus-request-list method) + (with-current-buffer nntp-server-buffer + (let ((cur (current-buffer)) + name) + (goto-char (point-min)) + (unless (string= gnus-ignored-newsgroups "") + (delete-matching-lines gnus-ignored-newsgroups)) + ;; We treat NNTP as a special case to avoid problems with + ;; garbage group names like `"foo' that appear in some badly + ;; managed active files. -jh. + (if (eq (car method) 'nntp) + (while (not (eobp)) + (ignore-errors + (push (cons + (mm-string-as-unibyte + (buffer-substring + (point) + (progn + (skip-chars-forward "^ \t") + (point)))) + (let ((last (read cur))) + (cons (read cur) last))) + groups)) + (forward-line)) + (while (not (eobp)) + (ignore-errors + (push (mm-string-as-unibyte + (let ((p (point))) + (skip-chars-forward "^ \t\\\\") + (setq name (buffer-substring (+ p 1) (- (point) 1))) + (gnus-group-full-name name method))) + groups)) + (forward-line))))) + groups)) + ;; The end. (provide 'nnir) --=-=-=--