Gour <
go...@atmarama.net> writes:
> In the past when I was using getmail I was invoking it via
> cronjob, but now I wonder how you do it, iow. how does your
> 'mu4e-get-mail-command' look like?
i just use cronjobs also - i have several accounts, and the
higher-volume accounts get checked more regularly than the
lower-volume accounts. So `mu4e-get-mail-command` is set to
"true". :-)
However, when i occasionally want to check an account manually, i
use this:
(defun get-mail (account)
"Run `getmail' for account specified by ACCOUNT."
(interactive
(list
(completing-read
"Email account? " (my-filter
#'(lambda (e)
(if (string-match "\.gm$" e)
e))
(directory-files "~/.getmail/")))))
(let ((b (generate-new-buffer " *getmail*")))
(start-process-shell-command "getmail" b (concat
"/usr/bin/getmail -r " account)) (set-process-sentinel
(get-process "getmail") #'(lambda (process event)
(with-current-buffer " *getmail*"
(goto-char (point-min)) (re-search-forward "^
\\([[:digit:]].+\\)") (message (match-string 1))
(kill-buffer " *getmail*") (mu4e-update-index)
(save-window-excursion
(mu4e-headers-rerun-search)))))))
(Each of my getmail account configs ends in a '.gm' extension.)
Here's my definition of `my-filter` (which i'm guessing could be
more elegant!):
(defun my-filter (f l &optional r)
"Filter a list L using predicate function F, returning
a list of list elements for which F is true."
(let ((a (car-safe l)))
(if a
(if (funcall f a)
(my-filter
f (cdr l) (if r
(append r (list a))
(list a)))
(my-filter
f (cdr l) (if r
r)))
r)))
Alexis.