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

bs-configurations という変数にフィルタリング用の関数を追加してやれば良いわけである.

ここでは"same-mode"という名前をつけてみた.このcodeはace-jump-bufferから抽出した(実際のコードはマクロ).GPL ライセンスの旨を併記しておく.

;; Copyright 2013-2015 Justin Talbott
;; 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-mode (buffer)
  (let ((current-mode major-mode))
    (with-current-buffer buffer
      (not (eq major-mode current-mode)))))

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

そして 例えばこんな感じに設定する.

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