[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: imap patches for nnir



Kai.Grossjohann@CS.Uni-Dortmund.DE writes:

>   > It still performs the same search more than once though, making it
>   > somewhat inefficient. This is with nnir 1.40.
> 
> Hm.

I'll try to trace it.

> I have got a mechanism for specifying arbitrary search parameters in a
> backend-specific way.  See the glimpse entry in nnir-engines and the
> function nnir-run-glimpse for an example of how it is used.  The
> prompting of the user happends automatically after C-u G G and is
> centrally defined in nnir-read-parms.

I'll look into using this to something meaningful. Perhaps we could
ask the user if he want to search headers, full-body, dates or
something.

I'm not sure you want to query which groups should be searched via a
prompt, even if it has group name completion -- the group process
marks are perfect for that.

Anyway, I just finished hacking nnir-run-imap to behave just like I
want it to: `#' some groups in the group buffer and then `G G', enter
your query. Then only the groups you marked are searched. Is this
behaviour OK with you?

I've immediately found how extremely useful nnir is, it's great! No
more logging in on the server and then grep'ing through mailboxes. :-)

The entire nnir-run-imap function:

(defun nnir-run-imap (query)
  (require 'imap)
  (require 'nnimap)
  (save-excursion
    (let ((qstring (cdr (assq 'query query)))
	  (server (cadr nnir-mail-backend))
	  (defs (caddr nnir-mail-backend))
	  artlist buf)
      (message "Opening server %s" server)
      (condition-case ()
	  (when (nnimap-open-server server defs) ;; xxx
	    (setq buf nnimap-server-buffer) ;; xxx
	    (if (null gnus-group-marked)
		(error "No process marked groups")
	      (mapcar
	       (lambda (group)
		 (let ((arts 0)
		       (mbx (gnus-group-real-name group)))
		   (message "Searching %s..." mbx)
		   (when (imap-mailbox-select mbx buf)
		     (mapcar
		      (lambda (artnum)
			(push (vector mbx artnum 1) artlist)
			(setq arts (1+ arts)))
		      (imap-search (concat "TEXT \"" qstring "\"") buf))
		     (message "Searching %s... %d matches" mbx arts))))
	       gnus-group-marked))
	    (message "Searching mailboxes...done"))
	(quit nil))
      (reverse artlist))))