2 ;; Copyright (c) 2013 Francois Fleuret
3 ;; Written by Francois Fleuret <francois@fleuret.org>
5 ;; This file is part of mymail.
7 ;; mymail is free software: you can redistribute it and/or modify it
8 ;; under the terms of the GNU General Public License version 3 as
9 ;; published by the Free Software Foundation.
11 ;; mymail is distributed in the hope that it will be useful, but
12 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 ;; General Public License for more details.
16 ;; You should have received a copy of the GNU General Public License
17 ;; along with mymail. If not, see <http://www.gnu.org/licenses/>.
19 ;; You may want to add
21 ;; (add-to-list 'recentf-exclude "/tmp/mymail-vm-.*\.mbox")
27 ;; (define-key vm-summary-mode-map "\\" 'mymail/vm-visit-folder)
29 ;; So that pressing "\" in the summary start a search with mymail
32 "Command to visit a folder built on-the-fly with mymail"
35 (defcustom mymail/default-additional-search-requests ""
36 "Comma-separated list of search requests to add to any search"
40 (defcustom mymail/default-search-request nil
41 "Default request to use in place of the empty search"
45 (defun mymail/vm-visit-folder (param)
46 "Read a comma-separated list of search requests for mymail,
47 create a temporary mbox with the resulting mails, and open it in
48 vm with `vm-visit-folder'.
50 If the request string is empty, use
51 `mymail/default-search-request' instead.
53 The string `mymail/default-additional-search-requests' is automatically
54 concatenated to the provided request, except if the request is
57 (list (read-string "mymail-vm: " nil 'mymail-vm-history)))
59 (if (string= param "")
60 (if mymail/default-search-request
61 (setq param mymail/default-search-request)
62 (error "mymail error: empty search")))
70 (lambda (searche-request)
71 (if (not (string= searche-request ""))
72 (list "--search" searche-request)))
73 (if (string= (substring param 0 1) "\\")
74 (split-string (substring param 1 nil) ",")
75 (split-string (concat param ","
76 mymail/default-additional-search-requests) ","))
80 (while (get-file-buffer (setq mbox-name (format "/tmp/mymail-vm-%d.mbox" n)))
83 (if (= (apply 'call-process
84 (nconc (list "mymail" nil nil nil
86 "--default-search" "p")
89 (vm-visit-folder mbox-name t)
90 (message "mymail failed"))