From: Eric Abrahamsen <eric@ericabrahamsen.net>
To: ding@gnus.org
Subject: Fetching underlying imap mail on M-g
Date: Thu, 04 Jun 2020 10:06:51 -0700 [thread overview]
Message-ID: <87img6sqtw.fsf@ericabrahamsen.net> (raw)
I'm posting this here just in case it's useful to anyone; I'm finding it
very handy.
I store my IMAP mail in a local dovecot, updated using "mbsync". I've
got several IMAP accounts, with a lot of groups, and was getting sick of
switching to the shell and running "mbsync -a", then back to Gnus, and
eventually "g". I tried a few things with an asynchronous update from
withing Gnus, etc: nothing really felt right. I decided what I wanted
was to be able to do a "full update" (including switching to the shell)
if I wanted, but also do a "spot update" when hitting M-g on a
group/topic/etc. So I added the function below to
`gnus-get-new-news-hook'. Basically it checks if I'm only updating a
handful of groups, and calls the underlying "mbsync" to actually fetch
mail from the server. You could also do this for several accounts, using
`make-process' for asynchronous updates.
Hope it's of interest to someone...
(defun my-gnus-retrieve-group ()
(when (memq this-command '(gnus-topic-get-new-news-this-topic
gnus-group-get-new-news-this-group))
(let ((pr-groups
(seq-filter (lambda (g)
(string-match "^nnimap\\+NPR:" g))
(gnus-group-process-prefix
current-prefix-arg))))
(message "Fetching mail for %d group(s)" (length pr-groups))
(when pr-groups
(call-process
nil nil nil
"/usr/bin/mbsync"
(mapconcat (lambda (g)
(format "pr:%s"
(replace-regexp-in-string
"\\." "/"
(nth 1 (split-string g ":")))))
pr-groups " "))))))
(add-hook 'gnus-get-new-news-hook #'my-gnus-retrieve-group)
next reply other threads:[~2020-06-04 17:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-04 17:06 Eric Abrahamsen [this message]
2020-06-04 17:27 ` dick.r.chiang
2020-06-04 17:40 ` Eric Abrahamsen
2020-06-05 15:42 ` Bob Newell
2020-06-05 19:41 ` Eric Abrahamsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87img6sqtw.fsf@ericabrahamsen.net \
--to=eric@ericabrahamsen.net \
--cc=ding@gnus.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).