From: Francois Fleuret Date: Fri, 1 Feb 2013 17:16:13 +0000 (+0100) Subject: Pick the mbox name dynamically so that it is not currently used in another buffer. X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=commitdiff_plain;h=7d57add0997d7cd4acfd39cca384c9b1b4382732;p=mymail.git Pick the mbox name dynamically so that it is not currently used in another buffer. --- diff --git a/mymail-vm.el b/mymail-vm.el index 03b52cc..b65d732 100644 --- a/mymail-vm.el +++ b/mymail-vm.el @@ -19,10 +19,14 @@ (defun mymail/vm-visit-folder (param) (interactive (list (read-string "mymail-vm search: " nil 'mymail-vm-history))) - (let ((args (mapconcat (lambda (x) (concat "-s " "\"" x "\"")) + (let ((n 1) + (mbox-name nil) + (args (mapconcat (lambda (x) (concat "-s " "\"" x "\"")) (split-string param ",") " "))) - (shell-command (concat "mymail " args " > /tmp/mymail.mbox")) - ) - (vm-visit-folder "/tmp/mymail.mbox") - ) + (while (get-file-buffer (setq mbox-name (format "/tmp/mymail-vm-%d.mbox" n))) + (setq n (+ n 1))) + + (shell-command (concat "mymail " args " > " mbox-name)) + (vm-visit-folder mbox-name) + ))