Gnus development mailing list
 help / color / mirror / Atom feed
* Fetching underlying imap mail on M-g
@ 2020-06-04 17:06 Eric Abrahamsen
  2020-06-04 17:27 ` dick.r.chiang
  0 siblings, 1 reply; 5+ messages in thread
From: Eric Abrahamsen @ 2020-06-04 17:06 UTC (permalink / raw)
  To: ding

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)



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-06-05 19:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-04 17:06 Fetching underlying imap mail on M-g Eric Abrahamsen
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

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).