From 761e1bd10f679cca74728f343dcab84116514efb Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Fri, 24 Mar 2023 17:41:22 -0700 Subject: have at most one notmuch nnselect buffer whose changes we will save --- .emacs.d/init.el | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) 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) -- cgit v1.2.3