【Emacs】bsにおけるバッファリストやバッファ切り替え対象を同じタブに限定したいとき

前回記事の関連. tabspaces.elから一部関数を拝借したので,ライセンスを付記する.

;; https://github.com/mclear-tools/tabspaces/blob/main/tabspaces.el
;; Copyright 2013-2015 Justin Talbott
;; Copyright (C) 2022 Colin McLear
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program.  If not, see <https://www.gnu.org/licenses/>.
(defun bs-config--same-tab-buffer-list (&optional frame tabnum)
  (let ((list
         (if tabnum
             (let ((tab (nth tabnum (frame-parameter frame 'tabs))))
               (if (eq 'current-tab (car tab))
                   (frame-parameter frame 'buffer-list)
                 (or
                  (cdr (assq 'wc-bl tab))
                  (mapcar 'get-buffer
                          (car (cdr (assq #'bs-config--same-tab-buffer-list
                                          (assq 'ws tab))))))))
           (frame-parameter frame 'buffer-list))))
    (seq-filter #'buffer-live-p list)))
(defun bs-config--same-tab (buffer)
  (let ((current-buffer-list
         (bs-config--same-tab-buffer-list
          nil (tab-bar--current-tab-index))))
    (with-current-buffer buffer
      (not (member buffer current-buffer-list)))))

(add-to-list 'bs-configurations
             '("same-tab" nil nil nil bs-config--same-tab nil))

設定は例えば:

(setq bs-default-configuration "same-tab")
(setq bs-cycle-configuration-name "same-tab")