Index: sbbs.el ================================================================== --- sbbs.el +++ sbbs.el @@ -61,10 +61,14 @@ :type 'boolean) (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")) "Face for spoiler text in threads.") @@ -225,10 +229,18 @@ (unless (and (eq 'highlight (get-text-property (point) 'face)) (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 (defconst sbbs--link-regexp @@ -755,10 +767,13 @@ (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) (hl-line-mode t))