Function: mairix-call-mairix

mairix-call-mairix is a byte-compiled function defined in mairix.el.gz.

Signature

(mairix-call-mairix QUERY FILE THREADS)

Documentation

Call Mairix with QUERY and output FILE.

If FILE is nil, use default. If THREADS is non-nil, also return whole threads. Function returns t if messages were found.

Source Code

;; Defined in /usr/src/emacs/lisp/net/mairix.el.gz
(defun mairix-call-mairix (query file threads)
  "Call Mairix with QUERY and output FILE.
If FILE is nil, use default.  If THREADS is non-nil, also return
whole threads.  Function returns t if messages were found."
  (let* ((commandsplit (split-string mairix-command))
	 (args (cons
                (car commandsplit)
		(append
                 `(nil ,(get-buffer-create mairix-output-buffer) nil)
                 mairix-search-options)))
	 rval)
    (with-current-buffer mairix-output-buffer
      (erase-buffer))
    (when (> (length commandsplit) 1)
      (setq args (append args (cdr commandsplit))))
    (when threads
      (setq args (append args '("-t"))))
    (when (stringp query)
      (setq query (split-string query)))
    (setq mairix-last-search (list (mapconcat 'identity query " ")
				     file threads))
    (when (not file)
      (setq file mairix-search-file))
    (setq file
	  (concat
	   (file-name-as-directory
	    (expand-file-name
	     mairix-file-path))
	   file))
    (setq rval
	  (apply #'call-process
		 (append args (list "-o" file) query)))
    (if (zerop rval)
	(with-current-buffer mairix-output-buffer
	  (goto-char (point-min))
	  (re-search-forward "^Matched.*messages")
	  (message (match-string 0)))
      (if (and (= rval 1)
	       (with-current-buffer mairix-output-buffer
		 (goto-char (point-min))
		 (looking-at "^Matched 0 messages")))
	  (message "No messages found")
	(error "Error running Mairix.  See buffer %s for details"
	       mairix-output-buffer)))
    (zerop rval)))