From 594dc7eda49288282ee8c02fc0594fc3aeb97fad Mon Sep 17 00:00:00 2001 From: JSDurand Date: Mon, 16 Aug 2021 00:11:08 +0800 Subject: Display Gnus in a separate tab The separation of Gnus into a tab means I can better handle the mails and deal with them without interrupting my other activities. * basic.el (display-buffer-alist): This creates the tab to display * GNUS. * gnus-conf.el (durand-display-gnus, gnus): This buries the original buffer and calls the previous function. And gnus is after-adviced by this function. This is needed since gnus calls `switch-to-buffer' instead of `display-buffer' internally. (durand-gnus-kill-tab): The kill-tab function kills the tab, if it is present. (durand-gnus-quit, gnus-group-mode-map): Bury the buffer and kills the tab. Bind to the original "q" key. (gnus-exit-gnus-hook): Call the kill-tab function in this hook. --- gnus-conf.el | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'gnus-conf.el') diff --git a/gnus-conf.el b/gnus-conf.el index 39a211a..689a2fa 100644 --- a/gnus-conf.el +++ b/gnus-conf.el @@ -15,6 +15,36 @@ ;; (nnimap-server-port 143)) )) +;;; display using display-buffer + +(defun durand-display-gnus (&rest _args) + "Display the group buffer using display-buffer." + (cond + ((null (get-buffer "*Group*")) + (user-error "No group buffer!")) + (t + (quit-window) + (display-buffer (get-buffer "*Group*"))))) + +(advice-add #'gnus :after #'durand-display-gnus) + +(defun durand-gnus-kill-tab (&rest _args) + "Kill the tab when exiting Gnus." + (cond + ((durand-member "email" + (mapcar (lambda (tab) (cdr (assq 'name tab))) + (funcall tab-bar-tabs-function)) + #'string=) + (tab-bar-close-tab-by-name "email")))) + +(defun durand-gnus-quit () + "Quit and kill tab at the same time." + (interactive) + (bury-buffer) + (durand-gnus-kill-tab)) + +(add-hook 'gnus-exit-gnus-hook #'durand-gnus-kill-tab) + ;;; repunctuate sentences (add-hook 'gnus-part-display-hook 'gnus-treat-repunctuate) @@ -148,7 +178,7 @@ ;;; exiting -(define-key gnus-group-mode-map (vector ?q) #'bury-buffer) +(define-key gnus-group-mode-map (vector ?q) #'durand-gnus-quit) (define-key gnus-group-mode-map (vector ?x) #'gnus-group-exit) ;;; agent key bindings -- cgit v1.2.3-18-g5258