]> code.delx.au - gnu-emacs/blobdiff - lisp/net/mairix.el
* net/tramp-cache.el (tramp-connection-properties): New customer option.
[gnu-emacs] / lisp / net / mairix.el
index b5fb92e5c6f5d7c70ce85383c1ed21cd747689d9..e6a5f8299ac4c219f572d21361201beaf309fd1f 100644 (file)
@@ -1,6 +1,6 @@
 ;;; mairix.el --- Mairix interface for Emacs
 
-;; Copyright (C) 2008, 2009, 2010  Free Software Foundation, Inc.
+;; Copyright (C) 2008-2013 Free Software Foundation, Inc.
 
 ;; Author: David Engster <dengste@eml.cc>
 ;; Keywords: mail searching
@@ -51,7 +51,7 @@
 ;; Currently, RMail, Gnus (with mbox files), and VM are supported as
 ;; mail programs, but it is pretty easy to interface it with other
 ;; ones as well.  Please see the docs and the source for details.
-;; In a nutshell: include your favourite mail program in
+;; In a nutshell: include your favorite mail program in
 ;; `mairix-mail-program' and write functions for
 ;; `mairix-display-functions' and `mairix-get-mail-header-functions'.
 ;; If you have written such functions for your Emacs mail program of
@@ -70,8 +70,6 @@
 (require 'widget)
 (require 'cus-edit)
 
-(eval-when-compile
-  (require 'cl))
 
 ;;; Keymappings
 
@@ -224,14 +222,12 @@ Currently there are 'threads and 'flags.")
 
 ;;; RMail
 
-;; Display function:
-(autoload 'rmail "rmail")
-(autoload 'rmail-summary-displayed "rmail")
-(autoload 'rmail-summary "rmailsum")
-(defvar rmail-buffer)
+(declare-function rmail-summary-displayed "rmail" ())
+(declare-function rmail-summary "rmailsum" ()) ; autoloaded in rmail
 
 (defun mairix-rmail-display (folder)
   "Display mbox file FOLDER with RMail."
+  (require 'rmail)
   (let (show-summary)
     ;; If it exists, select existing RMail window
     (when (and (boundp 'rmail-buffer)
@@ -251,6 +247,8 @@ Currently there are 'threads and 'flags.")
     (when show-summary
       (rmail-summary))))
 
+(defvar rmail-buffer)
+
 ;; Fetching mail header field:
 (defun mairix-rmail-fetch-field (field)
   "Get mail header FIELD for current message using RMail."
@@ -341,7 +339,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
@@ -570,10 +568,10 @@ whole threads.  Function returns t if messages were found."
               mairix-output-buffer)))
     (zerop rval)))
 
-(defun mairix-replace-illegal-chars (header)
-  "Replace illegal characters in HEADER for mairix query."
+(defun mairix-replace-invalid-chars (header)
+  "Replace invalid characters in HEADER for mairix query."
   (when header
-    (while (string-match "[^-.@/,& [:alnum:]]" header)
+    (while (string-match "[^-.@/,^=~& [:alnum:]]" header)
       (setq header (replace-match "" t t header)))
     (while (string-match "[& ]" header)
       (setq header (replace-match "," t t header)))
@@ -595,9 +593,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)
@@ -622,7 +618,7 @@ See %s for details" mairix-output-buffer)))
         (concat
          (nth 1 cur)
          ":"
-         (mairix-replace-illegal-chars
+         (mairix-replace-invalid-chars
           (widget-value
           (cadr (assoc (concat "e" (car (cddr cur))) widgets)))))
         query)))
@@ -654,9 +650,17 @@ Fill in VALUES if based on an article."
     (kill-all-local-variables)
     (erase-buffer)
     (widget-insert
-     "Specify your query for Mairix (check boxes for activating fields):\n\n")
+     "Specify your query for Mairix using check boxes for activating fields.\n\n")
+    (widget-insert
+     (concat "Use ~word        to match messages "
+            (propertize "not" 'face 'italic)
+            " containing the word)\n"
+            "    substring=   to match words containing the substring\n"
+            "    substring=N  to match words containing the substring, allowing\n"
+            "                  up to N errors(missing/extra/different letters)\n"
+            "    ^substring=  to match the substring at the beginning of a word.\n"))
     (widget-insert
-     "(Whitespaces will be converted to ',' (i.e. AND). Use '/' for OR.)\n\n")
+     "Whitespace will be converted to ',' (i.e. AND).  Use '/' for OR.\n\n")
     (setq mairix-widgets (mairix-widget-build-editable-fields values))
     (when (member 'flags mairix-widget-other)
       (widget-insert "\nFlags:\n      Seen:     ")
@@ -737,23 +741,21 @@ VALUES may contain values for editable fields from current article."
 
 ;;;; Major mode for editing/deleting/saving searches
 
-(defvar mairix-searches-mode-map nil "'mairix-searches-mode' keymap.")
-
-;; Keymap
-(if (not mairix-searches-mode-map)
-    (let ((map (make-keymap)))
-      (define-key map [(return)] 'mairix-select-search)
-      (define-key map [(down)] 'mairix-next-search)
-      (define-key map [(up)] 'mairix-previous-search)
-      (define-key map [(right)] 'mairix-next-search)
-      (define-key map [(left)] 'mairix-previous-search)
-      (define-key map "\C-p" 'mairix-previous-search)
-      (define-key map "\C-n" 'mairix-next-search)
-      (define-key map [(q)] 'mairix-select-quit)
-      (define-key map [(e)] 'mairix-select-edit)
-      (define-key map [(d)] 'mairix-select-delete)
-      (define-key map [(s)] 'mairix-select-save)
-      (setq mairix-searches-mode-map map)))
+(defvar mairix-searches-mode-map
+  (let ((map (make-keymap)))
+    (define-key map [(return)] 'mairix-select-search)
+    (define-key map [(down)] 'mairix-next-search)
+    (define-key map [(up)] 'mairix-previous-search)
+    (define-key map [(right)] 'mairix-next-search)
+    (define-key map [(left)] 'mairix-previous-search)
+    (define-key map "\C-p" 'mairix-previous-search)
+    (define-key map "\C-n" 'mairix-next-search)
+    (define-key map [(q)] 'mairix-select-quit)
+    (define-key map [(e)] 'mairix-select-edit)
+    (define-key map [(d)] 'mairix-select-delete)
+    (define-key map [(s)] 'mairix-select-save)
+    map)
+  "'mairix-searches-mode' keymap.")
 
 (defvar mairix-searches-mode-font-lock-keywords)
 
@@ -939,7 +941,7 @@ Use cursor keys or C-n,C-p to select next/previous search.\n\n")
              (lambda (field)
                (list (car (cddr field))
                      (if (car field)
-                         (mairix-replace-illegal-chars
+                         (mairix-replace-invalid-chars
                           (funcall get-mail-header (car field)))
                        nil))))
             mairix-widget-fields-list)))
@@ -949,5 +951,3 @@ Use cursor keys or C-n,C-p to select next/previous search.\n\n")
 (provide 'mairix)
 
 ;;; mairix.el ends here
-
-;; arch-tag: 787ab678-fcd5-4c50-9295-01c2ee5124a6