@@ -62,8 +62,12 @@ (defcustom sbbs-open-at-last-post nil "Jump to last post in a thread when opening a thread." :type 'boolean) + +(defcustom sbbs-kill-threads-on-quit t + "Kill all thread buffers when quitting a board buffer." + :type 'boolean) (defface sbbs--semi-spoiler-face '((((background light)) :background "gray80" :foreground "black") (((background dark)) :background "gray20" :foreground "white")) @@ -226,8 +230,16 @@ (looking-at-p "\\`#[[:digit:]]+")) ;; in case we are on the first character of a post, we shouldn't ;; jump back, since that would mean setting to point to NR-1. (sbbs-read-previous 1))) + +(defun sbbs--cleanup-board () + "Close all thread buffers for the current board." + (when sbbs-kill-threads-on-quit + (dolist (buf (buffer-list)) + (when (and (eq (buffer-local-value 'sbbs--board buf) sbbs--board) + (buffer-local-value 'sbbs--thread-id buf)) + (kill-buffer buf))))) ;;; UI GENERATOR @@ -756,8 +768,11 @@ (setq tabulated-list-format [("Date" 16 t) ("#" 3 t :right-align t) ("Headline" 0 nil)] tabulated-list-sort-key '("Date" . t)) + (add-hook 'quit-window-hook + 'sbbs--cleanup-board + nil t) (add-hook 'tabulated-list-revert-hook #'sbbs--reload-board nil t) (tabulated-list-init-header)