Bind RET and TAB on images for better UX.
[gnus] / lisp / nnmairix.el
index cf00531..04db76b 100644 (file)
@@ -1,6 +1,6 @@
 ;;; nnmairix.el --- Mairix back end for Gnus, the Emacs newsreader
 
-;; Copyright (C) 2007, 2008  Free Software Foundation, Inc.
+;; Copyright (C) 2007, 2008, 2009, 2010  Free Software Foundation, Inc.
 
 ;; Author: David Engster <dengste@eml.cc>
 ;; Keywords: mail searching
@@ -23,9 +23,6 @@
 
 ;;; Commentary:
 
-;; THIS IS BETA SOFTWARE! This back end should not mess up or
-;; even delete your mails, but having a backup is always a good idea.
-
 ;; This is a back end for using the mairix search engine with
 ;; Gnus.  Mairix is a tool for searching words in locally stored
 ;; mail.  Mairix is very fast which allows using it efficiently for
 ;;
 ;; Mairix is written by Richard Curnow.  More information can be found at
 ;; http://www.rpcurnow.force9.co.uk/mairix/
-;;
-;; For details about setting up mairix&Gnus&nnmairix.el, look at the
-;; emacswiki:
-;;
-;; http://www.emacswiki.org/cgi-bin/wiki/GnusMairix
-;;
-;; The newest version of nnmairix.el can be found at
-;;
-;; http://www.emacswiki.org/cgi-bin/emacs/nnmairix.el
-
-;; For impatient people, here's the setup in a nutshell:
-;;
-;; This back end requires an installed mairix binary which is
-;; configured to index your mail folder.  You don't have to specify a
-;; search folder (but it does no harm, either).  Visit the man page of
-;; mairix and mairixrc for details.
-;;
-;; Put nnmairix.el into your search path and "(require 'nnmarix)" into
-;; your .gnus.  Then call nnmairix-create-default-group (or 'G b
-;; c'). This function will ask for all necessary information to create
-;; a mairix server in Gnus with the default search folder.  This
-;; default search folder will be used for all temporary searches: call
-;; nnmairix-search ('G b s') and enter a mairix query (like
-;; f:test@example.com). To create a mairix group for one specific
-;; search query, use 'G b g'.  See the emacswiki or the source for more
-;; information.
 
 ;; Commentary on the code: nnmairix sits between Gnus and the "real"
 ;; back end which handles the mail (currently nnml, nnimap and
 
 ;;; Code:
 
+(eval-when-compile (require 'cl))       ;For (pop (cdr ogroup)).
+
 (require 'nnoo)
 (require 'gnus-group)
 (require 'gnus-sum)
@@ -520,7 +493,7 @@ Other back ends might or might not work.")
        (when (eq nnmairix-backend 'nnml)
          (when nnmairix-rename-files-for-nnml
            (nnmairix-rename-files-consecutively mfolder))
-         (nnml-generate-nov-databases-directory mfolder))
+         (nnml-generate-nov-databases-directory mfolder nil t))
        (nnmairix-call-backend
         "request-scan" folder nnmairix-backend-server)
        (if (and fast allowfast)
@@ -583,8 +556,13 @@ Other back ends might or might not work.")
            (mapcar
             (lambda (arg) (- arg numcorr))
             articles)))
-    (setq rval (nnmairix-call-backend
-               "retrieve-headers" articles folder nnmairix-backend-server fetch-old))
+    (setq rval
+         (if (eq nnmairix-backend 'nnimap)
+             (let ((gnus-nov-is-evil t))
+               (nnmairix-call-backend
+                "retrieve-headers" articles folder nnmairix-backend-server fetch-old))
+           (nnmairix-call-backend
+            "retrieve-headers" articles folder nnmairix-backend-server fetch-old)))
     (when (eq rval 'nov)
       (nnmairix-replace-group-and-numbers articles folder group numcorr)
       rval)))
@@ -627,6 +605,12 @@ Other back ends might or might not work.")
        t)
     nil))
 
+;; Silence byte-compiler.
+(defvar gnus-registry-install)
+(autoload 'gnus-registry-fetch-group "gnus-registry")
+(autoload 'gnus-registry-fetch-groups "gnus-registry")
+(autoload 'gnus-registry-add-group "gnus-registry")
+
 (deffoo nnmairix-request-set-mark (group actions &optional server)
   (when server
     (nnmairix-open-server server))
@@ -722,6 +706,8 @@ Other back ends might or might not work.")
        (gnus-group-jump-to-group qualgroup)
        (gnus-group-get-new-news-this-group))))))
 
+(autoload 'nnimap-request-update-info-internal "nnimap")
+
 (deffoo nnmairix-request-update-info (group info &optional server)
 ;; propagate info from underlying IMAP folder to nnmairix group
 ;; This is currently experimental and must be explicitly activated
@@ -867,7 +853,7 @@ All necessary information will be queried from the user."
   (interactive)
   (let* ((name (read-string "Name of the mairix server: "))
        (server (completing-read "Back end server (TAB for completion): "
-                                (nnmairix-get-valid-servers)))
+                                (nnmairix-get-valid-servers) nil 1))
        (mairix (read-string "Command to call mairix: " "mairix"))
        (defaultgroup (read-string "Default search group: "))
        (backend (symbol-name (car (gnus-server-to-method server))))
@@ -1116,13 +1102,9 @@ with `nnmairix-mairix-update-options'."
          (set-process-sentinel (apply 'start-process args)
                                'nnmairix-sentinel-mairix-update-finished))))))
 
-;; Silence byte-compiler.
-(defvar gnus-registry-install)
-(autoload 'gnus-registry-fetch-group "gnus-registry")
-
 (defun nnmairix-group-delete-recreate-this-group ()
   "Deletes and recreates group on the back end.
-You can use this function on nnmairix groups which continously
+You can use this function on nnmairix groups which continuously
 show wrong article counts."
   (interactive)
   (let* ((group (gnus-group-group-name))
@@ -1217,7 +1199,8 @@ If UPDATEDB is t, database for SERVERNAME will be updated first."
          (unless (and skipdefault
                       (string= (car cur) default))
            (gnus-group-jump-to-group (car cur))
-           (gnus-group-get-new-news-this-group)))))))
+           (gnus-group-mark-group 1)))
+       (gnus-group-get-new-news-this-group)))))
 
 (defun nnmairix-remove-tick-mark-original-article ()
   "Remove tick mark from original article.
@@ -1686,6 +1669,11 @@ SERVER."
   (nnmairix-open-server server)
   (while (string-match "[<>]" mid)
     (setq mid (replace-match "" t t mid)))
+  ;; mairix somehow does not like '$' in message-id
+  (when (string-match "\\$" mid)
+    (setq mid (concat mid "=")))
+  (while (string-match "\\$" mid)
+    (setq mid (replace-match "=," t t mid)))
   (let (allgroups)
     (if (zerop (nnmairix-call-mairix-binary-raw
                (split-string nnmairix-mairix-command)
@@ -2056,5 +2044,4 @@ VALUES may contain values for editable fields from current article."
 
 (provide 'nnmairix)
 
-;; arch-tag: bb187498-b229-4a55-8c07-6d3f80713e94
 ;;; nnmairix.el ends here