summary refs log tree commit diff
diff options
context:
space:
mode:
authorTerin Stock <terinjokes@gmail.com>2022-07-18 23:58:27 -0700
committerTerin Stock <terinjokes@gmail.com>2022-07-19 00:04:44 -0700
commit80abbb881471632b481c6df3cc66f6d6cce68629 (patch)
treedb1231471cb9488453d3b975a7aff6e54a5a0e59
parent8efcf39a3975f2a65d8e34b8d4cf07179aecc5df (diff)
gnus: manage workspaces
Adds a new function to open gnus in the `*gnus*` workspace, which will
automatically be cleaned up once gnus is closed.
-rw-r--r--gnus.el31
1 files changed, 31 insertions, 0 deletions
diff --git a/gnus.el b/gnus.el
index 39a872f..ef89dee 100644
--- a/gnus.el
+++ b/gnus.el
@@ -1,8 +1,39 @@
 ;;; gnus.el -*- lexical-binding: t; -*-
 
+(defvar +gnus--wconf nil)
+(defvar +gnus-workspace-name "*gnus*")
+
+(setq gnus-startup-file "~/Sync/gnus/newsrc")
+
 (load! "gnus-article-treat-patch")
 (require 'gnus-article-treat-patch)
 (add-to-list 'gnus-article-patch-conditions "^@@ -[0-9]+,[0-9]+ \\+[0-9]+,[0-9]+ @@")
 
 (setq gnus-select-method '(nnnil "")
       gnus-secondary-select-methods '((nnmaildir "Maildir" (directory "/home/terin/.nnmaildir"))))
+(defun =gnus ()
+  "Activate `gnus' in its workspace."
+  (interactive)
+  (if (featurep! :ui workspaces)
+      (progn
+        (+workspace-switch +gnus-workspace-name t)
+        (doom/switch-to-scratch-buffer)
+        (gnus)
+        (+workspace/display))
+    (setq +gnus--wconf (current-window-configuration))
+    (delete-other-windows)
+    (switch-to-buffer (doom-fallback-buffer))
+    (gnus)))
+
+(defun +gnus-cleanup-h ()
+  "Cleanup after a gnus session."
+  (interactive)
+  (if (and (featurep! :ui workspaces)
+           (+workspace-exists-p +gnus-workspace-name))
+      (+workspace/delete +gnus-workspace-name)
+    (when (window-configuration-p +gnus--wconf)
+      (set-window-configuration +gnus--wconf))
+    (setq +gnus--wconf nil)
+    (previous-buffer)))
+
+(add-hook! 'gnus-exit-gnus-hook #'+gnus-cleanup-h)