Changed indentation to avoid a gcc warning.
[mymail.git] / mymail-vm.el
index 840bd93..2c9970f 100644 (file)
 ;; (add-to-list 'recentf-exclude "/tmp/mymail-vm-.*\.mbox")
 ;;
 ;; to your .emacs
+;;
+;; I also use
+;;
+;; (define-key vm-summary-mode-map "\\" 'mymail/vm-visit-folder)
+;;
+;; So that pressing "\" in the summary start a search with mymail
 
 (defgroup mymail ()
-  "Command to visit a folder build on-the-fly with mymail"
-  :version "0.9.5")
+  "Command to visit a folder built on-the-fly with mymail"
+  :version "0.9.10")
 
 (defcustom mymail/default-additional-search-requests ""
   "Comma-separated list of search requests to add to any search"
@@ -46,7 +52,7 @@ If the request string is empty, use
 
 The string `mymail/default-additional-search-requests' is automatically
 concatenated to the provided request, except if the request is
-prefaced with \\."
+prefaced with `\\'."
   (interactive
    (list (read-string "mymail-vm: " nil 'mymail-vm-history)))
 
@@ -59,28 +65,43 @@ prefaced with \\."
         (mbox-name nil)
 
         (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-additional-search-requests) ","))
-           )))
-
+                (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-additional-search-requests) ","))
+                 )))
         )
 
     (while (get-file-buffer (setq mbox-name (format "/tmp/mymail-vm-%d.mbox" n)))
       (setq n (+ n 1)))
 
+    ;; (message (prin1-to-string
+              ;; (nconc (list "mymail"
+                           ;; "--output" mbox-name
+                           ;; "--default-search" "p"
+                           ;; "--nb-mails-max" "500")
+                     ;; search-args))
+             ;; )
+
     (if (= (apply 'call-process
-                  (nconc (list "mymail" nil nil nil
+                  (nconc (list "mymail" nil '(nil "/tmp/mymail.err") nil
                                "--output" mbox-name
-                               "--default-search" "p")
+                               "--default-search" "p"
+                               "--nb-mails-max" "500")
                          search-args))
            0)
         (vm-visit-folder mbox-name t)
-      (message "mymail failed"))
-  ))
+
+      ;; (message "mymail failed. See /tmp/mymail.err"))
+
+      (message (with-temp-buffer
+                 (insert-file-contents "/tmp/mymail.err")
+                 (replace-string "\n" " ")
+                 (buffer-string)))
+      )
+    ))