tabbar mode rocks with customization

Why doing this

I like tabbar mode, and it gives Emacs a “modern” feeling – similar to that available in most web browsers such as my
favorite Firefox.

However, I don’t like the default settings of tabbar mode. So here comes my customization:

color and separator

my current tabbar tabs looks:

And the customization code in .emacs file are:

(setq tabbar-background-color "#959A79") ;; the color of the tabbar background
 '(tabbar-default ((t (:inherit variable-pitch :background "#959A79" :foreground "black" :weight bold))))
 '(tabbar-button ((t (:inherit tabbar-default :foreground "dark red"))))
 '(tabbar-button-highlight ((t (:inherit tabbar-default))))
 '(tabbar-highlight ((t (:underline t))))
 '(tabbar-selected ((t (:inherit tabbar-default :background "#95CA59"))))
 '(tabbar-separator ((t (:inherit tabbar-default :background "#95CA59"))))
 '(tabbar-unselected ((t (:inherit tabbar-default)))))

key bindings:

I use C-S-< and C-S-> to jump among tabs in the same group, and use C-S-n and C-S-p to switch among groups. Here is the
code in .emacs file:

(global-set-key (kbd "C-S-p") 'tabbar-backward-group)
(global-set-key (kbd "C-S-n") 'tabbar-forward-group)
(global-set-key (kbd "C-<") 'tabbar-backward)
(global-set-key (kbd "C->") 'tabbar-forward) ;; tabbar.el, put all the buffers on the tabs.

my favorite tabbar customization: to toggle between 2 different grouping schemes

  • grouping tabs by major mode (the default)
  • grouping tabs by dir the files belonging to

here is the effect:

  • grouping by dir (see how the org, tex, html, and bbl buffers under the same publishing project are grouped together)

  • grouping by major modes (see how all org buffers are grouped together)

here is the code

(defun tabbar-buffer-groups-by-dir ()
        "Put all files in the same directory into the same tab bar"
        (with-current-buffer (current-buffer)
          (let ((dir (expand-file-name default-directory)))
            (cond ;; assign group name until one clause succeeds, so the order is important
             ((eq major-mode 'dired-mode)
              (list "Dired"))
             ((memq major-mode
                    '(help-mode apropos-mode Info-mode Man-mode))
              (list "Help"))
             ((string-match-p "\*.*\*" (buffer-name))
              (list "Misc"))
             (t (list dir))))))

(defun tabbar-switch-grouping-method (&optional arg)
  "Changes grouping method of tabbar to grouping by dir.
With a prefix arg, changes to grouping by major mode."
  (interactive "P")
    (if arg
      (setq tabbar-buffer-groups-function 'tabbar-buffer-groups) ;; the default setting
        (setq tabbar-buffer-groups-function 'tabbar-buffer-groups-by-dir))))

misc settings

(setq tabbar-cycle-scope (quote tabs))
(setq table-time-before-update 0.1)
(setq tabbar-use-images t)

Date: 2012-09-21

Author: Da Zhang

Org version 7.9.1 with Emacs version 24

Validate XHTML 1.0


One thought on “tabbar mode rocks with customization

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s