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 (custom-set-faces '(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:
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") (ignore-errors (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)
Which keys do you use to jump between tabs in Firefox?
Not an Emacs way — I use rocker mouse gestures from FireGestures: while holding the right click button, scroll up and down for previous and next tabs.
This is really one of the modes I would never recommend to beginners. It is inferior to speedbar and it tends to make you use Emacs in a less Emacs-y way. Well, and it is gets in the way if you are doing heavy batch editing or use the same Emacs session for tons of stuff. Rather look at ido or ibuffer if you want to switch faster between buffers.
Well, I like Firefox equally as Emacs. I don’t feel that I need to do everything the Emacs-y way. In fact, as a daily Emacs user with more than 6 years of experience, I don’t like the floating window from speed bar. I use ibuffer, ido, and dired quite frequently, but it is so handy to have related buffers shown in the same tab group, and to be able to easily and intuitively jump around them.
This is dirty hack configuration for tabbar it kinda mix of other scripts. i really dunno elisp.
https://github.com/rhoit/dot-emacs/tree/master/plug-ins
Good article man. Still works with latest Emacs version.
Cool. The beauty of Emacs lisp!
Hi, thanks for the article. There does not seem a way though to have keyboard-bindings to right away select the “1st”, the “2nd”, “3rd”, … tab ?
E.g. like it is common (also in Firefox :)): M+1 = selects 1st-tab or alternatively C+1 = selects 1st-tab
I am not aware of such a function from tabbar-mode.
Thanks for the comment.