From 121c9f4619cbe5793bccc20460309671163ee497 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sun, 16 Apr 2023 10:30:38 -0700 Subject: spw/nnselect-generate-artlist: also disable notmuch cron job --- .emacs.d/init.el | 32 +++++++++++++++++++------------- scripts/mail/mmm-cron | 5 +++++ 2 files changed, 24 insertions(+), 13 deletions(-) create mode 100755 scripts/mail/mmm-cron diff --git a/.emacs.d/init.el b/.emacs.d/init.el index 54765baa..8e35502d 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -3634,19 +3634,25 @@ mutt's review view, after exiting EDITOR." (defun spw/nnselect-update-notmuch (group &optional specs _info) (when (and (not spw/this-command-notmuch-updated-p) (spw/gnus-specs-search-notmuch-p specs group)) - ;; Rescan nnmaildir+fmail:inbox to ensure we display new mail. - (gnus-activate-group "nnmaildir+fmail:inbox" 'scan) - ;; Update notmuch database before querying it. - (call-process "notmuch" nil nil nil "new" "--no-hooks") - ;; We want to avoid - ;; (i) changing the db between the calls to `nnselect-request-group' - ;; and `nnselect-request-headers' that occur when entering a group - ;; (see received mail date:@1681255438); and - ;; (ii) updating over and over again in `gnus-group-get-new-news'. - (setq spw/this-command-notmuch-updated-p t) - (spw/add-once-hook 'post-command-hook - (lambda () - (setq spw/this-command-notmuch-updated-p nil))))) + (let* ((lock (expand-file-name "~/.nomovemymail")) + (already-blocked-p (file-exists-p lock))) + (unless already-blocked-p + ;; Block the cron job; 'notmuch new' with --no-hooks will still run. + (with-temp-file lock)) + ;; Rescan nnmaildir+fmail:inbox to ensure we display new mail. + (gnus-activate-group "nnmaildir+fmail:inbox" 'scan) + ;; Update notmuch database before querying it. + (call-process "notmuch" nil nil nil "new" "--no-hooks") + ;; We want to avoid + ;; (i) changing the db between the calls to `nnselect-request-group' + ;; and `nnselect-request-headers' that occur when entering a group + ;; (see received mail date:@1681255438); and + ;; (ii) updating over and over again in `gnus-group-get-new-news'. + (setq spw/this-command-notmuch-updated-p t) + (spw/add-once-hook 'post-command-hook + (lambda () + (unless already-blocked-p (delete-file lock)) + (setq spw/this-command-notmuch-updated-p nil)))))) (advice-add 'nnselect-generate-artlist :before #'spw/nnselect-update-notmuch) (defun spw/gnus-group-nnselect-query (group) diff --git a/scripts/mail/mmm-cron b/scripts/mail/mmm-cron new file mode 100755 index 00000000..3c852fb7 --- /dev/null +++ b/scripts/mail/mmm-cron @@ -0,0 +1,5 @@ +#!/bin/sh + +# 'notmuch new' exits non-zero if ~/.nomovemymail exists, but we don't want to +# get mail from crond if that's the only reason for the failure. +[ -e ~/.nomovemymail ] || exec chronic nice ionice -c 3 notmuch new -- cgit v1.2.3