From 80abbb881471632b481c6df3cc66f6d6cce68629 Mon Sep 17 00:00:00 2001 From: Terin Stock Date: Mon, 18 Jul 2022 23:58:27 -0700 Subject: gnus: manage workspaces Adds a new function to open gnus in the `*gnus*` workspace, which will automatically be cleaned up once gnus is closed. --- gnus.el | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) 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) -- cgit 1.4.1