;;; 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
(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."
(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
"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)))
(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
"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)