Created
July 30, 2021 11:07
-
-
Save linktohack/b0f13e6056d60745115208e13542c23e to your computer and use it in GitHub Desktop.
Delete window when the last tab buried.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(setq tab-line-close-tab-function | |
#'(lambda (tab) | |
"Delete window when the last tab buried." | |
(let* ((buffer (if (bufferp tab) tab (cdr (assq 'buffer tab)))) | |
(window (get-buffer-window buffer))) | |
(with-selected-window (or window (selected-window)) | |
(let ((last-tab-p (length< (tab-line-tabs-window-buffers) 2))) | |
(if (eq buffer (current-buffer)) | |
(bury-buffer) | |
(set-window-prev-buffers nil (assq-delete-all buffer (window-prev-buffers))) | |
(set-window-next-buffers nil (delq buffer (window-next-buffers)))) | |
(when last-tab-p | |
(ignore-errors (delete-window window)))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment