summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2023-04-16 10:30:38 -0700
committerSean Whitton <spwhitton@spwhitton.name>2023-04-16 13:09:35 -0700
commit121c9f4619cbe5793bccc20460309671163ee497 (patch)
tree3e531f191202be7d18321d453024acf47c372eac
parent2deded7013ceb98335e3a0fc446f23a4bbf53de5 (diff)
downloaddotfiles-121c9f4619cbe5793bccc20460309671163ee497.tar.gz
spw/nnselect-generate-artlist: also disable notmuch cron job
-rw-r--r--.emacs.d/init.el32
-rwxr-xr-xscripts/mail/mmm-cron5
2 files changed, 24 insertions, 13 deletions
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