Pick the mbox name dynamically so that it is not currently used in another buffer.
[mymail.git] / mymail-vm.el
1
2 ;; Copyright (c) 2013 Francois Fleuret
3 ;; Written by Francois Fleuret <francois@fleuret.org>
4 ;;
5 ;; This file is part of mymail.
6 ;;
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.
10 ;;
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.
15 ;;
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/>.
18
19 (defun mymail/vm-visit-folder (param)
20   (interactive (list (read-string "mymail-vm search: " nil 'mymail-vm-history)))
21
22   (let ((n 1)
23         (mbox-name nil)
24         (args (mapconcat (lambda (x) (concat "-s " "\"" x "\""))
25                          (split-string param ",")
26                          " ")))
27     (while (get-file-buffer (setq mbox-name (format "/tmp/mymail-vm-%d.mbox" n)))
28       (setq n (+ n 1)))
29
30     (shell-command (concat "mymail " args " > " mbox-name))
31     (vm-visit-folder mbox-name)
32   ))