X-Git-Url: https://www.fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=blobdiff_plain;f=mymail-vm.el;h=dc1976c3c937fefc2cd54d22af9dc9d111a6e5ea;hb=32a03eca0ebb48facce97a8740993e2df893d518;hp=b65d732429693f890dc195a9f7a2d8180be797e4;hpb=7d57add0997d7cd4acfd39cca384c9b1b4382732;p=mymail.git diff --git a/mymail-vm.el b/mymail-vm.el index b65d732..dc1976c 100644 --- a/mymail-vm.el +++ b/mymail-vm.el @@ -16,17 +16,49 @@ ;; You should have received a copy of the GNU General Public License ;; along with mymail. If not, see . +(add-to-list 'recentf-exclude "/tmp/mymail-vm-.*\.mbox") + +(defcustom mymail/default-search-request "" + "Default request to add to any search" + :type 'string) + (defun mymail/vm-visit-folder (param) - (interactive (list (read-string "mymail-vm search: " nil 'mymail-vm-history))) + "Read a comma-separated list of search requests for mymail, +create a temporary mbox with the resulting mails, and open it in +vm with `vm-visit-folder'. + +The string `mymail/default-search-request' is automatically +concatenated to the provided request, except if the request is +prefaced with \\." + (interactive + (list (read-string "mymail-vm: " nil 'mymail-vm-history))) (let ((n 1) (mbox-name nil) - (args (mapconcat (lambda (x) (concat "-s " "\"" x "\"")) - (split-string param ",") - " "))) + + (search-args + + (apply 'nconc + (mapcar + (lambda (searche-request) + (if (not (string= searche-request "")) + (list "--search" searche-request))) + (if (string= (substring param 0 1) "\\") + (split-string (substring param 1 nil) ",") + (split-string (concat param "," mymail/default-search-request) ",")) + ))) + + ) + (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) + (if (= (apply 'call-process + (nconc (list "mymail" nil nil nil + "--output" mbox-name + "--default-search" "p") + search-args)) + 0) + (vm-visit-folder mbox-name t) + (message "mymail failed")) ))