From a2f5b830645e48ea10f0d418942eb32e97cb8c23 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Wed, 6 Dec 2023 19:36:01 +0000 Subject: add spw/reset-gnus & rework spw/gnus-startup-wrapper in light of it --- .emacs.d/init.el | 50 +++++++++++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/.emacs.d/init.el b/.emacs.d/init.el index 314c428d..b388ba67 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -3233,30 +3233,38 @@ mutt's review view, after exiting EDITOR." ,(list ',name ,@arglist-names))))) ,@(cdr parsed-body))))) +(spw/defun-pass-to-gdbmacs spw/reset-gnus () + "Prepare to move Gnus session to another host, or just reset its state. + +We want Gnus running on just one machine at once to avoid conflicts in +automatic updates to score files, and to avoid mail appearing to come back +unread." + (interactive) + (when (gnus-alive-p) + (pop-to-buffer-same-window gnus-group-buffer) + (gnus-group-exit)) + (if (gnus-alive-p) + (user-error "Gnus still running") + (delete-file "~/.newsrc.eld") + (dolist (mailbox (delete "annex" + (directory-files "~/.fmail/" nil "[[:alpha:]]"))) + (delete-directory (format "~/.fmail/%s/.nnmaildir/" mailbox) t)) + (let ((default-directory (expand-file-name "~/src/athpriv/"))) + (spw/eshell-jump 'strict) + (spw/eshell-insert-and-send "mr autoci && mr up && mr push")))) + (defvar gnus-always-read-dribble-file) (defun spw/gnus-startup-wrapper (orig-fun &rest args) - (when-let ((daemon (and (file-directory-p "~/.fmail/") (daemonp)))) - (unless (file-exists-p "~/.newsrc.eld") - (user-error "Must use dedicated Emacs for Gnus first run")) - (unless (or (string= "gdbmacs" daemon) - (spw/on-host-primary-p "athena.silentflame.com")) - (user-error "This is not the Gnusmacs you're looking for"))) - (let ((repo (expand-file-name "~/src/athpriv/"))) - (when (file-directory-p repo) - ;; We want Gnus running on just one machine at once to avoid conflicts - ;; in automatic updates to score files. If there are no uncommitted - ;; changes then it might be that Gnus is already running somewhere else. - (unless (cl-remove-if-not - (apply-partially #'string-match - "^.. \"?News/.+\\.\\(?:SCORE\\|ADAPT\\)\"?$") - (process-lines "mr" "-d" repo "status")) - (if (yes-or-no-p - "~/src/athpriv/News/ has no changes; really start Gnus?") - (unless (zerop (call-process "mr" nil "*myrepos athpriv update*" - nil "-d" repo "update")) - (error "mr couldn't update ~/src/athpriv/")) - (user-error "Aborting"))))) + (let ((daemon (and (file-directory-p "~/.fmail/") (daemonp)))) + (cond ((and daemon (not (file-exists-p "~/.newsrc.eld"))) + (user-error "Must use dedicated Emacs for Gnus first run")) + ((and daemon (not (string= "gdbmacs" daemon)) + (not (spw/on-host-primary-p "athena.silentflame.com"))) + (user-error "This is not the Gnusmacs you're looking for")) + ((not (or daemon + (yes-or-no-p "Confirm ~/src/athpriv/ up-to-date"))) + (user-error "Aborting")))) (let ((gc-cons-percentage 0.6) (gc-cons-threshold 402653184) (gnus-always-read-dribble-file (file-exists-p "~/.newsrc.eld"))) -- cgit v1.2.3