From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 11769 invoked from network); 4 Jun 2020 17:08:15 -0000 Received: from lists1.math.uh.edu (129.7.128.208) by inbox.vuxu.org with ESMTPUTF8; 4 Jun 2020 17:08:15 -0000 Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by lists1.math.uh.edu with smtp (Exim 4.92.3) (envelope-from ) id 1jgtKx-0001mT-77; Thu, 04 Jun 2020 12:07:27 -0500 Received: from mx1.math.uh.edu ([129.7.128.32]) by lists1.math.uh.edu with esmtps (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92.3) (envelope-from ) id 1jgtKu-0001ji-8X for ding@lists.math.uh.edu; Thu, 04 Jun 2020 12:07:24 -0500 Received: from quimby.gnus.org ([95.216.78.240]) by mx1.math.uh.edu with esmtps (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1jgtKd-004TNK-Os for ding@lists.math.uh.edu; Thu, 04 Jun 2020 12:07:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:Mime-Version:Message-ID:Date:Subject:From:To: Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=6XpZHrDDh4kG2pVms9lEbrHRbbr6VvMen/RMzb2P19w=; b=b3pacisD/HuHmlt75X/idn4DP8 eNB5M0fKYea0NA8xkYVR3SEINytGX4ojJE5dS11zlrT390Jr/1QkBYW6gUQaytkSBzj7HMVqTDzOT jEcs9rKn1KLo+4F/p/T6dN2KqlwxniNUMcxIm0ZyxJtTTFLxOO7oBX60YQxTY2iNZQc4=; Received: from ciao.gmane.io ([159.69.161.202]) by quimby.gnus.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jgtKW-00064Y-Ed for ding@gnus.org; Thu, 04 Jun 2020 19:07:03 +0200 Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1jgtKV-000Y1t-0b for ding@gnus.org; Thu, 04 Jun 2020 19:06:59 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: ding@gnus.org From: Eric Abrahamsen Subject: Fetching underlying imap mail on M-g Date: Thu, 04 Jun 2020 10:06:51 -0700 Message-ID: <87img6sqtw.fsf@ericabrahamsen.net> Mime-Version: 1.0 Content-Type: text/plain User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cancel-Lock: sha1:SF+s99gpuYSGfD6ky2WfCPCdPk8= List-ID: Precedence: bulk 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)