summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2023-03-24 17:41:22 -0700
committerSean Whitton <spwhitton@spwhitton.name>2023-04-16 13:07:22 -0700
commit761e1bd10f679cca74728f343dcab84116514efb (patch)
treec5aed32affd16cfe1d0aacf649da0712fc285981
parentde5ef4d1f5811942a8941759be0dc2bcd1669029 (diff)
downloaddotfiles-761e1bd10f679cca74728f343dcab84116514efb.tar.gz
have at most one notmuch nnselect buffer whose changes we will save
-rw-r--r--.emacs.d/init.el30
1 files changed, 30 insertions, 0 deletions
diff --git a/.emacs.d/init.el b/.emacs.d/init.el
index 3881a049..94a5c81c 100644
--- a/.emacs.d/init.el
+++ b/.emacs.d/init.el
@@ -263,6 +263,7 @@ windows side-by-side in the frame."
'(gnus-sum-thread-tree-single-leaf "╰► ")
'(gnus-sum-thread-tree-vertical "│")
'(gnus-summary-line-format "%U%R%z %(%12&user-date; %*%-23,23f%) %B%s\12")
+ '(gnus-summary-mode-line-format "Gnus: %u&summary;%g [%A] %Z")
'(gnus-summary-thread-gathering-function 'gnus-gather-threads-by-references)
'(gnus-suppress-duplicates t)
'(gnus-thread-sort-functions
@@ -3451,6 +3452,8 @@ mutt's review view, after exiting EDITOR."
(unless (gnus-alive-p) (gnus-no-server))
;; Kill all summaries in case any of their queries have changed.
+ ;; Possibly we should kill only `spw/saveable-notmuch-nnselect-summary',
+ ;; and only if it's not ephemeral.
(catch 'done
(dolist (buffer (buffer-list))
(when (buffer-local-value 'gnus-dead-summary-mode buffer)
@@ -3580,6 +3583,33 @@ mutt's review view, after exiting EDITOR."
(caadr (assq 'search-group-spec (cdr (assq 'nnselect-args specs))))))))
(defvar spw/this-command-notmuch-updated-p nil)
+(defvar spw/saveable-notmuch-nnselect-summary nil)
+(defvar gnus-group-is-exiting-p)
+
+(defun spw/set-first-notmuch-nnselect-summary ()
+ (cond ((and gnus-group-is-exiting-p
+ (eq (current-buffer) spw/saveable-notmuch-nnselect-summary))
+ (setq spw/saveable-notmuch-nnselect-summary nil))
+ ((and (not gnus-group-is-exiting-p)
+ (spw/gnus-specs-search-notmuch-p)
+ (not (buffer-live-p spw/saveable-notmuch-nnselect-summary)))
+ (setq spw/saveable-notmuch-nnselect-summary (current-buffer)))))
+(spw/feature-add-hook spw/set-first-notmuch-nnselect-summary
+ (gnus-sum gnus-select-group-hook)
+ (gnus-sum gnus-summary-prepare-exit-hook))
+
+(defun spw/gnus-summary-exit (orig-fun &rest args)
+ (if (and (spw/gnus-specs-search-notmuch-p)
+ (not (eq (current-buffer) spw/saveable-notmuch-nnselect-summary)))
+ (gnus-summary-exit-no-update t)
+ (apply orig-fun args)))
+(advice-add 'gnus-summary-exit :around #'spw/gnus-summary-exit)
+
+(defun gnus-user-format-function-summary (_ignore)
+ (if (and (spw/gnus-specs-search-notmuch-p)
+ (not (eq (current-buffer) spw/saveable-notmuch-nnselect-summary)))
+ "%%%%"
+ ""))
(defun spw/nnselect-update-notmuch (group &optional specs _info)
(when (and (not spw/this-command-notmuch-updated-p)