]> code.delx.au - gnu-emacs/blobdiff - lisp/net/mairix.el
Merge from mainline.
[gnu-emacs] / lisp / net / mairix.el
index 22e28b5c8867eac548be65530337e0d7083f23b4..1974427c829fa86fd237a2b7a2bf9769cbed0042 100644 (file)
@@ -1,6 +1,6 @@
 ;;; mairix.el --- Mairix interface for Emacs
 
-;; Copyright (C) 2008, 2009  Free Software Foundation, Inc.
+;; Copyright (C) 2008, 2009, 2010  Free Software Foundation, Inc.
 
 ;; Author: David Engster <dengste@eml.cc>
 ;; Keywords: mail searching
@@ -228,8 +228,7 @@ Currently there are 'threads and 'flags.")
 (autoload 'rmail "rmail")
 (autoload 'rmail-summary-displayed "rmail")
 (autoload 'rmail-summary "rmailsum")
-(eval-when-compile
-  (defvar rmail-buffer))
+(defvar rmail-buffer)
 
 (defun mairix-rmail-display (folder)
   "Display mbox file FOLDER with RMail."
@@ -253,17 +252,19 @@ Currently there are 'threads and 'flags.")
       (rmail-summary))))
 
 ;; Fetching mail header field:
-(autoload 'rmail-narrow-to-non-pruned-header "rmail")
 (defun mairix-rmail-fetch-field (field)
   "Get mail header FIELD for current message using RMail."
   (unless (and (boundp 'rmail-buffer)
               rmail-buffer)
     (error "No RMail buffer available"))
-  (save-excursion
-    (set-buffer rmail-buffer)
-    (save-restriction
-      (rmail-narrow-to-non-pruned-header)
-      (mail-fetch-field field))))
+  ;; At this point, we are in rmail mode, so the rmail funcs are loaded.
+  (if (fboundp 'rmail-get-header)      ; Emacs 23
+      (rmail-get-header field)
+    (with-current-buffer rmail-buffer
+      (save-restriction
+       ;; Don't warn about this when compiling Emacs 23.
+       (with-no-warnings (rmail-narrow-to-non-pruned-header))
+       (mail-fetch-field field)))))
 
 ;;; Gnus
 (eval-when-compile
@@ -292,10 +293,9 @@ Currently there are 'threads and 'flags.")
   "Get mail header FIELD for current message using Gnus."
   (unless (gnus-alive-p)
     (error "Gnus is not running"))
-  (save-excursion
-    (unless (gnus-buffer-exists-p gnus-article-buffer)
-      (error "No article buffer available"))
-    (set-buffer gnus-article-buffer)
+  (unless (gnus-buffer-exists-p gnus-article-buffer)
+    (error "No article buffer available"))
+  (with-current-buffer gnus-article-buffer
     (gnus-summary-toggle-header 1)
     (message-field-value field)))
 
@@ -341,7 +341,7 @@ Currently there are 'threads and 'flags.")
 
 (defun mairix-search (search threads)
   "Call Mairix with SEARCH.
-If THREADS is t, also display whole threads of found
+If THREADS is non-nil, also display whole threads of found
 messages.  Results will be put into the default search file."
   (interactive
    (list
@@ -595,9 +595,7 @@ See %s for details" mairix-output-buffer)))
   "Send query from WIDGETS to mairix binary."
   (mairix-search
    (mairix-widget-make-query-from-widgets widgets)
-   (if (widget-value (cadr (assoc "Threads" widgets)))
-       t
-     -1))
+   (if (widget-value (cadr (assoc "Threads" widgets))) t))
   (kill-buffer mairix-customize-query-buffer))
 
 (defun mairix-widget-save-search (widgets)