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")
26 "Command to visit a folder build on-the-fly with mymail"
29 (defcustom mymail/default-additional-search-requests ""
30 "Comma-separated list of search requests to add to any search"
34 (defcustom mymail/default-search-request nil
35 "Default request to use in place of the empty search"
39 (defun mymail/vm-visit-folder (param)
40 "Read a comma-separated list of search requests for mymail,
41 create a temporary mbox with the resulting mails, and open it in
42 vm with `vm-visit-folder'.
44 If the request string is empty, use
45 `mymail/default-search-request' instead.
47 The string `mymail/default-additional-search-requests' is automatically
48 concatenated to the provided request, except if the request is
51 (list (read-string "mymail-vm: " nil 'mymail-vm-history)))
53 (if (string= param "")
54 (if mymail/default-search-request
55 (setq param mymail/default-search-request)
56 (error "mymail error: empty search")))
65 (lambda (searche-request)
66 (if (not (string= searche-request ""))
67 (list "--search" searche-request)))
68 (if (string= (substring param 0 1) "\\")
69 (split-string (substring param 1 nil) ",")
70 (split-string (concat param "," mymail/default-additional-search-requests) ","))
75 (while (get-file-buffer (setq mbox-name (format "/tmp/mymail-vm-%d.mbox" n)))
78 (if (= (apply 'call-process
79 (nconc (list "mymail" nil nil nil
81 "--default-search" "p")
84 (vm-visit-folder mbox-name t)
85 (message "mymail failed"))