From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/72760 Path: news.gmane.org!not-for-mail From: Andrew Cohen Newsgroups: gmane.emacs.gnus.general Subject: Re: Any juicy outstanding Gnus bugs? Date: Thu, 07 Oct 2010 18:06:23 -0400 Message-ID: <87bp754q00.fsf@andy.bu.edu> References: <877hi89wks.fsf@dod.no> <87r5gf1co1.fsf@andy.bu.edu> <87d3rz10v9.fsf@andy.bu.edu> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1286489216 24379 80.91.229.12 (7 Oct 2010 22:06:56 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 7 Oct 2010 22:06:56 +0000 (UTC) To: ding@gnus.org Original-X-From: ding-owner+M21132@lists.math.uh.edu Fri Oct 08 00:06:55 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 1P3yc1-0006oV-Fo for ding-account@gmane.org; Fri, 08 Oct 2010 00:06:54 +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 1P3ybu-00074l-A5; Thu, 07 Oct 2010 17:06:46 -0500 Original-Received: from mx2.math.uh.edu ([129.7.128.33]) by util0.math.uh.edu with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1P3ybs-00074T-5T for ding@lists.math.uh.edu; Thu, 07 Oct 2010 17:06:44 -0500 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx2.math.uh.edu with esmtp (Exim 4.72) (envelope-from ) id 1P3ybq-0005eY-DA for ding@lists.math.uh.edu; Thu, 07 Oct 2010 17:06:43 -0500 Original-Received: from lo.gmane.org ([80.91.229.12]) by quimby.gnus.org with esmtp (Exim 3.36 #1 (Debian)) id 1P3ybp-00023e-00 for ; Fri, 08 Oct 2010 00:06:41 +0200 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1P3ybk-0006iB-Pz for ding@gnus.org; Fri, 08 Oct 2010 00:06:36 +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, 08 Oct 2010 00:06:36 +0200 Original-Received: from cohen by andy.bu.edu with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 08 Oct 2010 00:06:36 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 182 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:7MOpYGYzrJUf7yOKO2lp5oGM2fY= X-Spam-Score: -1.9 (-) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:72760 Archived-At: --=-=-= Content-Type: text/plain It took longer than I expected but all the required paperwork went to the FSF on Wednesday, so hopefully this is now taken care of. Attached is a patch for nnir.el that does a few things: 1. gnus-summary-nnir-goto-thread implementation for imap. I'm finding the thread by searching for all articles that are referenced by the original article, or reference any of the articles referenced by the original article (i.e. I'm being pretty aggressive in finding the thread). It seems quite fast, but if it turns out to be too slow it is easily changed. 2. Fixes gnus-completing-read (the recent changeover broke things). 3. Cleans up the autoloads and some obsolete comments. One function was still loaded from the old imap.el and I thought it might be prudent to move this function into nnir.el (imap-quote-specials) so that imap.el can just go away. Regards, Andy --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=nnir.el.diff Content-Description: nnir.el.patch diff --git a/lisp/nnir.el b/lisp/nnir.el index 3739cb8..4e8a97b 100644 --- a/lisp/nnir.el +++ b/lisp/nnir.el @@ -339,6 +339,12 @@ (eval-when-compile (require 'cl)) + +(eval-when-compile + (autoload 'nnimap-buffer "nnimap") + (autoload 'nnimap-command "nnimap") + (autoload 'nnimap-possibly-change-group "nnimap")) + (nnoo-declare nnir) (nnoo-define-basics nnir) @@ -346,15 +352,15 @@ (defvar nnir-imap-search-field "TEXT" "The IMAP search item when doing an nnir search. To use raw - imap queries by default set this to \"\"") + imap queries by default set this to \"Imap\"") (defvar nnir-imap-search-arguments '(("Whole message" . "TEXT") ("Subject" . "SUBJECT") ("To" . "TO") ("From" . "FROM") - ("Head" . "HEADER \"%s\"") - (nil . "")) + ("Imap" . "") + (nil . "HEADER \"%s\"")) "Mapping from user readable strings to IMAP search items for use in nnir") (defvar nnir-imap-search-argument-history () @@ -375,9 +381,8 @@ result, `gnus-retrieve-headers' will be called instead.") ()) (imap nnir-run-imap ((criteria - "Search in: " ; Prompt + "Search in" ; Prompt ,nnir-imap-search-arguments ; alist for completing - nil ; no filtering nil ; allow any user input nil ; initial value nnir-imap-search-argument-history ; the history to use @@ -703,19 +708,30 @@ and show thread that contains this article." (let* ((cur (gnus-summary-article-number)) (group (nnir-artlist-artitem-group nnir-artlist cur)) (backend-number (nnir-artlist-artitem-number nnir-artlist cur)) - server backend-group) - (setq server (nnir-group-server group)) - (setq backend-group (gnus-group-real-name group)) - (gnus-group-read-ephemeral-group - backend-group - (gnus-server-to-method server) - t ; activate - (cons (current-buffer) - 'summary) ; window config - nil - (list backend-number)) - (gnus-summary-limit (list backend-number)) - (gnus-summary-refer-thread))) + (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))))))))) + (gnus-summary-read-group-1 group t t gnus-summary-buffer + nil (list backend-number)) + (gnus-summary-limit (list backend-number)) + (gnus-summary-refer-thread)))) + (if (fboundp 'eval-after-load) (eval-after-load "gnus-sum" @@ -937,22 +953,9 @@ pairs (also vectors, actually)." ;; IMAP interface. ;; todo: -;; nnir invokes this two (2) times???! -;; we should not use nnimap at all but open our own server connection -;; we should not LIST * but use nnimap-list-pattern from defs ;; send queries as literals ;; handle errors -(autoload 'nnimap-open-server "nnimap") -(defvar nnimap-server-buffer) ;; nnimap.el -(autoload 'imap-mailbox-select "imap") -(autoload 'imap-search "imap") -(autoload 'imap-quote-specials "imap") - -(eval-when-compile - (autoload 'nnimap-buffer "nnimap") - (autoload 'nnimap-command "nnimap") - (autoload 'nnimap-possibly-change-group "nnimap")) (defun nnir-run-imap (query srv &optional group-option) "Run a search against an IMAP back-end server. @@ -1045,7 +1048,7 @@ In future the following will be added to the language: (cond ;; Simple string term ((stringp expr) - (format "%s \"%s\"" criteria (imap-quote-specials expr))) + (format "%s \"%s\"" criteria (nnir-imap-quote-specials expr))) ;; Trivial term: and ((eq expr 'and) nil) ;; Composite term: or expression @@ -1579,7 +1582,7 @@ Tested with Namazu 2.0.6 on a GNU/Linux system." (let ((sym (car parmspec)) (prompt (cdr parmspec))) (if (listp prompt) - (let* ((result (gnus-completing-read prompt nil)) + (let* ((result (apply 'gnus-completing-read prompt)) (mapping (or (assoc result nnir-imap-search-arguments) (assoc nil nnir-imap-search-arguments)))) (cons sym (format (cdr mapping) result))) @@ -1693,6 +1696,16 @@ The Gnus backend/server information is added." with-dups) res)) +(defun nnir-imap-quote-specials (string) + (with-temp-buffer + (insert string) + (goto-char (point-min)) + (while (re-search-forward "[\\\"]" nil t) + (forward-char -1) + (insert "\\") + (forward-char 1)) + (buffer-string))) + ;; The end. (provide 'nnir) --=-=-=--