X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/2699a55464f7b43171c7b0e64d095640904e9e21..db4613576d3115aa320f0293d081ce98baa06acd:/lisp/net/mairix.el diff --git a/lisp/net/mairix.el b/lisp/net/mairix.el index bfac633c58..c1b107932c 100644 --- a/lisp/net/mairix.el +++ b/lisp/net/mairix.el @@ -1,6 +1,6 @@ ;;; mairix.el --- Mairix interface for Emacs -;; Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. +;; Copyright (C) 2008-2015 Free Software Foundation, Inc. ;; Author: David Engster ;; 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." @@ -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))) @@ -620,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))) @@ -652,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 - "(Whitespaces will be converted to ',' (i.e. AND). Use '/' for OR.)\n\n") + (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 + "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: ") @@ -751,31 +757,24 @@ VALUES may contain values for editable fields from current article." map) "'mairix-searches-mode' keymap.") -(defvar mairix-searches-mode-font-lock-keywords) - -(defun mairix-searches-mode () +(defvar mairix-searches-mode-font-lock-keywords + '(("^\\([0-9]+\\)" + (1 font-lock-constant-face)) + ("^[0-9 ]+\\(Name:\\) \\(.*\\)" + (1 font-lock-keyword-face) (2 font-lock-string-face)) + ("^[ ]+\\(Query:\\) \\(.*\\) , " + (1 font-lock-keyword-face) (2 font-lock-string-face)) + (", \\(Threads:\\) \\(.*\\)" + (1 font-lock-keyword-face) (2 font-lock-constant-face)) + ("^\\([A-Z].*\\)$" + (1 font-lock-comment-face)) + ("^[ ]+\\(Folder:\\) \\(.*\\)" + (1 font-lock-keyword-face) (2 font-lock-string-face)))) + +(define-derived-mode mairix-searches-mode fundamental-mode "mairix-searches" "Major mode for editing mairix searches." - (interactive) - (kill-all-local-variables) - (setq major-mode 'mairix-searches-mode) - (setq mode-name "mairix-searches") - (set-syntax-table text-mode-syntax-table) - (use-local-map mairix-searches-mode-map) - (make-local-variable 'font-lock-defaults) - (setq mairix-searches-mode-font-lock-keywords - (list (list "^\\([0-9]+\\)" - '(1 font-lock-constant-face)) - (list "^[0-9 ]+\\(Name:\\) \\(.*\\)" - '(1 font-lock-keyword-face) '(2 font-lock-string-face)) - (list "^[ ]+\\(Query:\\) \\(.*\\) , " - '(1 font-lock-keyword-face) '(2 font-lock-string-face)) - (list ", \\(Threads:\\) \\(.*\\)" - '(1 font-lock-keyword-face) '(2 font-lock-constant-face)) - (list "^\\([A-Z].*\\)$" - '(1 font-lock-comment-face)) - (list "^[ ]+\\(Folder:\\) \\(.*\\)" - '(1 font-lock-keyword-face) '(2 font-lock-string-face)))) - (setq font-lock-defaults '(mairix-searches-mode-font-lock-keywords))) + :syntax-table text-mode-syntax-table + (setq-local font-lock-defaults '(mairix-searches-mode-font-lock-keywords))) (defun mairix-build-search-list () "Display saved searches in current buffer." @@ -935,7 +934,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))) @@ -945,5 +944,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