The emacs extension of the day is tabbar.el. I was feeling jealous of cool new Mac text editors like TextMate with their drawers and their clickable tab-like buttons. How I wished that emacs had a pop-out drawer, or at the very least, tabs.
Although it is documented, tabbar has no handy start-up guide for beginners. With the help of Zhou Chen’s Emacs Tools page, I figured out that I needed to add
(require 'tabbar) (tabbar-mode)
to my .emacs file just to get the tab bar to show up.
Next, I wanted to do a keybinding to get emacs to switch tabs with command-shift-left-arrow and command-shift-right-arrow, the way Safari and iTerm do. With the help of the emacs function keys info node, I found the right combination for my .emacs file:
(global-set-key [A-S-left] 'tabbar-backward) (global-set-key [A-S-right] 'tabbar-forward)
[The above may depend on (setq mac-command-key-is-meta nil). If you don’t have that setting, then try M-S-left and M-S-right instead.] You can also assign ‘tabbar-backward-group and ‘tabbar-forward-group the same way, but ‘tabbar-backward and ‘tabbar-forward will scroll through groups as well so I didn’t bother.
I didn’t like the way tabbar assigned my buffers to groups, so I wrote my own version of the tabbar-buffer-groups function and put it in my .emacs file, too.
Instead of making a new tab group for each major mode, my function puts most tabs into the main tab group (called “Main”), weird things like the message buffer, help buffers, and anything that opens in fundamental mode into the “Misc” group, and keeps the “Mail” group around from the original function, although I don’t use emacs for mail.
(defun tabbar-buffer-groups (buffer) "Return the list of group names BUFFER belongs to. Return only one group for each buffer." (with-current-buffer (get-buffer buffer) (cond ((or (get-buffer-process (current-buffer)) (memq major-mode '(comint-mode compilation-mode))) '("Misc") ) ((member (buffer-name) '("*scratch*")) '("Main") ) ((member (buffer-name) '("*Messages*")) '("Misc") ) ((eq major-mode 'dired-mode) '("Main") ) ((memq major-mode '(fundamental-mode help-mode apropos-mode Info-mode Man-mode)) '("Misc") ) ((memq major-mode '(tex-mode latex-mode text-mode xml-mode)) '("Main") ) ((memq major-mode '(rmail-mode rmail-edit-mode vm-summary-mode vm-mode mail-mode mh-letter-mode mh-show-mode mh-folder-mode gnus-summary-mode message-mode gnus-group-mode gnus-article-mode score-mode gnus-browse-killed-mode)) '("Mail") ) (t '("Main") ) )))
I’d like better foreground and background colors on the tabs themselves, but I can’t get customize to save my settings.565