diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2022-07-06 22:39:44 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2022-07-11 18:37:32 -0700 |
commit | 90c20c57915d9d36c24515f96b927af920ba7b85 (patch) | |
tree | b37cebbfa67506ece116565d3945dadf9e6b6411 | |
parent | bb824cac42918a93e5b69d994d32ca2a430ab4f8 (diff) | |
download | dotfiles-90c20c57915d9d36c24515f96b927af920ba7b85.tar.gz |
populate spw/process-view-ids earlier
gnus-summary-prepared-hook happens after Gnus displays the first article.
-rw-r--r-- | .emacs.d/init.el | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/.emacs.d/init.el b/.emacs.d/init.el index 98df803c..7fca6a5f 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -2919,7 +2919,7 @@ mutt's review view, after exiting EDITOR." "--format=text" "--format-version=4" overlap)))) ;; Empty hash table means we know there is no mail from processing views. -;; nil means we were not able to check, so no catching up is allowed. +;; nil means we haven't yet / couldn't check, so no catching up is allowed. ;; ;; Note that this machinery can be defeated by `gnus-summary-clear-*'. ;; We call notmuch(1) in `spw/all-group-process-view-ids' to update its idea @@ -2928,28 +2928,27 @@ mutt's review view, after exiting EDITOR." ;; restore tag:unread. (defvar-local spw/process-view-ids nil) -(defun spw/gnus-summary-generate-process-view-ids () - (setq spw/process-view-ids nil) - (let ((ids (spw/all-group-process-view-ids gnus-newsgroup-name)) - (table (make-hash-table :test #'equal))) - (dolist (id ids) (puthash id t table)) - ;; Only point the variable at the table if we got this far. - (setq spw/process-view-ids table))) -(with-eval-after-load 'gnus-sum - (add-hook 'gnus-summary-prepared-hook - #'spw/gnus-summary-generate-process-view-ids)) - -(defun spw/check-group-process-view-id (id) +(defun spw/check-group-process-view-ids (&optional id) (if spw/process-view-ids - (gethash id spw/process-view-ids) - (error "This group/range may contain articles from processing views"))) + (or (not id) (gethash id spw/process-view-ids)) + (let ((ids (spw/all-group-process-view-ids gnus-newsgroup-name)) + (table (make-hash-table :test #'equal))) + (dolist (id ids) (puthash id t table)) + ;; Only point the variable at the table if we got this far. + (setq spw/process-view-ids table) + ;; Now try the check again. + (or (not id) (gethash id spw/process-view-ids))))) + +(with-eval-after-load 'gnus-sum + (add-hook 'gnus-summary-generate-hook + (lambda () (setq spw/process-view-ids nil)))) (defun spw/gnus-mark-article-hook () "Don't mark any mail from processing views as read just for viewing it." (unless (or (spw/gnus-summary-processing-view-p) (memq (gnus-summary-article-mark) (list gnus-read-mark gnus-del-mark))) - (if (spw/check-group-process-view-id (gnus-summary-header "message-id")) + (if (spw/check-group-process-view-ids (gnus-summary-header "message-id")) (message "Not marking mail from processing views as read") (gnus-summary-mark-read-and-unread-as-read)))) @@ -2967,7 +2966,7 @@ mutt's review view, after exiting EDITOR." (user-error "Cannot catch up processing views")) ;; We could pay attention to the TO-HERE and REVERSE arguments and check ;; only those IDs, though it'd be slower. - (unless (and spw/process-view-ids + (unless (and (spw/check-group-process-view-ids) (zerop (hash-table-count spw/process-view-ids))) (error "This group/range may contain articles from processing views")))) (advice-add 'gnus-summary-catchup :before #'spw/guard-gnus-summary-catchup) @@ -2975,7 +2974,7 @@ mutt's review view, after exiting EDITOR." (defun spw/gnus-summary-mark-as-read-forward () (interactive) (if (not (or (spw/gnus-summary-processing-view-p) - (spw/check-group-process-view-id + (spw/check-group-process-view-ids (gnus-summary-header "message-id")))) (call-interactively #'gnus-summary-mark-as-read-forward) ;; We want an 'R' mark, not 'r'. |