summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2023-12-06 19:36:01 +0000
committerSean Whitton <spwhitton@spwhitton.name>2023-12-06 19:36:06 +0000
commita2f5b830645e48ea10f0d418942eb32e97cb8c23 (patch)
tree340a8fdb181ffdd2f098901caa24cb59c116c319
parentea866392d8e7eec1628b9086ab9ed2f82a72b0b0 (diff)
downloaddotfiles-a2f5b830645e48ea10f0d418942eb32e97cb8c23.tar.gz
add spw/reset-gnus & rework spw/gnus-startup-wrapper in light of it
-rw-r--r--.emacs.d/init.el50
1 files 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")))