From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/72850 Path: news.gmane.org!not-for-mail From: Andrew Cohen Newsgroups: gmane.emacs.gnus.general Subject: Re: Any juicy outstanding Gnus bugs? Date: Sun, 10 Oct 2010 09:23:49 -0400 Message-ID: <877hhq18re.fsf@andy.bu.edu> References: <877hi89wks.fsf@dod.no> <87r5gf1co1.fsf@andy.bu.edu> <87d3rz10v9.fsf@andy.bu.edu> <87bp754q00.fsf@andy.bu.edu> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1286717049 6428 80.91.229.12 (10 Oct 2010 13:24:09 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 10 Oct 2010 13:24:09 +0000 (UTC) To: ding@gnus.org Original-X-From: ding-owner+M21222@lists.math.uh.edu Sun Oct 10 15:24:08 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 1P4vsl-0005XC-Hv for ding-account@gmane.org; Sun, 10 Oct 2010 15:24:08 +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 1P4vsj-00019o-4R; Sun, 10 Oct 2010 08:24:05 -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 1P4vsh-00019b-Id for ding@lists.math.uh.edu; Sun, 10 Oct 2010 08:24:03 -0500 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx2.math.uh.edu with esmtp (Exim 4.72) (envelope-from ) id 1P4vsd-0008TT-2u for ding@lists.math.uh.edu; Sun, 10 Oct 2010 08:24:03 -0500 Original-Received: from lo.gmane.org ([80.91.229.12]) by quimby.gnus.org with esmtp (Exim 3.36 #1 (Debian)) id 1P4vsc-0008Gv-00 for ; Sun, 10 Oct 2010 15:23:58 +0200 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1P4vsc-0005TU-71 for ding@gnus.org; Sun, 10 Oct 2010 15:23:58 +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 ; Sun, 10 Oct 2010 15:23:58 +0200 Original-Received: from cohen by andy.bu.edu with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 10 Oct 2010 15:23:58 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 211 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:IrMsYOSisaQa20c14GkZxZJ10Sw= X-Spam-Score: -1.9 (-) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:72850 Archived-At: --=-=-= Content-Type: text/plain >>>>> "Lars" == Lars Magne Ingebrigtsen writes: Lars> Looks good. Can you provide a ChangeLog entry, too, and I'll Lars> apply it? I've cleaned things up a bit to work better with the gnus-completing-read changes that Julien has implemented. Below is a new patch and a Changelog. >> + (format "%s \"%s\"" criteria (nnir-imap-quote-specials expr))) Lars> The "%S" format spec does this: Lars> (insert (format "%S" "foo\\ bar\" zot")) -> "foo\\ bar\" zot" I have no idea why the original code didn't use %S, so I've changed it and eliminated the need for imap-quote-specials. Regards, Andy --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=nnir.el.diff Content-Description: nnir.el diff --git a/lisp/nnir.el b/lisp/nnir.el index 86acad1..2a264d1 100644 --- a/lisp/nnir.el +++ b/lisp/nnir.el @@ -339,23 +339,34 @@ (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) (gnus-declare-backend "nnir" 'mail) -(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 \"\"") +(defvar nnir-imap-default-search-key "Whole message" + "The default IMAP search key for an nnir search. Must be one of + the keys in nnir-imap-search-arguments. To use raw 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 . "")) - "Mapping from user readable strings to IMAP search items for use in nnir") + ("Imap" . "")) + "Mapping from user readable keys to IMAP search items for use in nnir") + +(defvar nnir-imap-search-other "HEADER %S" + "The IMAP search item to use for anything other than + nnir-imap-search-arguments. By default this is the name of an + email header field") (defvar nnir-imap-search-argument-history () "The history for querying search options in nnir") @@ -375,12 +386,12 @@ result, `gnus-retrieve-headers' will be called instead.") ()) (imap nnir-run-imap ((criteria - "Search in: " ; Prompt + "Search in" ; Prompt ,(mapcar 'car nnir-imap-search-arguments) ; alist for completing nil ; allow any user input nil ; initial value nnir-imap-search-argument-history ; the history to use - ,nnir-imap-search-field ; default + ,nnir-imap-default-search-key ; default ))) (swish++ nnir-run-swish++ ((group . "Group spec: "))) @@ -702,19 +713,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" @@ -936,22 +958,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. @@ -963,7 +972,8 @@ details on the language and supported extensions" (group (or group-option (gnus-group-group-name))) (defs (caddr (gnus-server-to-method srv))) (criteria (or (cdr (assq 'criteria query)) - nnir-imap-search-field)) + (cdr (assoc nnir-imap-default-search-key + nnir-imap-search-arguments)))) (gnus-inhibit-demon t) artlist) (message "Opening server %s" server) @@ -1044,7 +1054,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 expr)) ;; Trivial term: and ((eq expr 'and) nil) ;; Composite term: or expression @@ -1580,7 +1590,7 @@ Tested with Namazu 2.0.6 on a GNU/Linux system." (if (listp prompt) (let* ((result (apply 'gnus-completing-read prompt)) (mapping (or (assoc result nnir-imap-search-arguments) - (assoc nil nnir-imap-search-arguments)))) + (cons nil nnir-imap-search-other)))) (cons sym (format (cdr mapping) result))) (cons sym (read-string prompt))))) --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=Changelog.diff Content-Description: Changelog diff --git a/lisp/ChangeLog b/lisp/ChangeLog index bae698a..bb4dee7 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,13 @@ +2010-10-10 Andrew Cohen + + * nnir.el (autoload): Clean up autoloads. + (nnir-imap-default-search-key): Renamed from + nnir-imap-search-field. Use key rather than value. + (nnir-imap-search-other): New variable. + (nnir-read-parm): Use it. + (nnir-imap-expr-to-imap): Use %S rather than imap-quote-specials. + (gnus-summary-nnir-goto-thread): Modify to work with imap. + 2010-10-09 Lars Magne Ingebrigtsen * spam.el (gnus-summary-mode-map): Bind to "$". Suggested by Russ --=-=-=--