【Emacs】tabbarでタブエディター化

スポンサーリンク

以前の記事でelscreenを使ってタブエディター化したが、タブはやっぱりバッファーと対で対応していた方が私には判りやすいので、tabbar.elでEmacsをタブエディター化したので、備忘録を残す。

準備

tabbarパッケージをインストール。

M-x package-install<RET>
tabbar

Emacsの設定

下記を初期設定に追加。
尚、私はinit-loaderを利用しており、~/.emacs.d/inits/30_tabbar.elファイルを作成。

;;
;; tabbarの設定
;;
(require 'tabbar)
(tabbar-mode)

(tabbar-mwheel-mode nil)                  ;; マウスホイール無効
(setq tabbar-buffer-groups-function nil)  ;; グループ無効
(setq tabbar-use-images nil)              ;; 画像を使わない

;;----- キーに割り当てる
;;(global-set-key (kbd "<C-tab>") 'tabbar-forward-tab)
;;(global-set-key (kbd "<C-S-tab>") 'tabbar-backward-tab)
(global-set-key (kbd "<f8>") 'tabbar-forward-tab)
(global-set-key (kbd "<f7>") 'tabbar-backward-tab)
(global-unset-key (kbd "C-z"))
(global-set-key (kbd "C-z C-n") 'tabbar-forward-tab)
(global-set-key (kbd "C-z C-p") 'tabbar-backward-tab)

;;----- 左側のボタンを消す
(dolist (btn '(tabbar-buffer-home-button
               tabbar-scroll-left-button
               tabbar-scroll-right-button))
  (set btn (cons (cons "" nil)
                 (cons "" nil))))


;;----- タブのセパレーターの長さ
(setq tabbar-separator '(2.0))


;;----- タブの色(CUIの時。GUIの時は後でカラーテーマが適用)
(set-face-attribute
 'tabbar-default nil
 :background "brightblack"
 :foreground "white"
 )
(set-face-attribute
 'tabbar-selected nil
 :background "#ff5f00"
 :foreground "brightwhite"
 :box nil
 )
(set-face-attribute
 'tabbar-modified nil
 :background "brightred"
 :foreground "brightwhite"
 :box nil
 )

(when window-system                       ; GUI時
  ;; 外観変更
  (set-face-attribute
   'tabbar-default nil
   :family "MeiryoKe_Gothic"
   :background "#34495E"
   :foreground "#EEEEEE"
   :height 0.85
   )
  (set-face-attribute
   'tabbar-unselected nil
   :background "#34495E"
   :foreground "#EEEEEE"
   :box nil
  )
  (set-face-attribute
   'tabbar-modified nil
   :background "#E67E22"
   :foreground "#EEEEEE"
   :box nil
  )
  (set-face-attribute
   'tabbar-selected nil
   :background "#E74C3C"
   :foreground "#EEEEEE"
   :box nil)
  (set-face-attribute
   'tabbar-button nil
   :box nil)
  (set-face-attribute
   'tabbar-separator nil
   :height 2.0)
)

;;----- 表示するバッファ
(defun my-tabbar-buffer-list ()
  (delq nil
        (mapcar #'(lambda (b)
                    (cond
                     ;; Always include the current buffer.
                     ((eq (current-buffer) b) b)
                     ((buffer-file-name b) b)
                     ((char-equal ?\  (aref (buffer-name b) 0)) nil)
                     ((equal "*scratch*" (buffer-name b)) b) ; *scratch*バッファは表示する
                     ((char-equal ?* (aref (buffer-name b) 0)) nil) ; それ以外の * で始まるバッファは表示しない
                     ((buffer-live-p b) b)))
                (buffer-list))))
(setq tabbar-buffer-list-function 'my-tabbar-buffer-list)

F9F10キーにタブ切り換え機能を割り当てた。もちろんマウスクリックでの切り換えも可能。

キー 説明
<f7> 左のタブへ切り換え(tabbar-backward-tab)
<f8> 右のタブへ切り換え(tabbar-forward-tab)

画面例

tabbar画像

設定ファイル

私の使っているtabbarの設定を含むEmacs設定ファイル一式をGitHubに公開。(下記記事で紹介)

【Emacs 25-29】初期設定ファイル(~/.emacs.d/)をGitHubに公開
これまで紹介してきた、私の使ってるEmacsの初期設定ファイル「~/.emacs.d/」をGitHub(下記URL)に公開した。macOS, Windows, Linuxで共用。 Emacsの初期状態ではお世辞にも使い勝手がいいとは言えない...

参照記事

【Emacs】init-loaderで初期設定ファイルを整理
Emacsの初期設定ファイルに設定記述する事で便利にしていく事ができるが、いろいろ書いていくと、長くなり見通しが悪くなってくる。 そこで「init-loader」パッケージを導入する事で、設定を分割して記述する。 インストール M-x pa...
【Emacs 25-29】初期設定ファイル(~/.emacs.d/)をGitHubに公開
これまで紹介してきた、私の使ってるEmacsの初期設定ファイル「~/.emacs.d/」をGitHub(下記URL)に公開した。macOS, Windows, Linuxで共用。 Emacsの初期状態ではお世辞にも使い勝手がいいとは言えない...

参考

  1. Emacs のカスタマイズ

コメント

タイトルとURLをコピーしました